PluginProbe
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms / 3.40.0
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms v3.40.0
3.54.0 3.53.0 3.52.0 3.51.0 3.50.0 3.45.0 3.38.0 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.40.0 3.40.1 3.41.0 3.42.0 3.43.0 3.44.0 3.5.0 3.5.1 3.5.2 3.5.3 3.6.0 3.6.1 All 178 releases
simple-tags / inc / taxonomies.php

taxonomies.php in Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms 3.40.0, at inc/taxonomies.php

1,749 lines 115.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class SimpleTags_Admin_Taxonomies
4 {
5
6 const MENU_SLUG = 'st_options';
7
8 // class instance
9 static $instance;
10
11 // WP_List_Table object
12 public $terms_table;
13
14 /**
15 * Constructor
16 *
17 * @return void
18 * @author Olatechpro
19 */
20 public function __construct()
21 {
22
23 add_filter('set-screen-option', [__CLASS__, 'set_screen'], 10, 3);
24 // Admin menu
25 add_action('admin_menu', [$this, 'admin_menu']);
26
27 // Javascript
28 add_action('admin_enqueue_scripts', [__CLASS__, 'admin_enqueue_scripts'], 11);
29
30 add_action('wp_ajax_taxopress_select2_term_filter', [$this, 'handle_taxopress_select2_filter']);
31
32 }
33
34 /**
35 * Init somes JS and CSS need for this feature
36 *
37 * @return void
38 * @author Olatechpro
39 */
40 public static function admin_enqueue_scripts()
41 {
42 wp_register_script('st-taxonomies', STAGS_URL . '/assets/js/taxonomies.js',
43 ['jquery', 'jquery-ui-dialog', 'postbox'], STAGS_VERSION);
44 wp_register_style('st-taxonomies-css', STAGS_URL . '/assets/css/taxonomies.css', ['wp-jquery-ui-dialog'],
45 STAGS_VERSION, 'all');
46
47 // add JS for manage click tags
48 if (isset($_GET['page']) && $_GET['page'] == 'st_taxonomies') {
49 wp_enqueue_script('st-taxonomies');
50 wp_enqueue_style('st-taxonomies-css');
51
52
53 $core = get_taxonomies(['_builtin' => true]);
54 $public = get_taxonomies([
55 '_builtin' => false,
56 'public' => true,
57 ]);
58 $private = get_taxonomies([
59 '_builtin' => false,
60 'public' => false,
61 ]);
62 $registered_taxonomies = array_merge($core, $public, $private);
63 wp_localize_script('st-taxonomies', 'taxopress_tax_data',
64 [
65 'confirm' => esc_html__('Are you sure you want to delete this? Deleting will NOT remove created content.',
66 'simple-tags'),
67 'no_associated_type' => esc_html__('Please select at least one post type.', 'simple-tags'),
68 'existing_taxonomies' => $registered_taxonomies,
69 'integer_error' => esc_html__('Taxonomy slug cannot be numbers only.', 'simple-tags'),
70 ]
71 );
72
73 }
74 }
75
76 public static function set_screen($status, $option, $value)
77 {
78 return $value;
79 }
80
81 /** Singleton instance */
82 public static function get_instance()
83 {
84 if (!isset(self::$instance)) {
85 self::$instance = new self();
86 }
87
88 return self::$instance;
89 }
90
91 /**
92 * Add WP admin menu for Tags
93 *
94 * @return void
95 * @author Olatechpro
96 */
97 public function admin_menu()
98 {
99 $hook = add_submenu_page(
100 self::MENU_SLUG,
101 esc_html__('Taxonomies', 'simple-tags'),
102 esc_html__('Taxonomies', 'simple-tags'),
103 'simple_tags',
104 'st_taxonomies',
105 [
106 $this,
107 'page_manage_taxonomies',
108 ]
109 );
110
111 if(taxopress_is_screen_main_page()){
112 add_action("load-$hook", [$this, 'screen_option']);
113 }
114 }
115
116 /**
117 * Screen options
118 */
119 public function screen_option()
120 {
121
122 $option = 'per_page';
123 $args = [
124 'label' => esc_html__('Number of items per page', 'simple-tags'),
125 'default' => 20,
126 'option' => 'st_taxonomies_per_page'
127 ];
128
129 add_screen_option($option, $args);
130
131 $this->terms_table = new Taxonomy_List();
132 }
133
134 /**
135 * Method for build the page HTML manage tags
136 *
137 * @return void
138 * @author Olatechpro
139 */
140 public function page_manage_taxonomies()
141 {
142 // Default order
143 if (!isset($_GET['order'])) {
144 $_GET['order'] = 'name-asc';
145 }
146
147 settings_errors(__CLASS__);
148
149 if (!isset($_GET['add'])) {
150 //all tax
151 ?>
152 <div class="wrap st_wrap st-manage-taxonomies-page">
153
154 <div id="">
155 <h1 class="wp-heading-inline"><?php _e('Taxonomies', 'simple-tags'); ?></h1>
156 <a href="<?php echo esc_url(admin_url('admin.php?page=st_taxonomies&add=taxonomy')); ?>"
157 class="page-title-action"><?php esc_html_e('Add New', 'simple-tags'); ?></a>
158
159 <div class="taxopress-description"><?php esc_html_e('This feature allows you to create new taxonomies and edit all the settings for each taxonomy.', 'simple-tags'); ?></div>
160
161
162 <?php
163 if (isset($_REQUEST['s']) && $search = sanitize_text_field(wp_unslash($_REQUEST['s']))) {
164 /* translators: %s: search keywords */
165 printf(' <span class="subtitle-text">' . esc_html__('Search results for &#8220;%s&#8221;',
166 'simple-tags') . '</span>', esc_html($search));
167 }
168 ?>
169 <?php
170
171 //the terms table instance
172 $this->terms_table->prepare_items();
173 ?>
174
175
176 <hr class="wp-header-end">
177 <div id="ajax-response"></div>
178 <form class="search-form wp-clearfix st-taxonomies-search-form" method="get">
179 <?php $this->terms_table->search_box(__('Search Taxonomies', 'simple-tags'), 'term'); ?>
180 </form>
181 <div class="clear"></div>
182
183 <div id="col-container" class="wp-clearfix">
184
185 <div class="col-wrap">
186 <?php
187 $selected_option = 'public';
188 if ( isset($_GET['taxonomy_type']) && $_GET['taxonomy_type'] === 'all' ) {
189 $selected_option = 'all';
190 }elseif ( isset($_GET['taxonomy_type']) && $_GET['taxonomy_type'] === 'private' ) {
191 $selected_option = 'private';
192 }
193 ?>
194 <div class="taxopress-taxonomy-type-wrap">
195 <select name="taxopress-taxonomy-type" class="taxopress-taxonomy-type">
196 <option value="all" <?php echo ($selected_option === 'all' ? 'selected="selected"' : ''); ?>><?php echo esc_html__('All Taxonomies', 'simple-tags'); ?></option>
197 <option value="public" <?php echo ($selected_option === 'public' ? 'selected="selected"' : ''); ?>><?php echo esc_html__('Public Taxonomies', 'simple-tags'); ?></option>
198 <option value="private" <?php echo ($selected_option === 'private' ? 'selected="selected"' : ''); ?>><?php echo esc_html__('Private Taxonomies', 'simple-tags'); ?></option>
199 </select>
200 </div>
201 <form action="<?php echo esc_url(add_query_arg('', '')); ?>" method="post">
202 <?php $this->terms_table->display(); //Display the table ?>
203 </form>
204 <div class="form-wrap edit-term-notes">
205 <p><?php esc_html__('Description here.', 'simple-tags') ?></p>
206 </div>
207 </div>
208
209
210 </div>
211
212
213 </div>
214 <?php } else {
215 if ($_GET['add'] == 'taxonomy') {
216 //add/edit taxonomy
217 $this->taxopress_manage_taxonomies();
218 echo '<div>';
219 }
220 } ?>
221
222
223 <?php SimpleTags_Admin::printAdminFooter(); ?>
224 </div>
225 <?php
226 do_action('simpletags-taxonomies', SimpleTags_Admin::$taxonomy);
227 }
228
229 /**
230 * Select2 Search taxonomy terms query
231 */
232 public function handle_taxopress_select2_filter() {
233 $search_term = isset($_GET['s']) ? sanitize_text_field($_GET['s']) : '';
234 $taxonomy = isset($_GET['taxonomy']) ? sanitize_text_field($_GET['taxonomy']) : 'category';
235 $nonce = isset($_GET['nonce']) ? sanitize_text_field($_REQUEST['nonce']) : '';
236
237 if (empty($nonce) || !wp_verify_nonce($nonce, 'st-admin-js')) {
238 wp_send_json_error(array('message' => esc_html__('Invalid nonce. Request is not authorized.', 'simple-tags')));
239 wp_die();
240 }
241
242 $args = array(
243 'taxonomy' => $taxonomy,
244 'hide_empty' => false,
245 'number' => 20,
246 'search' => $search_term,
247 'orderby' => 'name',
248 'order' => 'ASC',
249 );
250
251 $terms = get_terms($args);
252
253 $results = [];
254 foreach ($terms as $term) {
255 $results[] = array(
256 'id' => $term->slug,
257 'text' => $term->name,
258 );
259 }
260
261 wp_send_json(array(
262 'items' => $results
263 ));
264
265 wp_die();
266 }
267
268
269
270 /**
271 * Create our settings page output.
272 *
273 * @internal
274 */
275 public function taxopress_manage_taxonomies()
276 {
277
278 $tab = (!empty($_GET) && !empty($_GET['action']) && 'edit' == $_GET['action']) ? 'edit' : 'new';
279 $tab_class = 'taxopress-' . $tab;
280 $current = null;
281
282 ?>
283
284 <div class="wrap <?php echo esc_attr($tab_class); ?>">
285
286 <?php
287 /**
288 * Fires right inside the wrap div for the taxonomy editor screen.
289 */
290 do_action('taxopress_inside_taxonomy_wrap');
291
292 /**
293 * Filters whether or not a taxonomy was deleted.
294 *
295 * @param bool $value Whether or not taxonomy deleted. Default false.
296 */
297 $taxonomy_deleted = apply_filters('taxopress_taxonomy_deleted', false);
298
299 /**
300 * Fires below the output for the tab menu on the taxonomy add/edit screen.
301 */
302 do_action('taxopress_below_taxonomy_tab_menu');
303
304 $external_edit = false;
305 $taxonomy_edit = false;
306 $core_edit = false;
307
308 if ('edit' === $tab) {
309
310 $taxonomies = taxopress_get_taxonomy_data();
311
312 $selected_taxonomy = taxopress_get_current_taxonomy($taxonomy_deleted);
313 $request_tax = sanitize_text_field($_GET['taxopress_taxonomy']);
314
315 if ($selected_taxonomy && array_key_exists($selected_taxonomy, $taxonomies)) {
316 $current = $taxonomies[$selected_taxonomy];
317 $taxonomy_edit = true;
318 } elseif (taxonomy_exists($request_tax)) {
319 //not out taxonomy
320 $external_taxonomy = get_taxonomies(['name' => $request_tax], 'objects');
321 if (isset($external_taxonomy) > 0) {
322 $current = taxopress_convert_external_taxonomy($external_taxonomy[$request_tax],
323 $request_tax);
324 $external_edit = true;
325 $taxonomy_edit = true;
326 }
327 }
328
329 if($request_tax === 'media_tag'){
330 $external_edit = false;
331 }
332 }
333
334 if($taxonomy_edit){
335 $wordpress_core_tax = array_keys(get_taxonomies(['_builtin' => true]));
336 $wordpress_core_tax[] = 'post_tag';
337 $wordpress_core_tax[] = 'category';
338 if(in_array($current['name'], $wordpress_core_tax)){
339 $core_edit = true;
340 }
341 }
342
343 $ui = new taxopress_admin_ui();
344 ?>
345
346
347 <div class="wrap <?php echo esc_attr($tab_class); ?>">
348 <h1><?php echo esc_html__('Manage Taxonomy', 'simple-tags'); ?></h1>
349 <div class="wp-clearfix"></div>
350
351 <form method="post" action="<?php echo esc_url(taxopress_get_post_form_action($ui)); ?>">
352
353 <?php
354 if ($external_edit) {
355 echo '<input type="hidden" name="taxonomy_external_edit" aria-current="false" class="taxonomy_external_edit" value="1" />';
356 }
357 ?>
358
359
360 <div class="taxonomiesui">
361
362
363 <div class="postbox-container">
364 <div id="poststuff">
365 <div class="taxopress-section postbox">
366 <div class="postbox-header">
367 <h2 class="hndle ui-sortable-handle">
368 <?php
369 if ($taxonomy_edit) {
370 echo esc_html__('Edit Taxonomy', 'simple-tags');
371 } else {
372 echo esc_html__('Add new Taxonomy', 'simple-tags');
373 }
374 ?>
375 </h2>
376 </div>
377 <div class="inside">
378 <div class="main">
379
380 <ul class="st-taxonomy-tab">
381 <li aria-current="true" class="taxonomy_general_tab active" data-content="taxonomy_general">
382 <a href="#taxonomy_general"><span><?php esc_html_e('General',
383 'simple-tags'); ?></span></a>
384 </li>
385
386 <li aria-current="false" class="taxonomy_posttypes_tab" data-content="taxonomy_posttypes">
387 <a href="#taxonomy_posttypes"><span><?php esc_html_e('Post Types',
388 'simple-tags'); ?></span></a>
389 </li>
390
391 <li aria-current="false" class="taxonomy_permalinks_tab" data-content="taxonomy_permalinks">
392 <a href="#taxonomy_permalinks"><span><?php esc_html_e('Permalinks',
393 'simple-tags'); ?></span></a>
394 </li>
395
396 <li aria-current="false" class="taxonomy_menus_tab" data-content="taxonomy_menus">
397 <a href="#taxonomy_menus"><span><?php esc_html_e('Admin Area',
398 'simple-tags'); ?></span></a>
399 </li>
400
401 <li aria-current="false" class="taxonomy_labels_tab" data-content="taxonomy_labels">
402 <a href="#taxonomy_labels"><span><?php esc_html_e('Other Labels',
403 'simple-tags'); ?></span></a>
404 </li>
405
406 <li aria-current="false" class="taxonomy_restapi_tab" data-content="taxonomy_restapi">
407 <a href="#taxonomy_restapi"><span><?php esc_html_e('REST API',
408 'simple-tags'); ?></span></a>
409 </li>
410
411 <li aria-current="false" class="taxonomy_advanced_tab" data-content="taxonomy_advanced">
412 <a href="#taxonomy_advanced"><span><?php esc_html_e('Advanced',
413 'simple-tags'); ?></span></a>
414 </li>
415
416 <li aria-current="false" class="taxonomy_order_tab" data-content="taxonomy_order">
417 <a href="#taxonomy_order"><span><?php esc_html_e('Order',
418 'simple-tags'); ?></span></a>
419 </li>
420
421 <?php if( $taxonomy_edit && !$external_edit ){ ?>
422 <li aria-current="false" class="taxonomy_slug_tab" data-content="taxonomy_slug">
423 <a href="#taxonomy_slug"><span><?php esc_html_e('Slug',
424 'simple-tags'); ?></span></a>
425 </li>
426 <?php } ?>
427
428 <?php if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?>
429 <li aria-current="false" class="taxonomy_delete_tab" data-content="taxonomy_delete">
430 <a href="#taxonomy_delete"><span><?php esc_html_e('Deactivate or Delete',
431 'simple-tags'); ?></span></a>
432 </li>
433 <?php } ?>
434 </ul>
435
436
437 <div class="st-taxonomy-content">
438
439
440 <table class="form-table taxopress-table taxonomy_general">
441 <?php
442 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
443 echo $ui->get_tr_start();
444
445 if(!$taxonomy_edit){
446 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
447 echo $ui->get_th_start();
448 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
449 echo $ui->get_label('name', esc_html__('Taxonomy Slug', 'simple-tags')) . $ui->get_required_span();
450
451 if ('edit' === $tab) {
452 echo '<p id="slugchanged" class="hidemessage">' . esc_html__('Slug has changed',
453 'simple-tags') . '<span class="dashicons dashicons-warning"></span></p>';
454 }
455 echo '<p id="slugexists" class="hidemessage">' . esc_html__('Slug already exists',
456 'simple-tags') . '<span class="dashicons dashicons-warning"></span></p>';
457 echo '<p id="st-tags-slug-error-input" class="hidemessage">' . esc_html__('Special character not allowed in slug.', 'simple-tags') . '<span class="dashicons dashicons-warning"></span></p>';
458
459 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
460 echo $ui->get_th_end() . $ui->get_td_start();
461
462 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
463 echo $ui->get_text_input([
464 'namearray' => 'cpt_custom_tax',
465 'name' => 'name',
466 'textvalue' => isset($current['name']) ? esc_attr($current['name']) : '',
467 'maxlength' => '32',
468 'helptext' => esc_html__('The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and underscores.',
469 'simple-tags'),
470 'class' => 'tax-slug-input',
471 'required' => true,
472 'placeholder' => false,
473 'wrap' => false,
474 ]);
475
476 if ('edit' === $tab) {
477 echo '<p>';
478 esc_html_e('DO NOT EDIT the taxonomy slug unless also planning to migrate terms. Changing the slug registers a new taxonomy entry.',
479 'simple-tags');
480 echo '</p>';
481
482 echo '<div class="taxopress-spacer">';
483 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
484 echo $ui->get_check_input([
485 'checkvalue' => 'update_taxonomy',
486 'checked' => 'false',
487 'name' => 'update_taxonomy',
488 'namearray' => 'update_taxonomy',
489 'labeltext' => esc_html__('Migrate terms to newly renamed taxonomy?',
490 'simple-tags'),
491 'helptext' => '',
492 'default' => false,
493 'wrap' => false,
494 ]);
495 echo '</div>';
496 }
497
498 }
499
500
501
502 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
503 echo $ui->get_text_input([
504 'namearray' => 'cpt_custom_tax',
505 'name' => 'label',
506 'textvalue' => isset($current['label']) ? esc_attr($current['label']) : '',
507 'aftertext' => esc_html__('(e.g. Jobs)', 'simple-tags'),
508 'labeltext' => esc_html__('Plural Label', 'simple-tags'),
509 'maxlength' => '100',
510 'helptext' => '',
511 'required' => true,
512 ]);
513
514 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
515 echo $ui->get_text_input([
516 'namearray' => 'cpt_custom_tax',
517 'name' => 'singular_label',
518 'textvalue' => isset($current['singular_label']) ? esc_attr($current['singular_label']) : '',
519 'aftertext' => esc_html__('(e.g. Job)', 'simple-tags'),
520 'labeltext' => esc_html__('Singular Label', 'simple-tags'),
521 'maxlength' => '100',
522 'helptext' => '',
523 'required' => true,
524 ]);
525
526
527
528 $select = [
529 'options' => [
530 [
531 'attr' => '0',
532 'text' => esc_attr__('False', 'simple-tags'),
533 'default' => 'true',
534 ],
535 [
536 'attr' => '1',
537 'text' => esc_attr__('True', 'simple-tags'),
538 ],
539 ],
540 ];
541 $selected = isset($current) ? taxopress_disp_boolean($current['hierarchical']) : '';
542 $select['selected'] = !empty($selected) ? $current['hierarchical'] : '';
543 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
544 echo $ui->get_select_checkbox_input([
545 'namearray' => 'cpt_custom_tax',
546 'name' => 'hierarchical',
547 'labeltext' => esc_html__('Parent-Child Relationships', 'simple-tags'),
548 'aftertext' => esc_html__('Can terms in this taxonomy be organized into hierarchical relationships?',
549 'simple-tags'),
550 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
551 ]);
552
553
554
555 if (isset($current['description'])) {
556 $current['description'] = stripslashes_deep($current['description']);
557 }
558 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
559 echo $ui->get_textarea_input([
560 'namearray' => 'cpt_custom_tax',
561 'name' => 'description',
562 'rows' => '4',
563 'cols' => '40',
564 'textvalue' => isset($current['description']) ? esc_textarea($current['description']) : '',
565 'labeltext' => esc_html__('Description', 'simple-tags'),
566 'helptext' => esc_attr__('Describe what your taxonomy is used for.',
567 'simple-tags'),
568 ]);
569
570 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
571 echo $ui->get_text_input([
572 'namearray' => 'cpt_custom_tax',
573 'name' => 'default_term',
574 'textvalue' => isset($current['default_term']) ? esc_attr($current['default_term']) : '',
575 'labeltext' => esc_html__('Default Terms', 'simple-tags'),
576 'helptext' => esc_html__('Set the default terms for this taxonomy. These will be automatically added to all new posts. Enter the term names or slugs. Separate multiple terms with by comma.',
577 'simple-tags'),
578 ]);
579
580
581 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
582 echo $ui->get_td_end() . $ui->get_tr_end();
583 ?>
584 </table>
585
586
587 <table class="form-table taxopress-table taxonomy_posttypes"
588 style="display:none;">
589 <?php
590
591 /**
592 * Filters the arguments for post types to list for taxonomy association.
593 *
594 *
595 * @param array $value Array of default arguments.
596 */
597 $args = apply_filters('taxopress_attach_post_types_to_taxonomy',
598 ['public' => true]);
599
600 // If they don't return an array, fall back to the original default. Don't need to check for empty, because empty array is default for $args param in get_post_types anyway.
601 if (!is_array($args)) {
602 $args = ['public' => true];
603 }
604 $output = 'objects'; // Or objects.
605
606 /**
607 * Filters the results returned to display for available post types for taxonomy.
608 *
609 * @param array $value Array of post type objects.
610 * @param array $args Array of arguments for the post type query.
611 * @param string $output The output type we want for the results.
612 */
613 $post_types = apply_filters('taxopress_get_post_types_for_taxonomies',
614 get_post_types($args, $output), $args, $output);
615
616 foreach ($post_types as $post_type) {
617 $core_label = in_array($post_type->name, [
618 'post',
619 'page',
620 'attachment',
621 ], true) ? '' : '';
622
623
624 echo '<tr valign="top"><th scope="row"><label for="'. esc_attr($post_type->name) .'">'. esc_html($post_type->label) .'</label></th><td>';
625
626 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
627 echo $ui->get_check_input([
628 'checkvalue' => esc_attr($post_type->name),
629 'checked' => (!empty($current['object_types']) && is_array($current['object_types']) && in_array($post_type->name,
630 $current['object_types'], true)) ? 'true' : 'false',
631 'name' => esc_attr($post_type->name),
632 'namearray' => 'cpt_post_types',
633 'textvalue' => esc_attr($post_type->name),
634 'labeltext' => "",
635 'wrap' => false,
636 ]);
637
638 echo '</td></tr>';
639
640
641 }
642
643
644 if($taxonomy_edit){
645
646 $select = [
647 'options' => [
648 [
649 'attr' => '0',
650 'text' => esc_attr__('False', 'simple-tags'),
651 'default' => 'true',
652 ],
653 [
654 'attr' => '1',
655 'text' => esc_attr__('True', 'simple-tags'),
656 ],
657 ],
658 ];
659
660 }else{
661 $select = [
662 'options' => [
663 [
664 'attr' => '0',
665 'text' => esc_attr__('False', 'simple-tags'),
666 ],
667 [
668 'attr' => '1',
669 'text' => esc_attr__('True', 'simple-tags'),
670 'default' => 'true',
671 ],
672 ],
673 ];
674 }
675 $selected = isset($current) && isset($current['include_in_result']) ? taxopress_disp_boolean($current['include_in_result']) : '';
676 $select['selected'] = !empty($selected) ? $current['include_in_result'] : '';
677
678 echo '<td><hr /></td>';
679
680 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
681 echo $ui->get_select_checkbox_input([
682 'namearray' => 'cpt_custom_tax',
683 'name' => 'include_in_result',
684 'labeltext' => esc_html__('Archive page result', 'simple-tags'),
685 'aftertext' => esc_html__('Normally, WordPress will only show one post type on taxonomy archive pages. Enable this feature to show content from all selected posts types.',
686 'simple-tags'),
687 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
688 ]);
689
690
691 ?>
692
693 </table>
694
695
696 <table class="form-table taxopress-table taxonomy_slug"
697 style="display:none;">
698 <?php
699
700
701 if($taxonomy_edit){
702
703 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
704 echo $ui->get_th_start();
705 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
706 echo $ui->get_label('name', esc_html__('Taxonomy Slug', 'simple-tags')) . $ui->get_required_span();
707
708 if ('edit' === $tab) {
709 echo '<p id="slugchanged" class="hidemessage">' . esc_html__('Slug has changed',
710 'simple-tags') . '<span class="dashicons dashicons-warning"></span></p>';
711 }
712 echo '<p id="slugexists" class="hidemessage">' . esc_html__('Slug already exists',
713 'simple-tags') . '<span class="dashicons dashicons-warning"></span></p>';
714
715 echo '<p id="st-tags-slug-error-input" class="hidemessage">' . esc_html__('Special character not allowed in slug.', 'simple-tags') . '<span class="dashicons dashicons-warning"></span></p>';
716
717 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
718 echo $ui->get_th_end() . $ui->get_td_start();
719
720 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
721 echo $ui->get_text_input([
722 'namearray' => 'cpt_custom_tax',
723 'name' => 'name',
724 'textvalue' => isset($current['name']) ? esc_attr($current['name']) : '',
725 'maxlength' => '32',
726 'helptext' => 'The “slug” is the URL-friendly version of the name. It is usually all lowercase and contains only letters, numbers, and underscores.',
727 'class' => 'tax-slug-input',
728 'required' => true,
729 'placeholder' => false,
730 'wrap' => false,
731 ]);
732
733 if ('edit' === $tab) {
734 echo '<p>';
735 esc_html_e('DO NOT EDIT the taxonomy slug unless also planning to migrate terms. Changing the slug registers a new taxonomy entry.',
736 'simple-tags');
737 echo '</p>';
738
739 echo '<div class="taxopress-spacer">';
740 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
741 echo $ui->get_check_input([
742 'checkvalue' => 'update_taxonomy',
743 'checked' => 'false',
744 'name' => 'update_taxonomy',
745 'namearray' => 'update_taxonomy',
746 'labeltext' => esc_html__('Migrate terms to newly renamed taxonomy?',
747 'simple-tags'),
748 'helptext' => '',
749 'default' => false,
750 'wrap' => false,
751 ]);
752 echo '</div>';
753 }
754
755 }
756
757 ?>
758
759 </table>
760
761
762 <table class="form-table taxopress-table taxonomy_permalinks"
763 style="display:none;">
764 <?php
765
766
767 $select = [
768 'options' => [
769 [
770 'attr' => '0',
771 'text' => esc_attr__('False', 'simple-tags'),
772 ],
773 [
774 'attr' => '1',
775 'text' => esc_attr__('True', 'simple-tags'),
776 'default' => 'true',
777 ],
778 ],
779 ];
780 $selected = isset($current) ? taxopress_disp_boolean($current['rewrite']) : '';
781 $select['selected'] = !empty($selected) ? $current['rewrite'] : '';
782 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
783 echo $ui->get_select_checkbox_input([
784 'namearray' => 'cpt_custom_tax',
785 'name' => 'rewrite',
786 'labeltext' => esc_html__('Rewrite', 'simple-tags'),
787 'aftertext' => esc_html__('WordPress can use a custom permalink for this taxonomy. It does not have to match the slug.',
788 'simple-tags'),
789 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
790 ]);
791
792 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
793 echo $ui->get_text_input([
794 'namearray' => 'cpt_custom_tax',
795 'name' => 'rewrite_slug',
796 'textvalue' => isset($current['rewrite_slug']) ? esc_attr($current['rewrite_slug']) : '',
797 'aftertext' => esc_attr__('(default: taxonomy name)', 'simple-tags'),
798 'labeltext' => esc_html__('Custom Rewrite Slug', 'simple-tags'),
799 'helptext' => esc_html__('Custom taxonomy rewrite slug.',
800 'simple-tags'),
801 ]);
802
803 $select = [
804 'options' => [
805 [
806 'attr' => '0',
807 'text' => esc_attr__('False', 'simple-tags'),
808 ],
809 [
810 'attr' => '1',
811 'text' => esc_attr__('True', 'simple-tags'),
812 'default' => 'true',
813 ],
814 ],
815 ];
816 $selected = isset($current) ? taxopress_disp_boolean($current['rewrite_withfront']) : '';
817 $select['selected'] = !empty($selected) ? $current['rewrite_withfront'] : '';
818 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
819 echo $ui->get_select_checkbox_input([
820 'namearray' => 'cpt_custom_tax',
821 'name' => 'rewrite_withfront',
822 'labeltext' => esc_html__('Rewrite With Front', 'simple-tags'),
823 'aftertext' => esc_html__('Should the permastruct be prepended with the front base.',
824 'simple-tags'),
825 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
826 ]);
827
828 $select = [
829 'options' => [
830 [
831 'attr' => '0',
832 'text' => esc_attr__('False', 'simple-tags'),
833 'default' => 'false',
834 ],
835 [
836 'attr' => '1',
837 'text' => esc_attr__('True', 'simple-tags'),
838 ],
839 ],
840 ];
841 $selected = isset($current) ? taxopress_disp_boolean($current['rewrite_hierarchical']) : '';
842 $select['selected'] = !empty($selected) ? $current['rewrite_hierarchical'] : '';
843 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
844 echo $ui->get_select_checkbox_input([
845 'namearray' => 'cpt_custom_tax',
846 'name' => 'rewrite_hierarchical',
847 'labeltext' => esc_html__('Rewrite Hierarchical', 'simple-tags'),
848 'aftertext' => esc_html__('Should the permastruct allow hierarchical urls.',
849 'simple-tags'),
850 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
851 ]);
852
853 ?>
854
855 </table>
856
857
858 <table class="form-table taxopress-table taxonomy_menus"
859 style="display:none;">
860 <?php
861
862
863 $select = [
864 'options' => [
865 [
866 'attr' => '0',
867 'text' => esc_attr__('False', 'simple-tags'),
868 ],
869 [
870 'attr' => '1',
871 'text' => esc_attr__('True', 'simple-tags'),
872 'default' => 'true',
873 ],
874 ],
875 ];
876 $selected = isset($current) ? taxopress_disp_boolean($current['show_ui']) : '';
877 $select['selected'] = !empty($selected) ? $current['show_ui'] : '';
878 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
879 echo $ui->get_select_checkbox_input([
880 'namearray' => 'cpt_custom_tax',
881 'name' => 'show_ui',
882 'labeltext' => esc_html__('Show user interface', 'simple-tags'),
883 'aftertext' => esc_html__('Should there be a visible interface in the WordPress admin area to manage these terms?', 'simple-tags'),
884 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
885 ]);
886
887 $select = [
888 'options' => [
889 [
890 'attr' => '0',
891 'text' => esc_attr__('False', 'simple-tags'),
892 ],
893 [
894 'attr' => '1',
895 'text' => esc_attr__('True', 'simple-tags'),
896 'default' => 'true',
897 ],
898 ],
899 ];
900 $selected = isset($current) ? taxopress_disp_boolean($current['show_in_menu']) : '';
901 $select['selected'] = !empty($selected) ? $current['show_in_menu'] : '';
902 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
903 echo $ui->get_select_checkbox_input([
904 'namearray' => 'cpt_custom_tax',
905 'name' => 'show_in_menu',
906 'labeltext' => esc_html__('Show in admin menus', 'simple-tags'),
907 'aftertext' => esc_html__('Should there be links to this taxonomy in the WordPress admin menus?', 'simple-tags'),
908 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
909 ]);
910
911 $select = [
912 'options' => [
913 [
914 'attr' => '0',
915 'text' => esc_attr__('False', 'simple-tags'),
916 ],
917 [
918 'attr' => '1',
919 'text' => esc_attr__('True', 'simple-tags'),
920 'default' => 'true',
921 ],
922 ],
923 ];
924 $selected = (isset($current) && !empty($current['show_in_nav_menus'])) ? taxopress_disp_boolean($current['show_in_nav_menus']) : '';
925 $select['selected'] = !empty($selected) ? $current['show_in_nav_menus'] : '';
926 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
927 echo $ui->get_select_checkbox_input([
928 'namearray' => 'cpt_custom_tax',
929 'name' => 'show_in_nav_menus',
930 'labeltext' => esc_html__('Show in frontend menus', 'simple-tags'),
931 'aftertext' => esc_html__('Should this taxonomy be available for the frontend “Menus” and “Navigation” options?', 'simple-tags'),
932 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
933 ]);
934
935
936 $select = [
937 'options' => [
938 [
939 'attr' => '0',
940 'text' => esc_attr__('False', 'simple-tags'),
941 'default' => 'true',
942 ],
943 [
944 'attr' => '1',
945 'text' => esc_attr__('True', 'simple-tags'),
946 ],
947 ],
948 ];
949 $selected = isset($current) ? taxopress_disp_boolean($current['show_admin_column']) : '';
950 $select['selected'] = !empty($selected) ? $current['show_admin_column'] : '';
951 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
952 echo $ui->get_select_checkbox_input([
953 'namearray' => 'cpt_custom_tax',
954 'name' => 'show_admin_column',
955 'labeltext' => esc_html__('Show admin column', 'simple-tags'),
956 'aftertext' => esc_html__('Should a column for this taxonomy appear on screens such as “Posts” and “Pages”?', 'simple-tags'),
957 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
958 ]);
959
960 $select = [
961 'options' => [
962 [
963 'attr' => '0',
964 'text' => esc_attr__('False', 'simple-tags'),
965 'default' => 'false',
966 ],
967 [
968 'attr' => '1',
969 'text' => esc_attr__('True', 'simple-tags'),
970 ],
971 ],
972 ];
973 $selected = (isset($current) && !empty($current['show_in_quick_edit'])) ? taxopress_disp_boolean($current['show_in_quick_edit']) : '';
974 $select['selected'] = !empty($selected) ? $current['show_in_quick_edit'] : '';
975 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
976 echo $ui->get_select_checkbox_input([
977 'namearray' => 'cpt_custom_tax',
978 'name' => 'show_in_quick_edit',
979 'labeltext' => esc_html__('Show in "Quick Edit" and "Bulk Edit"',
980 'simple-tags'),
981 'aftertext' => esc_html__('Should this taxonomy be available in editing tools on screens such as “Posts” and “Pages”?', 'simple-tags'),
982 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
983 ]);
984
985 $select = array(
986 'options' => array(
987 array(
988 'attr' => '0',
989 'text' => esc_attr__( 'False', 'simple-tags' ),
990 'default' => 'false',
991 ),
992 array(
993 'attr' => '1',
994 'text' => esc_attr__( 'True', 'simple-tags' ),
995 ),
996 ),
997 );
998 $selected = ( isset( $current ) && ! empty( $current['show_in_filter'] ) ) ? taxopress_disp_boolean( $current['show_in_filter'] ) : '';
999 $select['selected'] = ! empty( $selected ) ? $current['show_in_filter'] : '';
1000 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1001 echo $ui->get_select_checkbox_input(
1002 array(
1003 'namearray' => 'cpt_custom_tax',
1004 'name' => 'show_in_filter',
1005 'labeltext' => esc_html__(
1006 'Show in Filter',
1007 'simple-tags'
1008 ),
1009 'aftertext' => esc_html__('Should this taxonomy be available in filters on screens such as “Posts” and “Pages”?', 'simple-tags'),
1010 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1011 )
1012 );
1013
1014 ?>
1015
1016 </table>
1017
1018
1019 <table class="form-table taxopress-table taxonomy_labels"
1020 style="display:none;">
1021
1022 <?php
1023 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1024 echo $ui->get_text_input([
1025 'namearray' => 'cpt_tax_labels',
1026 'name' => 'menu_name',
1027 'textvalue' => isset($current['labels']['menu_name']) ? esc_attr($current['labels']['menu_name']) : '',
1028 'aftertext' => esc_attr__('(e.g. Jobs)', 'simple-tags'),
1029 'labeltext' => esc_html__('Menu Name', 'simple-tags'),
1030 'helptext' => esc_html__('Custom admin menu name for your taxonomy.',
1031 'simple-tags'),
1032 'maxlength' => '100',
1033 'data' => [
1034 'label' => 'item', // Not localizing because it's isolated.
1035 'plurality' => 'plural',
1036 ],
1037 ]);
1038
1039 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1040 echo $ui->get_text_input([
1041 'namearray' => 'cpt_tax_labels',
1042 'name' => 'all_items',
1043 'textvalue' => isset($current['labels']['all_items']) ? esc_attr($current['labels']['all_items']) : '',
1044 'aftertext' => esc_attr__('(e.g. All Jobs)', 'simple-tags'),
1045 'labeltext' => esc_html__('All Items', 'simple-tags'),
1046 'helptext' => esc_html__('Used as tab text when showing all terms for hierarchical taxonomy while editing post.',
1047 'simple-tags'),
1048 'data' => [
1049 /* translators: Used for autofill */
1050 'label' => sprintf(esc_attr__('All %s', 'simple-tags'),
1051 'item'),
1052 'plurality' => 'plural',
1053 ],
1054 ]);
1055
1056 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1057 echo $ui->get_text_input([
1058 'namearray' => 'cpt_tax_labels',
1059 'name' => 'edit_item',
1060 'textvalue' => isset($current['labels']['edit_item']) ? esc_attr($current['labels']['edit_item']) : '',
1061 'aftertext' => esc_attr__('(e.g. Edit Job)', 'simple-tags'),
1062 'labeltext' => esc_html__('Edit Item', 'simple-tags'),
1063 'helptext' => esc_html__('Used at the top of the term editor screen for an existing taxonomy term.',
1064 'simple-tags'),
1065 'data' => [
1066 /* translators: Used for autofill */
1067 'label' => sprintf(esc_attr__('Edit %s', 'simple-tags'),
1068 'item'),
1069 'plurality' => 'singular',
1070 ],
1071 ]);
1072
1073 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1074 echo $ui->get_text_input([
1075 'namearray' => 'cpt_tax_labels',
1076 'name' => 'view_item',
1077 'textvalue' => isset($current['labels']['view_item']) ? esc_attr($current['labels']['view_item']) : '',
1078 'aftertext' => esc_attr__('(e.g. View Job)', 'simple-tags'),
1079 'labeltext' => esc_html__('View Item', 'simple-tags'),
1080 'helptext' => esc_html__('Used in the admin bar when viewing editor screen for an existing taxonomy term.',
1081 'simple-tags'),
1082 'data' => [
1083 /* translators: Used for autofill */
1084 'label' => sprintf(esc_attr__('View %s', 'simple-tags'),
1085 'item'),
1086 'plurality' => 'singular',
1087 ],
1088 ]);
1089
1090 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1091 echo $ui->get_text_input([
1092 'namearray' => 'cpt_tax_labels',
1093 'name' => 'update_item',
1094 'textvalue' => isset($current['labels']['update_item']) ? esc_attr($current['labels']['update_item']) : '',
1095 'aftertext' => esc_attr__('(e.g. Update Job Name)', 'simple-tags'),
1096 'labeltext' => esc_html__('Update Item Name', 'simple-tags'),
1097 'helptext' => esc_html__('Custom taxonomy label. Used in the admin menu for displaying taxonomies.',
1098 'simple-tags'),
1099 'data' => [
1100 /* translators: Used for autofill */
1101 'label' => sprintf(esc_attr__('Update %s name',
1102 'simple-tags'),
1103 'item'),
1104 'plurality' => 'singular',
1105 ],
1106 ]);
1107
1108 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1109 echo $ui->get_text_input([
1110 'namearray' => 'cpt_tax_labels',
1111 'name' => 'add_new_item',
1112 'textvalue' => isset($current['labels']['add_new_item']) ? esc_attr($current['labels']['add_new_item']) : '',
1113 'aftertext' => esc_attr__('(e.g. Add New Job)', 'simple-tags'),
1114 'labeltext' => esc_html__('Add New Item', 'simple-tags'),
1115 'helptext' => esc_html__('Used at the top of the term editor screen and button text for a new taxonomy term.',
1116 'simple-tags'),
1117 'data' => [
1118 /* translators: Used for autofill */
1119 'label' => sprintf(esc_attr__('Add new %s', 'simple-tags'),
1120 'item'),
1121 'plurality' => 'singular',
1122 ],
1123 ]);
1124
1125 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1126 echo $ui->get_text_input([
1127 'namearray' => 'cpt_tax_labels',
1128 'name' => 'new_item_name',
1129 'textvalue' => isset($current['labels']['new_item_name']) ? esc_attr($current['labels']['new_item_name']) : '',
1130 'aftertext' => esc_attr__('(e.g. New Job Name)', 'simple-tags'),
1131 'labeltext' => esc_html__('New Item Name', 'simple-tags'),
1132 'helptext' => esc_html__('Custom taxonomy label. Used in the admin menu for displaying taxonomies.',
1133 'simple-tags'),
1134 'data' => [
1135 /* translators: Used for autofill */
1136 'label' => sprintf(esc_attr__('New %s name', 'simple-tags'),
1137 'item'),
1138 'plurality' => 'singular',
1139 ],
1140 ]);
1141
1142 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1143 echo $ui->get_text_input([
1144 'namearray' => 'cpt_tax_labels',
1145 'name' => 'parent_item',
1146 'textvalue' => isset($current['labels']['parent_item']) ? esc_attr($current['labels']['parent_item']) : '',
1147 'aftertext' => esc_attr__('(e.g. Parent Job)', 'simple-tags'),
1148 'labeltext' => esc_html__('Parent Item', 'simple-tags'),
1149 'helptext' => esc_html__('Custom taxonomy label. Used in the admin menu for displaying taxonomies.',
1150 'simple-tags'),
1151 'data' => [
1152 /* translators: Used for autofill */
1153 'label' => sprintf(esc_attr__('Parent %s', 'simple-tags'),
1154 'item'),
1155 'plurality' => 'singular',
1156 ],
1157 ]);
1158
1159 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1160 echo $ui->get_text_input([
1161 'namearray' => 'cpt_tax_labels',
1162 'name' => 'parent_item_colon',
1163 'textvalue' => isset($current['labels']['parent_item_colon']) ? esc_attr($current['labels']['parent_item_colon']) : '',
1164 'aftertext' => esc_attr__('(e.g. Parent Job:)', 'simple-tags'),
1165 'labeltext' => esc_html__('Parent Item Colon', 'simple-tags'),
1166 'helptext' => esc_html__('Custom taxonomy label. Used in the admin menu for displaying taxonomies.',
1167 'simple-tags'),
1168 'data' => [
1169 /* translators: Used for autofill */
1170 'label' => sprintf(esc_attr__('Parent %s:', 'simple-tags'),
1171 'item'),
1172 'plurality' => 'singular',
1173 ],
1174 ]);
1175
1176 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1177 echo $ui->get_text_input([
1178 'namearray' => 'cpt_tax_labels',
1179 'name' => 'search_items',
1180 'textvalue' => isset($current['labels']['search_items']) ? esc_attr($current['labels']['search_items']) : '',
1181 'aftertext' => esc_attr__('(e.g. Search Jobs)', 'simple-tags'),
1182 'labeltext' => esc_html__('Search Items', 'simple-tags'),
1183 'helptext' => esc_html__('Custom taxonomy label. Used in the admin menu for displaying taxonomies.',
1184 'simple-tags'),
1185 'data' => [
1186 /* translators: Used for autofill */
1187 'label' => sprintf(esc_attr__('Search %s', 'simple-tags'),
1188 'item'),
1189 'plurality' => 'plural',
1190 ],
1191 ]);
1192
1193 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1194 echo $ui->get_text_input([
1195 'namearray' => 'cpt_tax_labels',
1196 'name' => 'popular_items',
1197 'textvalue' => isset($current['labels']['popular_items']) ? esc_attr($current['labels']['popular_items']) : null,
1198 'aftertext' => esc_attr__('(e.g. Popular Jobs)', 'simple-tags'),
1199 'labeltext' => esc_html__('Popular Items', 'simple-tags'),
1200 'helptext' => esc_html__('Custom taxonomy label. Used in the admin menu for displaying taxonomies.',
1201 'simple-tags'),
1202 'data' => [
1203 /* translators: Used for autofill */
1204 'label' => sprintf(esc_attr__('Popular %s', 'simple-tags'),
1205 'item'),
1206 'plurality' => 'plural',
1207 ],
1208 ]);
1209
1210 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1211 echo $ui->get_text_input([
1212 'namearray' => 'cpt_tax_labels',
1213 'name' => 'separate_items_with_commas',
1214 'textvalue' => isset($current['labels']['separate_items_with_commas']) ? esc_attr($current['labels']['separate_items_with_commas']) : null,
1215 'aftertext' => esc_attr__('(e.g. Separate Jobs with commas)',
1216 'simple-tags'),
1217 'labeltext' => esc_html__('Separate Items with Commas',
1218 'simple-tags'),
1219 'helptext' => esc_html__('Custom taxonomy label. Used in the admin menu for displaying taxonomies.',
1220 'simple-tags'),
1221 'data' => [
1222 /* translators: Used for autofill */
1223 'label' => sprintf(esc_attr__('Separate %s with commas',
1224 'simple-tags'), 'item'),
1225 'plurality' => 'plural',
1226 ],
1227 ]);
1228
1229 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1230 echo $ui->get_text_input([
1231 'namearray' => 'cpt_tax_labels',
1232 'name' => 'add_or_remove_items',
1233 'textvalue' => isset($current['labels']['add_or_remove_items']) ? esc_attr($current['labels']['add_or_remove_items']) : null,
1234 'aftertext' => esc_attr__('(e.g. Add or remove Jobs)',
1235 'simple-tags'),
1236 'labeltext' => esc_html__('Add or Remove Items', 'simple-tags'),
1237 'helptext' => esc_html__('Custom taxonomy label. Used in the admin menu for displaying taxonomies.',
1238 'simple-tags'),
1239 'data' => [
1240 /* translators: Used for autofill */
1241 'label' => sprintf(esc_attr__('Add or remove %s',
1242 'simple-tags'),
1243 'item'),
1244 'plurality' => 'plural',
1245 ],
1246 ]);
1247
1248 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1249 echo $ui->get_text_input([
1250 'namearray' => 'cpt_tax_labels',
1251 'name' => 'choose_from_most_used',
1252 'textvalue' => isset($current['labels']['choose_from_most_used']) ? esc_attr($current['labels']['choose_from_most_used']) : null,
1253 'aftertext' => esc_attr__('(e.g. Choose from the most used Jobs)',
1254 'simple-tags'),
1255 'labeltext' => esc_html__('Choose From Most Used', 'simple-tags'),
1256 'helptext' => esc_html__('Custom taxonomy label. Used in the admin menu for displaying taxonomies.',
1257 'simple-tags'),
1258 'data' => [
1259 /* translators: Used for autofill */
1260 'label' => sprintf(esc_attr__('Choose from the most used %s',
1261 'simple-tags'), 'item'),
1262 'plurality' => 'plural',
1263 ],
1264 ]);
1265
1266 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1267 echo $ui->get_text_input([
1268 'namearray' => 'cpt_tax_labels',
1269 'name' => 'no_terms',
1270 'textvalue' => isset($current['labels']['no_terms']) ? esc_attr($current['labels']['no_terms']) : null,
1271 'aftertext' => esc_html__('(e.g. No jobs)', 'simple-tags'),
1272 'labeltext' => esc_html__('No terms', 'simple-tags'),
1273 'helptext' => esc_attr__('Used when indicating that there are no terms in the given taxonomy associated with an object.',
1274 'simple-tags'),
1275 'data' => [
1276 /* translators: Used for autofill */
1277 'label' => sprintf(esc_attr__('No %s', 'simple-tags'),
1278 'item'),
1279 'plurality' => 'plural',
1280 ],
1281 ]);
1282
1283 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1284 echo $ui->get_text_input([
1285 'namearray' => 'cpt_tax_labels',
1286 'name' => 'items_list_navigation',
1287 'textvalue' => isset($current['labels']['items_list_navigation']) ? esc_attr($current['labels']['items_list_navigation']) : null,
1288 'aftertext' => esc_html__('(e.g. Jobs list navigation)',
1289 'simple-tags'),
1290 'labeltext' => esc_html__('Items List Navigation', 'simple-tags'),
1291 'helptext' => esc_attr__('Screen reader text for the pagination heading on the term listing screen.',
1292 'simple-tags'),
1293 'data' => [
1294 /* translators: Used for autofill */
1295 'label' => sprintf(esc_attr__('%s list navigation',
1296 'simple-tags'),
1297 'item'),
1298 'plurality' => 'plural',
1299 ],
1300 ]);
1301
1302 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1303 echo $ui->get_text_input([
1304 'namearray' => 'cpt_tax_labels',
1305 'name' => 'items_list',
1306 'textvalue' => isset($current['labels']['items_list']) ? esc_attr($current['labels']['items_list']) : null,
1307 'aftertext' => esc_html__('(e.g. Jobs list)', 'simple-tags'),
1308 'labeltext' => esc_html__('Items List', 'simple-tags'),
1309 'helptext' => esc_attr__('Screen reader text for the items list heading on the term listing screen.',
1310 'simple-tags'),
1311 'data' => [
1312 /* translators: Used for autofill */
1313 'label' => sprintf(esc_attr__('%s list', 'simple-tags'),
1314 'item'),
1315 'plurality' => 'plural',
1316 ],
1317 ]);
1318
1319 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1320 echo $ui->get_text_input([
1321 'namearray' => 'cpt_tax_labels',
1322 'name' => 'not_found',
1323 'textvalue' => isset($current['labels']['not_found']) ? esc_attr($current['labels']['not_found']) : null,
1324 'aftertext' => esc_html__('(e.g. No jobs found)', 'simple-tags'),
1325 'labeltext' => esc_html__('Not Found', 'simple-tags'),
1326 'helptext' => esc_attr__('The text displayed via clicking ‘Choose from the most used items’ in the taxonomy meta box when no items are available.',
1327 'simple-tags'),
1328 'data' => [
1329 /* translators: Used for autofill */
1330 'label' => sprintf(esc_attr__('No %s found', 'simple-tags'),
1331 'item'),
1332 'plurality' => 'plural',
1333 ],
1334 ]);
1335
1336 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1337 echo $ui->get_text_input([
1338 'namearray' => 'cpt_tax_labels',
1339 'name' => 'back_to_items',
1340 'textvalue' => isset($current['labels']['back_to_items']) ? esc_attr($current['labels']['back_to_items']) : null,
1341 'aftertext' => esc_html__('(e.g. &larr; Back to jobs',
1342 'simple-tags'),
1343 'labeltext' => esc_html__('Back to Items', 'simple-tags'),
1344 'helptext' => esc_attr__('The text displayed after a term has been updated for a link back to main index.',
1345 'simple-tags'),
1346 'data' => [
1347 /* translators: Used for autofill */
1348 'label' => sprintf(esc_attr__('Back to %s', 'simple-tags'),
1349 'item'),
1350 'plurality' => 'plural',
1351 ],
1352 ]);
1353 ?>
1354 </table>
1355
1356 <table class="form-table taxopress-table taxonomy_restapi"
1357 style="display:none;">
1358 <?php
1359
1360 $select = [
1361 'options' => [
1362 [
1363 'attr' => '0',
1364 'text' => esc_attr__('False', 'simple-tags'),
1365 ],
1366 [
1367 'attr' => '1',
1368 'text' => esc_attr__('True', 'simple-tags'),
1369 'default' => 'true',
1370 ],
1371 ],
1372 ];
1373 $selected = isset($current) ? taxopress_disp_boolean($current['show_in_rest']) : '';
1374 $select['selected'] = !empty($selected) ? $current['show_in_rest'] : '';
1375 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1376 echo $ui->get_select_checkbox_input([
1377 'namearray' => 'cpt_custom_tax',
1378 'name' => 'show_in_rest',
1379 'labeltext' => esc_html__('Show in REST API', 'simple-tags'),
1380 'aftertext' => esc_attr__('Add the taxonomy to the WordPress wp-json API.', 'simple-tags'),
1381 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1382 ]);
1383
1384 $rest_base_slug = '';
1385
1386 if (!empty($current['rest_base'])) {
1387 $rest_base_slug .= $current['rest_base'];
1388 } elseif (!empty($current['name'])) {
1389 $rest_base_slug .= $current['name'];
1390 } else {
1391 $rest_base_slug .= '{taxonomy}';
1392 }
1393
1394 // $current['name']
1395 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1396 echo $ui->get_text_input([
1397 'namearray' => 'cpt_custom_tax',
1398 'name' => 'rest_base',
1399 'labeltext' => esc_html__('REST API base slug', 'simple-tags'),
1400 'helptext' => esc_attr__('The base slug that this taxonomy will use in the REST API.', 'simple-tags') . ' <a target="blank" href="'. home_url('/wp-json/wp/v2/'. $rest_base_slug .'').'">'. home_url('/wp-json/wp/v2/'. $rest_base_slug .'').'</a>',
1401 'textvalue' => isset($current['rest_base']) ? esc_attr($current['rest_base']) : '',
1402 ]);
1403
1404 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1405 echo $ui->get_text_input([
1406 'namearray' => 'cpt_custom_tax',
1407 'name' => 'rest_controller_class',
1408 'labeltext' => esc_html__('REST API controller class',
1409 'simple-tags'),
1410 'helptext' => esc_attr__('The name of a custom Rest Controller class instead of WP_REST_Terms_Controller.', 'simple-tags'),
1411 'aftertext' => esc_attr__('Custom controller to use instead of WP_REST_Terms_Controller.',
1412 'simple-tags'),
1413 'textvalue' => isset($current['rest_controller_class']) ? esc_attr($current['rest_controller_class']) : '',
1414 ]);
1415
1416
1417 ?>
1418
1419 </div>
1420
1421
1422 <table class="form-table taxopress-table taxonomy_advanced"
1423 style="display:none;">
1424 <?php
1425
1426 $select = [
1427 'options' => [
1428 [
1429 'attr' => '0',
1430 'text' => esc_attr__('False', 'simple-tags'),
1431 ],
1432 [
1433 'attr' => '1',
1434 'text' => esc_attr__('True', 'simple-tags'),
1435 'default' => 'true',
1436 ],
1437 ],
1438 ];
1439 $selected = isset($current) ? taxopress_disp_boolean($current['public']) : '';
1440 $select['selected'] = !empty($selected) ? $current['public'] : '';
1441 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1442 echo $ui->get_select_checkbox_input([
1443 'namearray' => 'cpt_custom_tax',
1444 'name' => 'public',
1445 'labeltext' => esc_html__('Public', 'simple-tags'),
1446 'aftertext' => esc_html__('The taxonomy is for public use. It can be seen by frontend users.',
1447 'simple-tags'),
1448 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1449 ]);
1450
1451 $select = [
1452 'options' => [
1453 [
1454 'attr' => '0',
1455 'text' => esc_attr__('False', 'simple-tags'),
1456 ],
1457 [
1458 'attr' => '1',
1459 'text' => esc_attr__('True', 'simple-tags'),
1460 'default' => 'true',
1461 ],
1462 ],
1463 ];
1464 $selected = isset($current) ? taxopress_disp_boolean($current['publicly_queryable']) : '';
1465 $select['selected'] = !empty($selected) ? $current['publicly_queryable'] : '';
1466 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1467 echo $ui->get_select_checkbox_input([
1468 'namearray' => 'cpt_custom_tax',
1469 'name' => 'publicly_queryable',
1470 'labeltext' => esc_html__('Public Queryable', 'simple-tags'),
1471 'aftertext' => esc_html__('The taxonomy is publicly queryable.',
1472 'simple-tags'),
1473 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1474 ]);
1475
1476 $select = [
1477 'options' => [
1478 [
1479 'attr' => '0',
1480 'text' => esc_attr__('False', 'simple-tags'),
1481 ],
1482 [
1483 'attr' => '1',
1484 'text' => esc_attr__('True', 'simple-tags'),
1485 'default' => 'true',
1486 ],
1487 ],
1488 ];
1489 $selected = isset($current) ? taxopress_disp_boolean($current['query_var']) : '';
1490 $select['selected'] = !empty($selected) ? $current['query_var'] : '';
1491 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1492 echo $ui->get_select_checkbox_input([
1493 'namearray' => 'cpt_custom_tax',
1494 'name' => 'query_var',
1495 'labeltext' => esc_html__('Query Var', 'simple-tags'),
1496 'aftertext' => esc_html__('Enable a custom query_var key for this taxonomy.',
1497 'simple-tags'),
1498 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1499 ]);
1500
1501 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1502 echo $ui->get_text_input([
1503 'namearray' => 'cpt_custom_tax',
1504 'name' => 'query_var_slug',
1505 'textvalue' => isset($current['query_var_slug']) ? esc_attr($current['query_var_slug']) : '',
1506 'aftertext' => '',
1507 'labeltext' => esc_html__('Custom Query Var String', 'simple-tags'),
1508 'helptext' => esc_html__('Sets a custom query_var slug for this taxonomy.',
1509 'simple-tags'),
1510 ]);
1511
1512 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1513 echo $ui->get_text_input([
1514 'namearray' => 'cpt_custom_tax',
1515 'name' => 'meta_box_cb',
1516 'textvalue' => isset($current['meta_box_cb']) ? esc_attr($current['meta_box_cb']) : '',
1517 'labeltext' => esc_html__('Metabox callback', 'simple-tags'),
1518 'helptext' => esc_html__('Sets a callback function name for the meta box display. Hierarchical default: post_categories_meta_box, non-hierarchical default: post_tags_meta_box. To remove the metabox completely, use "false".',
1519 'simple-tags'),
1520 ]);
1521 ?>
1522 </table>
1523
1524 <table class="form-table taxopress-table taxonomy_order"
1525 style="display:none;">
1526 <?php
1527 $taxonomy_label = !empty($current['label']) ? $current['label'] : esc_html__('Categories', 'simple-tags');
1528 ?>
1529 <tr>
1530 <td colspan="2">
1531 <div class="taxopress-description">
1532 <?php
1533 echo esc_html(
1534 sprintf(
1535 __('This feature controls the order of %s when you\'re editing posts, and in frontend displays.', 'simple-tags'),
1536 $taxonomy_label
1537 )
1538 );
1539 ?>
1540 </div>
1541 </td>
1542 </tr>
1543 <tr>
1544 <th scope="row">
1545 <label for="taxopress_enable_ordering"><?php esc_html_e('Enable TaxoPress ordering', 'simple-tags'); ?></label>
1546 </th>
1547 <td>
1548 <input type="checkbox" name="cpt_custom_tax[enable_taxopress_ordering]" id="taxopress_enable_ordering" value="1"
1549 <?php checked( !empty($current['enable_taxopress_ordering']), 1 ); ?> />
1550 <span class="description"><?php esc_html_e('Enable TaxoPress ordering for this taxonomy in the frontend and admin area.', 'simple-tags'); ?></span>
1551 </td>
1552 </tr>
1553 <?php
1554 do_action('taxopress_terms_order', $current);
1555 ?>
1556 </table>
1557
1558
1559
1560 <table class="form-table taxopress-table taxonomy_delete"
1561 style="display:none;">
1562 <?php
1563 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1564 echo $ui->get_tr_start() . $ui->get_th_start();
1565
1566 ?>
1567 <?php
1568 if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?>
1569
1570
1571 <?php
1572
1573 $activate_action_link = add_query_arg(
1574 [
1575 'page' => 'st_taxonomies',
1576 'add' => 'taxonomy',
1577 'action' => 'edit',
1578 'action2' => 'taxopress-reactivate-taxonomy',
1579 'taxonomy' => esc_attr($request_tax),
1580 '_wpnonce' => wp_create_nonce('taxonomy-action-request-nonce'),
1581 'taxopress_taxonomy' => esc_attr($request_tax),
1582 ],
1583 taxopress_admin_url('admin.php')
1584 );
1585 $deactivate_action_link = add_query_arg(
1586 [
1587 'page' => 'st_taxonomies',
1588 'add' => 'taxonomy',
1589 'action' => 'edit',
1590 'action2' => 'taxopress-deactivate-taxonomy',
1591 'taxonomy' => esc_attr($request_tax),
1592 '_wpnonce' => wp_create_nonce('taxonomy-action-request-nonce'),
1593 'taxopress_taxonomy' => esc_attr($request_tax),
1594 ],
1595 taxopress_admin_url('admin.php')
1596 );
1597
1598 if (in_array($request_tax, taxopress_get_deactivated_taxonomy())) {
1599 ?>
1600 <span class="action-button reactivate"><a class="button-primary"
1601 href="<?php echo esc_url($activate_action_link); ?>"><?php echo esc_html__('Re-activate Taxonomy',
1602 'simple-tags'); ?></a></span>
1603 <?php } else { ?>
1604 <span class="action-button deactivate"><a class="button-primary"
1605 href="<?php echo esc_url($deactivate_action_link); ?>"><?php echo esc_html__('Deactivate Taxonomy',
1606 'simple-tags'); ?></a></span>
1607 <?php }
1608 /**
1609 * Filters the text value to use on the button when deleting.
1610 *
1611 * @param string $value Text to use for the button.
1612 */
1613 if (!$external_edit) {
1614 ?>
1615 <input type="submit" class="button-secondary taxopress-delete-bottom"
1616 name="cpt_delete"
1617 id="cpt_submit_delete"
1618 value="<?php echo esc_attr(apply_filters('taxopress_taxonomy_submit_delete',
1619 esc_html__('Delete Taxonomy', 'simple-tags'))); ?>"/>
1620 <?php } elseif ($external_edit && array_key_exists($current['name'], taxopress_get_extername_taxonomy_data())) { ?>
1621 <input type="submit" class="button-secondary taxopress-delete-bottom"
1622 name="cpt_delete"
1623 id="cpt_submit_delete"
1624 value="<?php echo esc_attr(apply_filters('taxopress_taxonomy_submit_delete',
1625 esc_html__('Delete TaxoPress Edit Data', 'simple-tags'))); ?>"/>
1626 <?php
1627 echo '<div class="taxopress-warning"">' . esc_html__('You can only delete taxonomies created with TaxoPress. However, you can delete any changes or edit made from TaxoPress which will remove TaxoPress version edit restoring original taxonomies data or removing it if already deleted',
1628 'simple-tags') . '</div>';
1629 }
1630 }
1631 ?>
1632
1633 <?php
1634
1635 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1636 echo $ui->get_th_end(). $ui->get_tr_end();
1637
1638
1639 ?>
1640
1641 </table>
1642
1643
1644 </div>
1645 <div class="clear"></div>
1646
1647
1648 </div>
1649 </div>
1650 </div>
1651
1652
1653 <?php
1654 /**
1655 * Fires after the default fieldsets on the taxonomy screen.
1656 *
1657 * @param taxopress_admin_ui $ui Admin UI instance.
1658 */
1659 do_action('taxopress_taxonomy_after_fieldsets', $ui);
1660 ?>
1661
1662 </div>
1663 </div>
1664 </div>
1665
1666
1667
1668 <div class="taxopress-right-sidebar">
1669 <div class="taxopress-right-sidebar-wrapper">
1670
1671
1672 <p class="submit">
1673
1674 <?php
1675 wp_nonce_field('taxopress_addedit_taxonomy_nonce_action',
1676 'taxopress_addedit_taxonomy_nonce_field');
1677 if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?>
1678 <?php
1679
1680 /**
1681 * Filters the text value to use on the button when editing.
1682 *
1683 * @param string $value Text to use for the button.
1684 */
1685 ?>
1686 <input type="submit" class="button-primary taxopress-taxonomy-submit" name="cpt_submit"
1687 value="<?php echo esc_attr(apply_filters('taxopress_taxonomy_submit_edit',
1688 esc_attr__('Save Taxonomy', 'simple-tags'))); ?>"/>
1689 <?php
1690 } else { ?>
1691 <?php
1692
1693 /**
1694 * Filters the text value to use on the button when adding.
1695 *
1696 * @param string $value Text to use for the button.
1697 */
1698 ?>
1699 <input type="submit" class="button-primary taxopress-taxonomy-submit" name="cpt_submit"
1700 value="<?php echo esc_attr(apply_filters('taxopress_taxonomy_submit_add',
1701 esc_attr__('Add Taxonomy', 'simple-tags'))); ?>"/>
1702 <?php } ?>
1703 <div class="taxonomy-required-field"></div>
1704
1705 <?php if (!empty($current)) { ?>
1706 <input type="hidden" name="tax_original" id="tax_original"
1707 value="<?php echo esc_attr($current['name']); ?>"/>
1708 <?php
1709 }
1710
1711 // Used to check and see if we should prevent duplicate slugs.
1712 ?>
1713 <input type="hidden" name="cpt_tax_status" id="cpt_tax_status"
1714 value="<?php echo esc_attr($tab); ?>"/>
1715 </p>
1716 </div>
1717
1718 <?php do_action('taxopress_admin_after_sidebar'); ?>
1719 </div>
1720
1721
1722 </form>
1723 </div><!-- End .wrap -->
1724
1725 <div class="clear"></div>
1726
1727 <?php # Modal Windows; ?>
1728 <div class="remodal" data-remodal-id="taxopress-modal-alert"
1729 data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
1730 <div class="" style="color:red;"><?php echo esc_html__('Please complete the following required fields to save your changes:', 'simple-tags'); ?></div>
1731 <div id="taxopress-modal-alert-content"></div>
1732 <br>
1733 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('Okay', 'simple-tags'); ?></button>
1734 </div>
1735
1736 <div class="remodal" data-remodal-id="taxopress-modal-confirm"
1737 data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
1738 <div id="taxopress-modal-confirm-content"></div>
1739 <br>
1740 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('No', 'simple-tags'); ?></button>
1741 <button data-remodal-action="confirm"
1742 class="remodal-confirm"><?php echo esc_html__('Yes', 'simple-tags'); ?></button>
1743 </div>
1744
1745 <?php
1746 }
1747
1748 }
1749