register Vocabulary Exporter (ref. #180)
This commit is contained in:
parent
0636edf87a
commit
6342fbc1f6
|
@ -20,6 +20,15 @@ class Export_Handler {
|
||||||
'class_name' => '\Tainacan\Exporter\CSV'
|
'class_name' => '\Tainacan\Exporter\CSV'
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
$this->register_exporter([
|
||||||
|
'name' => 'Vocabulary CSV',
|
||||||
|
'description' => __('Allows you to export a taxonomy to a CSV file', 'tainacan'),
|
||||||
|
'slug' => 'vocabularycsv',
|
||||||
|
'class_name' => '\Tainacan\Exporter\Term_Exporter',
|
||||||
|
'manual_mapping' => false,
|
||||||
|
'manual_collection' => false
|
||||||
|
]);
|
||||||
|
|
||||||
do_action('tainacan_register_exporters');
|
do_action('tainacan_register_exporters');
|
||||||
|
|
||||||
add_action( 'tainacan-enqueue-admin-scripts', array($this, 'enqueue_scripts') );
|
add_action( 'tainacan-enqueue-admin-scripts', array($this, 'enqueue_scripts') );
|
||||||
|
|
|
@ -25,8 +25,6 @@ class Term_Exporter extends Exporter {
|
||||||
|
|
||||||
public function __construct($attributes = array()){
|
public function __construct($attributes = array()){
|
||||||
parent::__construct($attributes);
|
parent::__construct($attributes);
|
||||||
$this->set_accepted_mapping_methods('any'); // set all method to mapping
|
|
||||||
$this->accept_no_mapping = true;
|
|
||||||
|
|
||||||
$this->set_default_options([
|
$this->set_default_options([
|
||||||
'delimiter' => ',',
|
'delimiter' => ',',
|
||||||
|
@ -67,6 +65,14 @@ class Term_Exporter extends Exporter {
|
||||||
return rtrim($data, "\n");
|
return rtrim($data, "\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function output_header() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function output_footer() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public function options_form() {
|
public function options_form() {
|
||||||
ob_start();
|
ob_start();
|
||||||
?>
|
?>
|
||||||
|
@ -165,7 +171,7 @@ class Term_Exporter extends Exporter {
|
||||||
*/
|
*/
|
||||||
public function get_terms_recursively( $term_repo, $taxonomy, $parent = 0, $level = 0 ){
|
public function get_terms_recursively( $term_repo, $taxonomy, $parent = 0, $level = 0 ){
|
||||||
$terms = $term_repo->fetch([ 'parent' => $parent ], $taxonomy->get_id());
|
$terms = $term_repo->fetch([ 'parent' => $parent ], $taxonomy->get_id());
|
||||||
|
$this->add_log(sizeof($terms));
|
||||||
if( $terms && sizeof($terms) > 0 ){
|
if( $terms && sizeof($terms) > 0 ){
|
||||||
$level++;
|
$level++;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue