From 6342fbc1f6a39b59ab1942298611f5faed1d7297 Mon Sep 17 00:00:00 2001 From: Eduardo Humberto Date: Tue, 15 Jan 2019 20:16:58 -0200 Subject: [PATCH] register Vocabulary Exporter (ref. #180) --- src/exporter/class-tainacan-export-handler.php | 9 +++++++++ src/exporter/class-tainacan-term-exporter.php | 12 +++++++++--- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/exporter/class-tainacan-export-handler.php b/src/exporter/class-tainacan-export-handler.php index e55e3be2b..ca9261e9f 100644 --- a/src/exporter/class-tainacan-export-handler.php +++ b/src/exporter/class-tainacan-export-handler.php @@ -19,6 +19,15 @@ class Export_Handler { 'slug' => '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'); diff --git a/src/exporter/class-tainacan-term-exporter.php b/src/exporter/class-tainacan-term-exporter.php index 4e389341d..09298352f 100644 --- a/src/exporter/class-tainacan-term-exporter.php +++ b/src/exporter/class-tainacan-term-exporter.php @@ -25,8 +25,6 @@ class Term_Exporter extends Exporter { public function __construct($attributes = array()){ parent::__construct($attributes); - $this->set_accepted_mapping_methods('any'); // set all method to mapping - $this->accept_no_mapping = true; $this->set_default_options([ 'delimiter' => ',', @@ -67,6 +65,14 @@ class Term_Exporter extends Exporter { return rtrim($data, "\n"); } + public function output_header() { + return false; + } + + public function output_footer() { + return false; + } + public function options_form() { ob_start(); ?> @@ -165,7 +171,7 @@ class Term_Exporter extends Exporter { */ public function get_terms_recursively( $term_repo, $taxonomy, $parent = 0, $level = 0 ){ $terms = $term_repo->fetch([ 'parent' => $parent ], $taxonomy->get_id()); - + $this->add_log(sizeof($terms)); if( $terms && sizeof($terms) > 0 ){ $level++;