| @@ -55,52 +55,52 @@ | ||
| 55 | 55 | |
| 56 | 56 | public function register() |
| 57 | 57 | { |
| 58 | 58 | return [ |
| 59 | - $this->register_group('Term', 'term', [ | |
| 60 | - $this->register_field('ID', 'term_id', [ | |
| 61 | - 'tooltip' => __('ID is only used to reference existing records', 'importwp') | |
| 59 | + $this->register_group(__('Term', 'jc-importer'), 'term', [ | |
| 60 | + $this->register_field(__('ID', 'jc-importer'), 'term_id', [ | |
| 61 | + 'tooltip' => __('ID is only used to reference existing records', 'jc-importer') | |
| 62 | 62 | ]), |
| 63 | - $this->register_core_field('Name', 'name', [ | |
| 64 | - 'tooltip' => __('The term name', 'importwp') | |
| 63 | + $this->register_core_field(__('Name', 'jc-importer'), 'name', [ | |
| 64 | + 'tooltip' => __('The term name', 'jc-importer') | |
| 65 | 65 | ]), |
| 66 | - $this->register_field('Description', 'description', [ | |
| 67 | - 'tooltip' => __('The term description', 'importwp') | |
| 66 | + $this->register_field(__('Description', 'jc-importer'), 'description', [ | |
| 67 | + 'tooltip' => __('The term description', 'jc-importer') | |
| 68 | 68 | ]), |
| 69 | - $this->register_field('Slug', 'slug', [ | |
| 70 | - 'tooltip' => __('The term slug to use', 'importwp') | |
| 69 | + $this->register_field(__('Slug', 'jc-importer'), 'slug', [ | |
| 70 | + 'tooltip' => __('The term slug to use', 'jc-importer') | |
| 71 | 71 | ]), |
| 72 | - $this->register_group('Parent Settings', '_parent', [ | |
| 73 | - $this->register_field('Parent', 'parent', [ | |
| 72 | + $this->register_group(__('Parent Settings', 'jc-importer'), '_parent', [ | |
| 73 | + $this->register_field(__('Parent', 'jc-importer'), 'parent', [ | |
| 74 | 74 | 'default' => '', |
| 75 | 75 | 'options' => 'callback', |
| 76 | - 'tooltip' => __('The id of the parent term', 'importwp') | |
| 76 | + 'tooltip' => __('The id of the parent term', 'jc-importer') | |
| 77 | 77 | ]), |
| 78 | - $this->register_field('Parent Field Type', '_parent_type', [ | |
| 78 | + $this->register_field(__('Parent Field Type', 'jc-importer'), '_parent_type', [ | |
| 79 | 79 | 'default' => 'id', |
| 80 | 80 | 'options' => [ |
| 81 | - ['value' => 'id', 'label' => 'ID'], | |
| 82 | - ['value' => 'slug', 'label' => 'Slug'], | |
| 83 | - ['value' => 'name', 'label' => 'Name'], | |
| 84 | - ['value' => 'column', 'label' => 'Reference Column'], | |
| 85 | - ['value' => 'custom_field', 'label' => 'Custom Field'], | |
| 81 | + ['value' => 'id', 'label' => __('ID', 'jc-importer')], | |
| 82 | + ['value' => 'slug', 'label' => __('Slug', 'jc-importer')], | |
| 83 | + ['value' => 'name', 'label' => __('Name', 'jc-importer')], | |
| 84 | + ['value' => 'column', 'label' => __('Reference Column', 'jc-importer')], | |
| 85 | + ['value' => 'custom_field', 'label' => __('Custom Field', 'jc-importer')], | |
| 86 | 86 | ], |
| 87 | 87 | 'type' => 'select', |
| 88 | - 'tooltip' => __('Select how the parent field should be handled', 'importwp') | |
| 88 | + 'tooltip' => __('Select how the parent field should be handled', 'jc-importer') | |
| 89 | 89 | ]), |
| 90 | - $this->register_field('Parent Reference Column', '_parent_ref', [ | |
| 90 | + $this->register_field(__('Parent Reference Column', 'jc-importer'), '_parent_ref', [ | |
| 91 | 91 | 'condition' => ['_parent_type', '==', 'column'], |
| 92 | - 'tooltip' => __('Select the column/node that the parent field is referencing', 'importwp') | |
| 92 | + 'tooltip' => __('Select the column/node that the parent field is referencing', 'jc-importer') | |
| 93 | 93 | ]), |
| 94 | - $this->register_field('Custom Field Key', '_custom_field', [ | |
| 94 | + $this->register_field(__('Custom Field Key', 'jc-importer'), '_custom_field', [ | |
| 95 | 95 | 'condition' => ['_parent_type', '==', 'custom_field'], |
| 96 | - 'tooltip' => __('Enter the name of the custom field.', 'importwp') | |
| 96 | + 'tooltip' => __('Enter the name of the custom field.', 'jc-importer') | |
| 97 | 97 | ]) |
| 98 | 98 | ]), |
| 99 | - $this->register_field('Alias of', 'alias_of', [ | |
| 100 | - 'tooltip' => __('Slug of the term to make this term an alias of', 'importwp') | |
| 99 | + $this->register_field(__('Alias of', 'jc-importer'), 'alias_of', [ | |
| 100 | + 'tooltip' => __('Slug of the term to make this term an alias of', 'jc-importer') | |
| 101 | 101 | ]), |
| 102 | - ]) | |
| 102 | + ], ['link' => 'https://www.importwp.com/docs/wordpress-taxonomy-importer-template/']) | |
| 103 | 103 | ]; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | 106 | public function register_settings() |
| @@ -308,14 +308,14 @@ | ||
| 308 | 308 | if (!isset($parent['map'])) { |
| 309 | 309 | $parent['map'] = []; |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | - $parent['map'][$matches[1]] = sprintf('{%d}', $index); | |
| 312 | + $parent['map'][$matches[1]] = sprintf('{%s}', $index); | |
| 313 | 313 | } elseif (isset($this->field_map[$field])) { |
| 314 | 314 | |
| 315 | 315 | // Handle core fields |
| 316 | 316 | $field_key = $this->field_map[$field]; |
| 317 | - $map[$field_key] = sprintf('{%d}', $index); | |
| 317 | + $map[$field_key] = sprintf('{%s}', $index); | |
| 318 | 318 | |
| 319 | 319 | if (in_array($field, $this->optional_fields)) { |
| 320 | 320 | $enabled[] = $field_key; |
| 321 | 321 | } |
| @@ -354,6 +354,32 @@ | ||
| 354 | 354 | return [ |
| 355 | 355 | 'map' => $map, |
| 356 | 356 | 'enabled' => $enabled |
| 357 | 357 | ]; |
| 358 | + } | |
| 359 | + | |
| 360 | + public function get_permission_fields($importer_model) | |
| 361 | + { | |
| 362 | + $permission_fields = parent::get_permission_fields($importer_model); | |
| 363 | + | |
| 364 | + $permission_fields['core'] = [ | |
| 365 | + 'term_id' => __('ID', 'jc-importer'), | |
| 366 | + 'name' => __('Name', 'jc-importer'), | |
| 367 | + 'description' => __('Description', 'jc-importer'), | |
| 368 | + 'slug' => __('Slug', 'jc-importer'), | |
| 369 | + 'alias_of' => __('Alias Of', 'jc-importer'), | |
| 370 | + 'parent' => __('Parent', 'jc-importer'), | |
| 371 | + ]; | |
| 372 | + | |
| 373 | + return $permission_fields; | |
| 374 | + } | |
| 375 | + | |
| 376 | + public function get_unique_identifier_options($importer_model, $unique_fields = []) | |
| 377 | + { | |
| 378 | + $output = parent::get_unique_identifier_options($importer_model, $unique_fields); | |
| 379 | + | |
| 380 | + return array_merge( | |
| 381 | + $output, | |
| 382 | + $this->get_unique_identifier_options_from_map($importer_model, $unique_fields, $this->field_map, $this->optional_fields) | |
| 383 | + ); | |
| 358 | 384 | } |
| 359 | 385 | } |