register Vocabulary Exporter (ref. #180)

This commit is contained in:
Eduardo Humberto 2019-01-15 20:16:58 -02:00
parent 0636edf87a
commit 6342fbc1f6
2 changed files with 18 additions and 3 deletions

View File

@ -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');

View File

@ -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++;