diff --git a/src/classes/tainacan-creator.php b/src/classes/tainacan-creator.php index e435f7f72..0228cd4f3 100644 --- a/src/classes/tainacan-creator.php +++ b/src/classes/tainacan-creator.php @@ -54,7 +54,11 @@ function tainacan_autoload($class_name){ $sliced = array_slice($class_path, 1, count($class_path) -2); if( isset( $class_path[1] ) && $class_path[1] === 'Importer' ){ - $dir = TAINACAN_IMPORTER_DIR; + $dir = TAINACAN_IMPORTER_DIR; + $dir_import = strtolower(str_replace('_', '-' , $class_name)); + if (file_exists("$dir$dir_import/")) { + $dir .= "$dir_import/"; + } } else if( isset( $class_path[1] ) && $class_path[1] === 'Exposers' ){ $dir = TAINACAN_EXPOSERS_DIR; if(count($class_path) > 3) $dir .= strtolower($class_path[2]).DIRECTORY_SEPARATOR; diff --git a/src/importer/class-tainacan-importer-handler.php b/src/importer/class-tainacan-importer-handler.php index ec6588ca2..af1ed33c1 100644 --- a/src/importer/class-tainacan-importer-handler.php +++ b/src/importer/class-tainacan-importer-handler.php @@ -54,6 +54,12 @@ class Importer_Handler { do_action('tainacan_register_importers'); + add_action( 'tainacan-enqueue-admin-scripts', array($this, 'enqueue_scripts') ); + } + + function enqueue_scripts() { + global $TAINACAN_BASE_URL; + wp_enqueue_script('import_term_csv_script', $TAINACAN_BASE_URL . '/importer/term-importer/js/term.js', false, false, true); } function add_to_queue(\Tainacan\Importer\Importer $importer_object) { diff --git a/src/importer/class-tainacan-term-importer.php b/src/importer/term-importer/class-tainacan-term-importer.php similarity index 70% rename from src/importer/class-tainacan-term-importer.php rename to src/importer/term-importer/class-tainacan-term-importer.php index b51170e4a..a85937263 100644 --- a/src/importer/class-tainacan-term-importer.php +++ b/src/importer/term-importer/class-tainacan-term-importer.php @@ -14,6 +14,11 @@ use \Tainacan\Entities; class Term_Importer extends Importer { protected $steps = [ + [ + 'name' => 'Create Taxonomy', + 'progress_label' => 'Creating taxonomy', + 'callback' => 'create_taxonomy' + ], [ 'name' => 'Import Terms', 'progress_label' => 'Creating terms', @@ -28,7 +33,8 @@ class Term_Importer extends Importer { $this->remove_import_method('url'); $this->set_default_options([ - 'delimiter' => ',' + 'delimiter' => ',', + 'new_taxonomy' => '' ]); } @@ -57,8 +63,8 @@ class Term_Importer extends Importer { -