PluginProbe
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms / 3.38.0
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms v3.38.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 / autoterms.php

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

1,631 lines 119.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class SimpleTags_Autoterms
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 // WP_List_Table object
15 public $logs_table;
16
17 /**
18 * Constructor
19 *
20 * @return void
21 * @author Olatechpro
22 */
23 public function __construct()
24 {
25
26 add_filter('set-screen-option', [__CLASS__, 'set_screen'], 10, 3);
27 // Admin menu
28 add_action('admin_menu', [$this, 'admin_menu']);
29 // Javascript
30 add_action('admin_enqueue_scripts', [__CLASS__, 'admin_enqueue_scripts'], 11);
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
43 // add JS for manage click tags
44 if (isset($_GET['page']) && $_GET['page'] == 'st_autoterms') {
45 wp_enqueue_style('st-taxonomies-css');
46 }
47 }
48
49 public static function set_screen($status, $option, $value)
50 {
51 return $value;
52 }
53
54 /** Singleton instance */
55 public static function get_instance()
56 {
57 if (!isset(self::$instance)) {
58 self::$instance = new self();
59 }
60
61 return self::$instance;
62 }
63
64 /**
65 * Add WP admin menu for Tags
66 *
67 * @return void
68 * @author Olatechpro
69 */
70 public function admin_menu()
71 {
72 $hook = add_submenu_page(
73 self::MENU_SLUG,
74 esc_html__('Auto Terms', 'simple-tags'),
75 esc_html__('Auto Terms', 'simple-tags'),
76 'simple_tags',
77 'st_autoterms',
78 [
79 $this,
80 'page_manage_autoterms',
81 ]
82 );
83
84 if(taxopress_is_screen_main_page()){
85 add_action("load-$hook", [$this, 'screen_option']);
86 }
87 }
88
89 public function autoterms_logs_count(){
90
91 $count = taxopress_autoterms_logs_data(1)['counts'];
92 return '('. number_format_i18n($count) .')';
93 }
94
95 /**
96 * Screen options
97 */
98 public function screen_option()
99 {
100
101 $option = 'per_page';
102
103 if (isset($_GET['tab']) && $_GET['tab'] === 'logs') {
104 $args = [
105 'label' => esc_html__('Number of items per page', 'simple-tags'),
106 'default' => 20,
107 'option' => 'st_autoterms_logs_per_page'
108 ];
109 $this->logs_table = new Autoterms_Logs();
110 }else{
111 $args = [
112 'label' => esc_html__('Number of items per page', 'simple-tags'),
113 'default' => 20,
114 'option' => 'st_autoterms_per_page'
115 ];
116 $this->terms_table = new Autoterms_List();
117 }
118
119 add_screen_option($option, $args);
120 }
121
122 /**
123 * Method for build the page HTML manage tags
124 *
125 * @return void
126 * @author Olatechpro
127 */
128 public function page_manage_autoterms()
129 {
130 // Default order
131 if (!isset($_GET['order'])) {
132 $_GET['order'] = 'name-asc';
133 }
134
135 settings_errors(__CLASS__);
136
137 if (isset($_GET['tab']) && $_GET['tab'] === 'logs') {
138 //autoterms logs
139
140 $delete_all_link = add_query_arg([
141 'page' => 'st_autoterms',
142 'tab' => 'logs',
143 'action' => 'taxopress-delete-autoterm-logs',
144 '_wpnonce' => wp_create_nonce('autoterm-action-request-nonce')
145 ],
146 admin_url('admin.php')
147 );
148
149 $enable_log_link = add_query_arg([
150 'page' => 'st_autoterms',
151 'tab' => 'logs',
152 'action' => 'taxopress-enable-autoterm-logs',
153 '_wpnonce' => wp_create_nonce('autoterm-action-request-nonce')
154 ],
155 admin_url('admin.php')
156 );
157
158 $disable_log_link = add_query_arg([
159 'page' => 'st_autoterms',
160 'tab' => 'logs',
161 'action' => 'taxopress-disable-autoterm-logs',
162 '_wpnonce' => wp_create_nonce('autoterm-action-request-nonce')
163 ],
164 admin_url('admin.php')
165 );
166 ?>
167 <div class="wrap st_wrap st-manage-taxonomies-page">
168
169 <div id="">
170 <h1 class="wp-heading-inline"><?php esc_html_e('Auto Terms Logs', 'simple-tags'); ?></h1>
171 <a href="<?php echo esc_url(admin_url('admin.php?page=st_autoterms')); ?>"
172 class="page-title-action"><?php esc_html_e('Auto Terms', 'simple-tags'); ?></a>
173
174 <a href="<?php echo esc_url(admin_url('admin.php?page=st_autoterms&add=new_item')); ?>"
175 class="page-title-action"><?php esc_html_e('Add New Auto Terms', 'simple-tags'); ?></a>
176
177 <?php if(get_option('taxopress_autoterms_logs_disabled')){ ?>
178 <a href="<?php echo esc_url($enable_log_link); ?>" class="page-title-action taxopress-logs-tablenav-enable-logs"><?php esc_html_e('Enable Logs', 'simple-tags'); ?></a>
179 <?php } else { ?>
180 <a href="<?php echo esc_url($disable_log_link); ?>" class="page-title-action taxopress-logs-tablenav-disable-logs" onclick="return confirm('<?php esc_attr_e('Are you sure you want to disable logs?', 'simple-tags'); ?>')"><?php esc_html_e('Disable Logs', 'simple-tags'); ?></a>
181 <?php } ?>
182
183 <a href="<?php echo esc_url($delete_all_link); ?>" class="page-title-action taxopress-logs-tablenav-purge-logs" onclick="return confirm('<?php esc_attr_e('Are you sure you want to delete all logs?', 'simple-tags'); ?>')"><?php esc_html_e('Delete All Logs', 'simple-tags'); ?></a>
184
185 <div class="taxopress-description">
186 <?php esc_html_e('Auto Terms logs history.', 'simple-tags'); ?>
187 </div>
188
189
190 <?php
191 if (isset($_REQUEST['s']) && $search = esc_attr(sanitize_text_field(wp_unslash($_REQUEST['s'])))) {
192 /* translators: %s: search keywords */
193 printf(' <span class="subtitle">' . esc_html__('Search results for &#8220;%s&#8221;',
194 'simple-tags') . '</span>', esc_html($search));
195 }
196 ?>
197 <?php
198
199 //the terms table instance
200 $this->logs_table->prepare_items();
201 ?>
202
203
204 <hr class="wp-header-end">
205 <div id="ajax-response"></div>
206 <form class="search-form wp-clearfix st-taxonomies-search-form" method="get">
207 <?php $this->logs_table->search_box(esc_html__('Search Auto Terms Logs', 'simple-tags'), 'term'); ?>
208 </form>
209 <div class="clear"></div>
210
211 <div id="col-container" class="wp-clearfix">
212
213 <div class="col-wrap">
214 <form action="<?php echo esc_url(add_query_arg('', '')); ?>" method="post">
215 <?php $this->logs_table->display(); //Display the table ?>
216 </form>
217 <div class="form-wrap edit-term-notes">
218 <p><?php esc_html__('Description here.', 'simple-tags') ?></p>
219 </div>
220 </div>
221
222
223 </div>
224
225
226 </div>
227 <?php }elseif (!isset($_GET['add'])) {
228 //all tax
229 ?>
230 <div class="wrap st_wrap st-manage-taxonomies-page">
231
232 <div id="">
233 <h1 class="wp-heading-inline"><?php esc_html_e('Auto Terms', 'simple-tags'); ?></h1>
234 <a href="<?php echo esc_url(admin_url('admin.php?page=st_autoterms&add=new_item')); ?>"
235 class="page-title-action taxopress">
236 <span class="dashicons dashicons-lock"></span>
237 <?php esc_html_e('Add New Auto Terms', 'simple-tags'); ?>
238 </a>
239
240 <a href="<?php echo esc_url(admin_url('admin.php?page=st_autoterms&tab=logs')); ?>"
241 class="page-title-action"><?php esc_html_e('Logs', 'simple-tags'); ?> <span class="update-plugins"><span class="plugin-count"><?php echo esc_html($this->autoterms_logs_count()); ?></span></span></a>
242
243 <div class="taxopress-description">
244 <?php esc_html_e('Auto Terms can scan your content and automatically assign new and existing terms.', 'simple-tags'); ?>
245 </div>
246
247
248 <?php
249 if (isset($_REQUEST['s']) && $search = esc_attr(sanitize_text_field(wp_unslash($_REQUEST['s'])))) {
250 /* translators: %s: search keywords */
251 printf(' <span class="subtitle">' . esc_html__('Search results for &#8220;%s&#8221;',
252 'simple-tags') . '</span>', esc_html($search));
253 }
254 ?>
255 <?php
256
257 //the terms table instance
258 $this->terms_table->prepare_items();
259 ?>
260
261
262 <hr class="wp-header-end">
263 <div id="ajax-response"></div>
264 <form class="search-form wp-clearfix st-taxonomies-search-form" method="get">
265 <?php $this->terms_table->search_box(esc_html__('Search Auto Terms', 'simple-tags'), 'term'); ?>
266 </form>
267 <div class="clear"></div>
268
269 <div id="col-container" class="wp-clearfix">
270
271 <div class="col-wrap">
272 <form action="<?php echo esc_url(add_query_arg('', '')); ?>" method="post">
273 <?php $this->terms_table->display(); //Display the table ?>
274 </form>
275 <div class="form-wrap edit-term-notes">
276 <p><?php esc_html__('Description here.', 'simple-tags') ?></p>
277 </div>
278 </div>
279
280
281 </div>
282
283
284 </div>
285 <?php } else {
286 if ($_GET['add'] == 'new_item') {
287 //add/edit taxonomy
288 $this->taxopress_manage_autoterms();
289 echo '<div>';
290 }
291 } ?>
292
293
294 <?php SimpleTags_Admin::printAdminFooter(); ?>
295 </div>
296 <?php
297 }
298
299
300 /**
301 * Create our settings page output.
302 *
303 * @internal
304 */
305 public function taxopress_manage_autoterms()
306 {
307
308 $tab = (!empty($_GET) && !empty($_GET['action']) && 'edit' == $_GET['action']) ? 'edit' : 'new';
309 $tab_class = 'taxopress-' . $tab;
310 $current = null;
311
312 ?>
313
314 <div class="wrap <?php echo esc_attr($tab_class); ?>">
315
316 <?php
317
318 $autoterms = taxopress_get_autoterm_data();
319 $autoterm_edit = false;
320 $autoterm_limit = false;
321
322 if ('edit' === $tab) {
323
324
325 $selected_autoterm = taxopress_get_current_autoterm();
326
327 if ($selected_autoterm && array_key_exists($selected_autoterm, $autoterms)) {
328 $current = $autoterms[$selected_autoterm];
329 $autoterm_edit = true;
330 }
331
332 }
333
334
335 if (!isset($current['title']) && count($autoterms) > 0 && apply_filters('taxopress_autoterms_create_limit', true)) {
336 $autoterm_limit = true;
337 }
338
339
340 $ui = new taxopress_admin_ui();
341
342 $taxonomy_replace_options = [
343 'options' => [
344 [
345 'attr' => 'append',
346 'text' => esc_attr__('Add new terms and keep existing terms.', 'simple-tags'),
347 'default' => 'true'
348 ],
349 [
350 'attr' => 'append_and_replace',
351 'text' => esc_attr__('Add new terms and remove existing terms.', 'simple-tags')
352 ],
353 [
354 'attr' => 'replace',
355 'text' => esc_attr__('Remove existing terms even if no new terms are found.', 'simple-tags')
356 ]
357 ],
358 ];
359 ?>
360
361
362 <div class="wrap <?php echo esc_attr($tab_class); ?>">
363 <h1><?php echo esc_html__('Manage Auto Terms', 'simple-tags'); ?>
364
365 <a href="<?php echo esc_url(admin_url('admin.php?page=st_autoterms')); ?>"
366 class="page-title-action"><?php esc_html_e('Auto Terms', 'simple-tags'); ?></a>
367
368 <a href="<?php echo esc_url(admin_url('admin.php?page=st_autoterms&tab=logs')); ?>"
369 class="page-title-action"><?php esc_html_e('Logs', 'simple-tags'); ?> <span class="update-plugins"><span class="plugin-count"><?php echo esc_html($this->autoterms_logs_count()); ?></span></span></a>
370
371 </h1>
372
373 <div class="wp-clearfix"></div>
374
375 <form method="post" action="">
376
377
378 <div class="tagcloudui st-tabbed">
379
380
381 <div class="autoterms-postbox-container">
382 <div id="poststuff">
383 <div class="taxopress-section postbox">
384 <div class="postbox-header">
385 <h2 class="hndle ui-sortable-handle">
386 <?php
387 if ($autoterm_edit) {
388 $active_tab = ( isset($current['active_tab']) && !empty(trim($current['active_tab'])) ) ? $current['active_tab'] : 'autoterm_general';
389 echo esc_html__('Edit Auto Terms', 'simple-tags');
390 echo '<input type="hidden" name="edited_autoterm" value="' . esc_attr($current['ID']) . '" />';
391 echo '<input type="hidden" name="taxopress_autoterm[ID]" value="' . esc_attr($current['ID']) . '" />';
392 echo '<input type="hidden" name="taxopress_autoterm[active_tab]" class="taxopress-active-subtab" value="'.esc_attr($active_tab).'" />';
393 } else {
394 $active_tab = 'autoterm_general';
395 echo '<input type="hidden" name="taxopress_autoterm[active_tab]" class="taxopress-active-subtab" value="" />';
396 echo esc_html__('Add new Auto Terms', 'simple-tags');
397 }
398 ?>
399 </h2>
400 </div>
401 <div class="inside">
402 <div class="main">
403
404
405 <?php if ($autoterm_limit) {
406 echo '<div class="st-taxonomy-content promo-box-area"><div class="taxopress-warning upgrade-pro">
407
408 <h2 style="margin-bottom: 5px;">' . esc_html__('To create more Auto Terms, please upgrade to TaxoPress Pro.',
409 'simple-tags') . '</h2>
410 <p>
411 ' . esc_html__('With TaxoPress Pro, you can create unlimited Auto Terms. You can create Auto Terms for any taxonomy.',
412 'simple-tags') . '
413
414 </p>
415 </div></div>';
416
417 } else {
418 ?>
419
420
421 <ul class="taxopress-tab">
422 <li aria-current="<?php echo $active_tab === 'autoterm_general' ? 'true' : 'false'; ?>" class="autoterm_general_tab <?php echo $active_tab === 'autoterm_general' ? 'active' : ''; ?>" data-content="autoterm_general">
423 <a href="#autoterm_general"><span><?php esc_html_e('General',
424 'simple-tags'); ?></span></a>
425 </li>
426 <li aria-current="<?php echo $active_tab === 'autoterm_display' ? 'true' : 'false'; ?>" class="autoterm_display_tab <?php echo $active_tab === 'autoterm_display' ? 'active' : ''; ?>" data-content="autoterm_display">
427 <a href="#autoterm_display"><span><?php esc_html_e('Post Types',
428 'simple-tags'); ?></span></a>
429 </li>
430
431 <li aria-current="<?php echo $active_tab === 'autoterm_terms' ? 'true' : 'false'; ?>" class="autoterm_terms_tab <?php echo $active_tab === 'autoterm_terms' ? 'active' : ''; ?>" data-content="autoterm_terms">
432 <a href="#autoterm_terms"><span><?php esc_html_e('Sources',
433 'simple-tags'); ?></span></a>
434 </li>
435
436 <li aria-current="<?php echo $active_tab === 'autoterm_when_to_use' ? 'true' : 'false'; ?>" class="autoterm_when_to_use_tab <?php echo $active_tab === 'autoterm_when_to_use' ? 'active' : ''; ?>" data-content="autoterm_when_to_use">
437 <a href="#autoterm_when_to_use"><span><?php esc_html_e('When to Use',
438 'simple-tags'); ?></span></a>
439 </li>
440
441 <li aria-current="<?php echo $active_tab === 'autoterm_options' ? 'true' : 'false'; ?>" class="autoterm_options_tab <?php echo $active_tab === 'autoterm_options' ? 'active' : ''; ?>" data-content="autoterm_options">
442 <a href="#autoterm_options"><span><?php esc_html_e('Options',
443 'simple-tags'); ?></span></a>
444 </li>
445
446 <li aria-current="<?php echo $active_tab === 'autoterm_exceptions' ? 'true' : 'false'; ?>" class="autoterm_exceptions_tab <?php echo $active_tab === 'autoterm_exceptions' ? 'active' : ''; ?>" data-content="autoterm_exceptions">
447 <a href="#autoterm_exceptions"><span><?php esc_html_e(
448 'Exceptions',
449 'simple-tags'
450 ); ?></span></a>
451 </li>
452
453 <!--<li aria-current="<?php echo $active_tab === 'autoterm_oldcontent' ? 'true' : 'false'; ?>" class="autoterm_oldcontent_tab <?php echo $active_tab === 'autoterm_oldcontent' ? 'active' : ''; ?>" data-content="autoterm_oldcontent">
454 <a href="#autoterm_oldcontent"><span><?php esc_html_e('Existing Content',
455 'simple-tags'); ?></span></a>
456 </li>-->
457
458 <li aria-current="<?php echo $active_tab === 'autoterm_advanced' ? 'true' : 'false'; ?>" class="autoterm_advanced_tab <?php echo $active_tab === 'autoterm_advanced' ? 'active' : ''; ?>" data-content="autoterm_advanced">
459 <a href="#autoterm_advanced"><span><?php esc_html_e('Advanced',
460 'simple-tags'); ?></span></a>
461 </li>
462
463 <li aria-current="<?php echo $active_tab === 'autoterm_preview' ? 'true' : 'false'; ?>" class="autoterm_preview_tab <?php echo $active_tab === 'autoterm_preview' ? 'active' : ''; ?>" data-content="autoterm_preview">
464 <a href="#autoterm_preview"><span><?php esc_html_e('Preview',
465 'simple-tags'); ?></span></a>
466 </li>
467
468 </ul>
469
470 <div class="st-taxonomy-content taxopress-tab-content">
471
472
473 <table class="form-table taxopress-table autoterm_general"
474 style="<?php echo $active_tab === 'autoterm_general' ? '' : 'display:none;'; ?>">
475 <?php
476 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
477 echo $ui->get_tr_start();
478
479 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
480 echo $ui->get_th_start();
481 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
482 echo $ui->get_label('title', esc_html__('Title', 'simple-tags')) . $ui->get_required_span();
483 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
484 echo $ui->get_th_end() . $ui->get_td_start();
485
486 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
487 echo $ui->get_text_input([
488 'namearray' => 'taxopress_autoterm',
489 'name' => 'title',
490 'textvalue' => isset($current['title']) ? esc_attr($current['title']) : '',
491 'maxlength' => '32',
492 'helptext' => '',
493 'required' => true,
494 'placeholder' => false,
495 'wrap' => false,
496 ]);
497
498
499 $options = [];
500 foreach (get_all_taxopress_taxonomies() as $_taxonomy) {
501 $_taxonomy = $_taxonomy->name;
502 $tax = get_taxonomy($_taxonomy);
503 if (empty($tax->labels->name)) {
504 continue;
505 }
506 if ($tax->name === 'post_tag') {
507 $options[] = [
508 'attr' => $tax->name,
509 'text' => $tax->labels->name. ' ('.$tax->name.')',
510 'default' => 'true',
511 ];
512 } else {
513 $options[] = [
514 'attr' => $tax->name,
515 'text' => $tax->labels->name. ' ('.$tax->name.')',
516 ];
517 }
518 }
519
520 $select = [
521 'options' => $options,
522 ];
523 $selected = isset($current) ? taxopress_disp_boolean($current['taxonomy']) : '';
524 $select['selected'] = !empty($selected) ? $current['taxonomy'] : '';
525 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
526 echo $ui->get_select_checkbox_input_main([
527 'namearray' => 'taxopress_autoterm',
528 'name' => 'taxonomy',
529 'class' => 'st-post-taxonomy-select',
530 'labeltext' => esc_html__('Taxonomy', 'simple-tags'),
531 'required' => true,
532 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
533 ]);
534
535 $selected_option = (isset($current) && isset($current['autoterm_from'])) ? $current['autoterm_from'] : '';
536
537 $term_from_options = [
538 '' => esc_attr__('Don\'t scan Post Content or Title', 'simple-tags'),
539 'post_content' => esc_attr__('Post Content', 'simple-tags'),
540 'post_title' => esc_attr__('Post Title', 'simple-tags'),
541 'posts' => esc_attr__('Post Content and Title', 'simple-tags')
542 ];
543 ?>
544 <tr valign="top">
545 <th scope="row">
546 <label for="autoterm_from">
547 <?php esc_html_e('Find term in:', 'simple-tags'); ?>
548 </label>
549 </th>
550 <td>
551 <select class="" id="autoterm_from" name="taxopress_autoterm[autoterm_from]">
552 <?php foreach ($term_from_options as $option => $label) : ?>
553 <option value="<?php echo esc_attr($option); ?>" <?php selected($selected_option, $option); ?>>
554 <?php echo esc_html($label); ?>
555 </option>
556 <?php endforeach; ?>
557 </select>
558 </td>
559 </tr>
560 <tr valign="top">
561 <th></th>
562 <td style="margin-top: 0; padding-top: 0;">
563 <table class="visbile-table st-autoterm-area-table">
564 <tr>
565 <th scope="row" colspan="3" style="margin-top: 0; padding-top: 0; padding-bottom: 0;">
566 <label>
567 <?php echo esc_html__('Find in more areas:', 'simple-tags'); ?>
568 </label>
569 </th>
570 </tr>
571 <tr class="autoterm-custom-findin-row form-tr option">
572 <td style="padding-left: 0; padding-top: 0;" colspan="3">
573 <select class="autoterm-area-custom-type" style="max-width: 100%;">
574 <?php
575 $area_types = [
576 'custom_fields' => esc_html__('Custom Field', 'simple-tags'),
577 'taxonomies' => esc_html__('Taxonomy', 'simple-tags'),
578 ];
579 foreach ($area_types as $area_type_value => $area_type_label) : ?>
580 <option value="<?php echo esc_attr($area_type_value); ?>">
581 <?php echo esc_html($area_type_label); ?>
582 </option>
583 <?php endforeach; ?>
584 </select>
585 </td>
586 </tr>
587 <tr class="autoterm-custom-findin-row form-tr fields">
588 <td style="padding-left: 0; padding-top: 0;" colspan="3">
589 <select class="autoterm-area-custom-taxonomy st-hide-content find-in-content taxonomies" style="max-width: 100%"
590 placeholder="<?php echo esc_attr__("Search Taxonomy", "simple-tags"); ?>">
591 <option value=""><?php echo esc_html__("Search Taxonomy", "simple-tags"); ?></option>
592 <?php
593 foreach (get_all_taxopress_taxonomies() as $_taxonomy) :
594 $_taxonomy = $_taxonomy->name;
595 $tax = get_taxonomy($_taxonomy);
596 if (empty($tax->labels->name)) {
597 continue;
598 }
599 ?>
600 <option value="<?php echo esc_attr($tax->name); ?>">
601 <?php echo esc_html($tax->labels->name. ' ('.$tax->name.')'); ?>
602 </option>
603 <?php endforeach; ?>
604 </select>
605 <div class="autoterm-field-area">
606 <select style="width: 100%;" class="taxopress-custom-fields-search find-in-content custom_fields"
607 data-placeholder="<?php echo esc_attr__("Search Custom Field...", "simple-tags"); ?>"
608 data-nonce="<?php echo esc_attr__(wp_create_nonce('taxopress-custom-fields-search')); ?>"></select>
609 </div>
610 </td>
611 </tr>
612 <?php
613 $find_in_customs_entries = (!empty($current['find_in_customs_entries']) && is_array($current['find_in_customs_entries'])) ? $current['find_in_customs_entries'] : [];
614
615 $find_in_custom_fields_custom_items = (!empty($current['find_in_custom_fields_custom_items']) && is_array($current['find_in_custom_fields_custom_items'])) ? $current['find_in_custom_fields_custom_items'] : [];
616
617 $find_in_taxonomies_custom_items = (!empty($current['find_in_taxonomies_custom_items']) && is_array($current['find_in_taxonomies_custom_items'])) ? $current['find_in_taxonomies_custom_items'] : [];
618
619 if (!empty($find_in_customs_entries)) :
620 foreach ($find_in_customs_entries as $entry_type => $entry_options) :
621
622 if (!empty($entry_options)) :
623 foreach ($entry_options as $entry_option) :
624 $checked_option = false;
625 if ($entry_type == 'custom_fields' && in_array($entry_option, $find_in_custom_fields_custom_items)) {
626 $checked_option = true;
627 } elseif (in_array($entry_option, $find_in_taxonomies_custom_items)) {
628 $checked_option = true;
629 }
630 ?>
631 <tr valign="top" class="find-in-customs-row <?php echo esc_attr($entry_type); ?> <?php echo esc_attr($entry_option); ?>">
632 <td colspan="2" class="item-header">
633 <div>
634 <span class="action-checkbox">
635 <input type="hidden" name="find_in_customs_entries[<?php echo esc_attr($entry_type); ?>][]" value="<?php echo esc_attr($entry_option); ?>" /><input type="checkbox" id="<?php echo esc_attr($entry_option); ?>" name="find_in_<?php echo esc_attr($entry_type); ?>_custom_items[]" value="<?php echo esc_attr($entry_option); ?>" <?php checked($checked_option, true); ?> />
636 </span>
637 <label for="<?php echo esc_attr($entry_option); ?>">
638 <?php echo esc_html($entry_option); ?>
639 </label>
640 </div>
641 </td>
642 <td>
643 <span class="delete">
644 <?php echo esc_html__("Delete", "simple-tags"); ?>
645 </span>
646 </td>
647 </tr>
648 <?php endforeach;
649 endif;
650
651 endforeach;
652 endif;
653
654 ?>
655 </table>
656 </td>
657 </tr>
658 <?php
659 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
660 echo $ui->get_td_end() . $ui->get_tr_end();
661 ?>
662 </table>
663
664 <table class="form-table taxopress-table autoterm_display"
665 style="<?php echo $active_tab === 'autoterm_display' ? '' : 'display:none;'; ?>">
666
667 <?php
668
669 /**
670 * Filters the arguments for post types to list for taxonomy association.
671 *
672 *
673 * @param array $value Array of default arguments.
674 */
675 $args = apply_filters('taxopress_attach_post_types_to_taxonomy',
676 ['public' => true]);
677
678 // 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.
679 if (!is_array($args)) {
680 $args = ['public' => true];
681 }
682 $output = 'objects'; // Or objects.
683
684 /**
685 * Filters the results returned to display for available post types for taxonomy.
686 *
687 * @param array $value Array of post type objects.
688 * @param array $args Array of arguments for the post type query.
689 * @param string $output The output type we want for the results.
690 */
691 $post_types = apply_filters('taxopress_get_post_types_for_taxonomies',
692 get_post_types($args, $output), $args, $output);
693
694 $term_auto_locations = [];
695 foreach ($post_types as $post_type) {
696 if (!in_array($post_type->name, ['attachment'])) {
697 $term_auto_locations[$post_type->name] = $post_type->label;
698 }
699 }
700
701 echo '<tr valign="top"><th scope="row"><label>' . esc_html__('Post Types to scan:',
702 'simple-tags') . '</label> </th><td>
703 <table class="visbile-table">';
704 foreach ($term_auto_locations as $key => $value) {
705
706
707 echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($key) . '">' . esc_html($value) . '</label></th><td>';
708 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
709 echo $ui->get_check_input([
710 'checkvalue' => esc_attr($key),
711 'checked' => (!empty($current['post_types']) && is_array($current['post_types']) && in_array($key, $current['post_types'], true)) ? 'true' : 'false',
712 'name' => esc_attr($key),
713 'namearray' => 'post_types',
714 'textvalue' => esc_attr($key),
715 'labeltext' => "",
716 'wrap' => false,
717 ]);
718
719 echo '</td></tr>';
720
721
722 }
723 echo '</table></td></tr>';
724 ?>
725
726 </table>
727
728
729 <table class="form-table taxopress-table autoterm_when_to_use"
730 style="<?php echo $active_tab === 'autoterm_when_to_use' ? '' : 'display:none;'; ?>">
731 <tr valign="top" class="tab-group-tr">
732 <td colspan="2">
733 <div class="taxopress-group-wrap autoterm-tab-group when">
734 <div class="taxopress-button-group">
735
736 <label class="post current">
737 <input disabled type="checkbox" name="taxopress_autoterm[autoterm_source_when_to_use_tab][]" value="post"><?php esc_html_e('Posts', 'simple-tags'); ?></label>
738 <label class="schedule">
739 <input disabled type="checkbox" name="taxopress_autoterm[autoterm_source_when_to_use_tab][]" value="schedule"><?php esc_html_e('Schedule', 'simple-tags'); ?></label>
740 <label class="existing-content">
741 <input disabled type="checkbox" name="taxopress_autoterm[autoterm_source_when_to_use_tab][]" value="existing_content"><?php esc_html_e('Existing Content', 'simple-tags'); ?></label>
742 <label class="metaboxes">
743 <input disabled type="checkbox" name="taxopress_autoterm[autoterm_source_when_to_use_tab][]" value="metaboxes"><?php esc_html_e('Metaboxes', 'simple-tags'); ?></label>
744 </div>
745 </div>
746 </td>
747 </tr>
748 <?php
749
750 if($autoterm_edit){
751 $default_select = [
752 'options' => [
753 [
754 'attr' => '0',
755 'text' => esc_attr__('False', 'simple-tags'),
756 'default' => 'true',
757 ],
758 [
759 'attr' => '1',
760 'text' => esc_attr__('True', 'simple-tags'),
761 ],
762 ],
763 ];
764 }else{
765 $default_select = [
766 'options' => [
767 [
768 'attr' => '0',
769 'text' => esc_attr__('False', 'simple-tags'),
770 ],
771 [
772 'attr' => '1',
773 'text' => esc_attr__('True', 'simple-tags'),
774 'default' => 'true',
775 ],
776 ],
777 ];
778
779 }
780
781 /**
782 * Post
783 */
784 $selected = (isset($current) && isset($current['autoterm_for_post'])) ? taxopress_disp_boolean($current['autoterm_for_post']) : '';
785 $default_select['selected'] = !empty($selected) ? $current['autoterm_for_post'] : '';
786 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
787 echo $ui->get_select_checkbox_input([
788 'namearray' => 'taxopress_autoterm',
789 'name' => 'autoterm_for_post',
790 'class' => 'autoterm_for_post autoterm-terms-when-to-field autoterm-terms-when-post fields-control',
791 'labeltext' => esc_html__('Post', 'simple-tags'),
792 'aftertext' => esc_html__('Enable Auto Terms when a post is saved or updated.', 'simple-tags'),
793 'selections' => $default_select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
794 'required' => false,
795 ]);
796
797 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
798 echo $ui->get_number_input([
799 'namearray' => 'taxopress_autoterm',
800 'name' => 'terms_limit',
801 'textvalue' => isset($current['terms_limit']) ? esc_attr($current['terms_limit']) : '5',
802 'class' => 'autoterm_for_post autoterm-terms-when-to-field autoterm-terms-when-post',
803 'labeltext' => esc_html__('Auto Terms Limit',
804 'simple-tags'),
805 'helptext' => esc_html__('Limit the number of generated Auto Terms. \'0\' for unlimited terms', 'simple-tags'),
806 'min' => '0',
807 'required' => false,
808 ]);
809
810
811 $selected = (isset($current) && isset($current['autoterm_target'])) ? taxopress_disp_boolean($current['autoterm_target']) : '';
812 $default_select['selected'] = !empty($selected) ? $current['autoterm_target'] : '';
813 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
814 echo $ui->get_select_checkbox_input([
815 'namearray' => 'taxopress_autoterm',
816 'name' => 'autoterm_target',
817 'class' => 'autoterm_for_post autoterm-terms-when-to-field autoterm-terms-when-post',
818 'labeltext' => esc_html__('Target content', 'simple-tags'),
819 'aftertext' => esc_html__('Only use Auto Terms on posts with no added terms.', 'simple-tags'),
820 'selections' => $default_select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
821 ]);
822
823
824 $selected = (isset($current) && isset($current['autoterm_word'])) ? taxopress_disp_boolean($current['autoterm_word']) : '';
825 $default_select['selected'] = !empty($selected) ? $current['autoterm_word'] : '';
826 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
827 echo $ui->get_select_checkbox_input([
828 'namearray' => 'taxopress_autoterm',
829 'name' => 'autoterm_word',
830 'class' => 'autoterm_for_post autoterm-terms-when-to-field autoterm-terms-when-post',
831 'labeltext' => esc_html__('Whole words', 'simple-tags'),
832 'aftertext' => esc_html__('Only add terms when the word is an exact match. Do not make matches for partial words.', 'simple-tags'),
833 'selections' => $default_select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
834 ]);
835
836
837 $selected = (isset($current) && isset($current['autoterm_hash'])) ? taxopress_disp_boolean($current['autoterm_hash']) : '';
838 $default_select['selected'] = !empty($selected) ? $current['autoterm_hash'] : '';
839 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
840 echo $ui->get_select_checkbox_input([
841 'namearray' => 'taxopress_autoterm',
842 'name' => 'autoterm_hash',
843 'class' => 'autoterm_for_post autoterm-terms-when-to-field autoterm-terms-when-post',
844 'labeltext' => esc_html__('Hashtags', 'simple-tags'),
845 'aftertext' => esc_html__('Support hashtags symbols # in Auto Terms.', 'simple-tags'),
846 'selections' => $default_select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
847 ]);
848
849 $selected = (isset($current) && isset($current['post_replace_type'])) ? taxopress_disp_boolean($current['post_replace_type']) : '';
850 $taxonomy_replace_options['selected'] = !empty($selected) ? $current['post_replace_type'] : '';
851 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
852 echo $ui->get_radio_input([
853 'namearray' => 'taxopress_autoterm',
854 'name' => 'post_replace_type',
855 'class' => 'autoterm_for_post autoterm-terms-when-to-field autoterm-terms-when-post',
856 'labeltext' => esc_html__('Auto Terms replacement settings',
857 'simple-tags'),
858 'aftertext' => esc_html__('This option determines what happens when adding new terms to posts.', 'simple-tags'),
859 'selections' => $taxonomy_replace_options,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
860 ]);
861
862
863 /**
864 * Schedule
865 */
866 do_action('taxopress_autoterms_schedule_autoterm_terms_to_use', $current);
867
868 /**
869 * Existing Content
870 */
871 $selected = (isset($current) && isset($current['autoterm_for_existing_content'])) ? taxopress_disp_boolean($current['autoterm_for_existing_content']) : '';
872 $default_select['selected'] = !empty($selected) ? $current['autoterm_for_existing_content'] : '';
873 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
874 echo $ui->get_select_checkbox_input([
875 'namearray' => 'taxopress_autoterm',
876 'name' => 'autoterm_for_existing_content',
877 'class' => 'autoterm_for_existing_content autoterm-terms-when-to-field autoterm-terms-when-existing-content fields-control',
878 'labeltext' => esc_html__('Existing Content', 'simple-tags'),
879 'aftertext' => esc_html__('Enable Auto Terms for the "Existing Content" feature.', 'simple-tags'),
880 'selections' => $default_select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
881 'required' => false,
882 ]);
883
884 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
885 echo $ui->get_number_input([
886 'namearray' => 'taxopress_autoterm',
887 'name' => 'existing_content_terms_limit',
888 'textvalue' => isset($current['existing_content_terms_limit']) ? esc_attr($current['existing_content_terms_limit']) : '5',
889 'class' => 'autoterm_for_existing_content autoterm-terms-when-to-field autoterm-terms-when-existing-content',
890 'labeltext' => esc_html__('Auto Terms Limit',
891 'simple-tags'),
892 'helptext' => esc_html__('Limit the number of generated Auto Terms. \'0\' for unlimited terms', 'simple-tags'),
893 'min' => '0',
894 'required' => false,
895 ]);
896
897 $selected = (isset($current) && isset($current['existing_content_replace_type'])) ? taxopress_disp_boolean($current['existing_content_replace_type']) : '';
898 $taxonomy_replace_options['selected'] = !empty($selected) ? $current['existing_content_replace_type'] : '';
899 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
900 echo $ui->get_radio_input([
901 'namearray' => 'taxopress_autoterm',
902 'name' => 'existing_content_replace_type',
903 'class' => 'autoterm_for_existing_content autoterm-terms-when-to-field autoterm-terms-when-existing-content',
904 'labeltext' => esc_html__('Auto Terms replacement settings',
905 'simple-tags'),
906 'aftertext' => esc_html__('This option determines what happens when adding new terms to posts.', 'simple-tags'),
907 'selections' => $taxonomy_replace_options,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
908 ]);
909
910
911 /**
912 * Metaboxes
913 */
914 $selected = (isset($current) && isset($current['autoterm_for_metaboxes'])) ? taxopress_disp_boolean($current['autoterm_for_metaboxes']) : '';
915 $default_select['selected'] = !empty($selected) ? $current['autoterm_for_metaboxes'] : '';
916 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
917 echo $ui->get_select_checkbox_input([
918 'namearray' => 'taxopress_autoterm',
919 'name' => 'autoterm_for_metaboxes',
920 'class' => 'autoterm_for_metaboxes autoterm-terms-when-to-field autoterm-terms-when-metaboxes fields-control',
921 'labeltext' => esc_html__('Metaboxes', 'simple-tags'),
922 'aftertext' => esc_html__('Enable Auto Terms for the "Metaboxes" and the "Fast Update" feature.', 'simple-tags'),
923 'selections' => $default_select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
924 'required' => false,
925 ]);
926 ?>
927 </table>
928
929
930
931
932 <table class="form-table taxopress-table autoterm_terms"
933 style="<?php echo $active_tab === 'autoterm_terms' ? '' : 'display:none;'; ?>">
934 <tr valign="top" class="tab-group-tr">
935 <td colspan="2">
936 <div class="taxopress-group-wrap autoterm-tab-group source">
937 <div class="taxopress-button-group">
938 <label class="existing current">
939 <input disabled type="checkbox" name="taxopress_autoterm[autoterm_source_tab][]" value="existing_terms"><?php esc_html_e('Existing Terms', 'simple-tags'); ?></label>
940 <label class="openai">
941 <input disabled type="checkbox" name="taxopress_autoterm[autoterm_source_tab][]" value="open_ai"><?php esc_html_e('OpenAI', 'simple-tags'); ?></label>
942 <label class="ibm-watson">
943 <input disabled type="checkbox" name="taxopress_autoterm[autoterm_source_tab][]" value="ibm_watson"><?php esc_html_e('IBM Watson', 'simple-tags'); ?></label>
944 <label class="dandelion">
945 <input disabled type="checkbox" name="taxopress_autoterm[autoterm_source_tab][]" value="dandelion"><?php esc_html_e('Dandelion', 'simple-tags'); ?></label>
946 <label class="lseg-refinitiv">
947 <input disabled type="checkbox" name="taxopress_autoterm[autoterm_source_tab][]" value="lseg_refinitiv"><?php esc_html_e('LSEG / Refinitiv', 'simple-tags'); ?></label>
948 </div>
949 </div>
950 </td>
951 </tr>
952 <?php
953
954 if($autoterm_edit){
955 $select = [
956 'options' => [
957 [
958 'attr' => '0',
959 'text' => esc_attr__('False', 'simple-tags'),
960 'default' => 'true',
961 ],
962 [
963 'attr' => '1',
964 'text' => esc_attr__('True', 'simple-tags'),
965 ],
966 ],
967 ];
968 }else{
969 $select = [
970 'options' => [
971 [
972 'attr' => '0',
973 'text' => esc_attr__('False', 'simple-tags'),
974 ],
975 [
976 'attr' => '1',
977 'text' => esc_attr__('True', 'simple-tags'),
978 'default' => 'true',
979 ],
980 ],
981 ];
982
983 }
984 $selected = (isset($current) && isset($current['autoterm_use_taxonomy'])) ? taxopress_disp_boolean($current['autoterm_use_taxonomy']) : '';
985 $select['selected'] = !empty($selected) ? $current['autoterm_use_taxonomy'] : '';
986 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
987 echo $ui->get_select_checkbox_input([
988 'namearray' => 'taxopress_autoterm',
989 'name' => 'autoterm_use_taxonomy',
990 'class' => 'autoterm_use_taxonomy autoterm-terms-to-use-field autoterm-terms-use-existing fields-control',
991 'labeltext' => esc_html__('Existing taxonomy terms', 'simple-tags'),
992 'aftertext' => esc_html__('This will add existing terms from the taxonomy selected in the "General" tab.', 'simple-tags'),
993 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
994 'required' => false,
995 ]);
996
997
998
999 if($autoterm_edit){
1000 $select = [
1001 'options' => [
1002 [
1003 'attr' => '0',
1004 'text' => esc_attr__('False', 'simple-tags'),
1005 'default' => 'true',
1006 ],
1007 [
1008 'attr' => '1',
1009 'text' => esc_attr__('True', 'simple-tags'),
1010 ],
1011 ],
1012 ];
1013 }else{
1014 $select = [
1015 'options' => [
1016 [
1017 'attr' => '0',
1018 'text' => esc_attr__('False', 'simple-tags'),
1019 ],
1020 [
1021 'attr' => '1',
1022 'text' => esc_attr__('True', 'simple-tags'),
1023 'default' => 'true',
1024 ],
1025 ],
1026 ];
1027
1028 }
1029
1030 $selected = (isset($current) && isset($current['autoterm_useall'])) ? taxopress_disp_boolean($current['autoterm_useall']) : '';
1031 $select['selected'] = !empty($selected) ? $current['autoterm_useall'] : '';
1032 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1033 echo $ui->get_select_checkbox_input([
1034 'namearray' => 'taxopress_autoterm',
1035 'name' => 'autoterm_useall',
1036 'class' => 'autoterm_useall autoterm-terms-to-use-field autoterm-terms-use-existing',
1037 'labeltext' => '',
1038 'aftertext' => esc_html__('Use all the terms in the selected taxonomy.', 'simple-tags'),
1039 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1040 'required' => false,
1041 ]);
1042
1043
1044 $select = [
1045 'options' => [
1046 [
1047 'attr' => '0',
1048 'text' => esc_attr__('False', 'simple-tags'),
1049 'default' => 'true',
1050 ],
1051 [
1052 'attr' => '1',
1053 'text' => esc_attr__('True', 'simple-tags'),
1054 ],
1055 ],
1056 ];
1057 $selected = (isset($current) && isset($current['autoterm_useonly'])) ? taxopress_disp_boolean($current['autoterm_useonly']) : '';
1058 $select['selected'] = !empty($selected) ? $current['autoterm_useonly'] : '';
1059 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1060 echo $ui->get_select_checkbox_input([
1061 'namearray' => 'taxopress_autoterm',
1062 'name' => 'autoterm_useonly',
1063 'class' => 'autoterm_useonly autoterm-terms-to-use-field autoterm-terms-use-existing',
1064 'labeltext' => ' ',
1065 'aftertext' => esc_html__('Use only some terms in the selected taxonomy.', 'simple-tags'),
1066 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1067 ]);
1068
1069 $specific_terms = ( isset($current) && isset($current['specific_terms'])) ? taxopress_change_to_array($current['specific_terms']) : '';
1070 echo '<tr class="autoterm_useonly_options '. ($selected === 'false' ? 'st-hide-content' : '') .'" valign="top"><th scope="row"><label for=""></label></th><td>';
1071 echo '<div class="auto-terms-to-use-error" style="display:none;"> '.esc_html__('Please choose an option for "Sources"', 'simple-tags').' </div>';
1072
1073 echo '<div class="st-autoterms-single-specific-term autoterm-terms-use-existing">
1074 <input autocomplete="off" type="text" class="st-full-width specific_terms_input" name="specific_terms_search" maxlength="32" placeholder="'. esc_attr(__('Choose the terms to use.', 'simple-tags')) .'" value="">
1075 </div>';
1076 echo '<ul class="taxopress-term-list-style">';
1077 if (!empty($specific_terms)) {
1078 foreach ($specific_terms as $specific_term) {
1079 if (!empty($specific_term)) {
1080 ?>
1081 <li class="taxopress-term-li">
1082 <span class="display-text"><?php echo esc_html($specific_term); ?></span>
1083 <span class="remove-term-row">
1084 <span class="dashicons dashicons-no-alt"></span>
1085 </span>
1086 <input type="hidden" class="taxopress-terms-names" name="specific_terms[]" value="<?php echo esc_attr($specific_term); ?>">
1087 </li>
1088 <?php
1089 }
1090 }
1091 }
1092 echo '</div>';
1093 echo '</td></tr>';
1094
1095
1096 $select = [
1097 'options' => [
1098 [
1099 'attr' => '0',
1100 'text' => esc_attr__('False', 'simple-tags'),
1101 'default' => 'true',
1102 ],
1103 [
1104 'attr' => '1',
1105 'text' => esc_attr__('True', 'simple-tags'),
1106 ],
1107 ],
1108 ];
1109 $selected = ( isset($current) && isset($current['suggest_local_terms_show_post_count']) ) ? taxopress_disp_boolean($current['suggest_local_terms_show_post_count']) : '';
1110 $select['selected'] = !empty($selected) ? $current['suggest_local_terms_show_post_count'] : '';
1111 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1112 echo $ui->get_select_checkbox_input([
1113 'namearray' => 'taxopress_autoterm',
1114 'name' => 'suggest_local_terms_show_post_count',
1115 'labeltext' => esc_html__('Show Term Post Count', 'simple-tags'),
1116 'aftertext' => esc_html__('This will show the number of posts attached to the terms.', 'simple-tags'),
1117 'class' => 'autoterm-terms-to-use-field autoterm-terms-use-existing',
1118 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1119 ]);
1120
1121 do_action('taxopress_autoterms_after_autoterm_terms_to_use', $current);
1122
1123 ?>
1124 </table>
1125
1126
1127 <table class="form-table taxopress-table autoterm_options"
1128 style="<?php echo $active_tab === 'autoterm_options' ? '' : 'display:none;'; ?>">
1129 <?php
1130
1131 if (taxopress_is_pro_version() && taxopress_is_synonyms_enabled()) {
1132 $select = [
1133 'options' => [
1134 [
1135 'attr' => '0',
1136 'text' => esc_attr__('False', 'simple-tags'),
1137 ],
1138 [
1139 'attr' => '1',
1140 'text' => esc_attr__('True', 'simple-tags'),
1141 'default' => 'true',
1142 ],
1143 ],
1144 ];
1145 $selected = (isset($current) && isset($current['synonyms_term'])) ? taxopress_disp_boolean($current['synonyms_term']) : '';
1146 $select['selected'] = !empty($selected) ? $current['synonyms_term'] : '';
1147 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1148 echo $ui->get_select_checkbox_input([
1149 'namearray' => 'taxopress_autoterm',
1150 'name' => 'synonyms_term',
1151 'labeltext' => esc_html__(
1152 'Add terms if synonyms found',
1153 'simple-tags'
1154 ),
1155 'aftertext' => esc_html__(
1156 'TaxoPress will add a term to the post if a synonym is found.',
1157 'simple-tags'
1158 ),
1159 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1160 ]);
1161 }
1162
1163
1164 $post_status_objects = taxopress_get_post_statuses();
1165 $post_status_options = [];
1166 foreach ( $post_status_objects as $status_slug => $status_object ) {
1167 if (in_array($status_slug, ['publish', 'future', 'draft', 'pending'])) {
1168 $post_status_options[$status_slug] = $status_object->label;
1169 }
1170 }
1171
1172 echo '<tr valign="top"><th scope="row"><label for="">' . esc_html__('Content statuses', 'simple-tags') . '</label> <span class="required">*</span></th><td>';
1173
1174 echo '<div class="auto-terms-post-status-error" style="display:none;"> '.esc_html__('Please choose an option for "Content statuses"', 'simple-tags').' </div>';
1175
1176 $autoterms_post_status = (!empty($current['post_status'])) ? (array)$current['post_status'] : ['publish'];
1177 foreach ($post_status_options as $key => $value) {
1178 $checked_status = (in_array($key, $autoterms_post_status)) ? 'checked' : '';
1179 echo '<input class="autoterm_post_status_'.esc_attr($key).'" type="checkbox" name="post_status[]" value="'.esc_attr($key).'" '.esc_attr($checked_status).'> ' . esc_html($value) . ' <br /><br />';
1180
1181 }
1182 echo '</td></tr>';
1183
1184 ?>
1185
1186 </table>
1187
1188
1189 <table class="form-table taxopress-table autoterm_exceptions" style="<?php echo $active_tab === 'autoterm_exceptions' ? '' : 'display:none;'; ?>">
1190 <?php
1191 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1192 echo $ui->get_textarea_input([
1193 'namearray' => 'taxopress_autoterm',
1194 'name' => 'autoterm_exclude',
1195 'rows' => '4',
1196 'cols' => '40',
1197 'class' => 'autocomplete-input auto-terms-stopwords',
1198 'textvalue' => isset($current['autoterm_exclude']) ? esc_attr($current['autoterm_exclude']) : '',
1199 'labeltext' => esc_html__(
1200 'Exclude terms from Auto Term',
1201 'simple-tags'
1202 ),
1203 'helptext' => esc_html__(
1204 'Choose terms to be excluded from auto terms.',
1205 'simple-tags'
1206 ),
1207 'required' => false,
1208 ]);
1209
1210 $html_exclusions = [
1211 //headers
1212 'h1' => esc_attr__('H1', 'simple-tags'),
1213 'h2' => esc_attr__('H2', 'simple-tags'),
1214 'h3' => esc_attr__('H3', 'simple-tags'),
1215 'h4' => esc_attr__('H4', 'simple-tags'),
1216 'h5' => esc_attr__('H5', 'simple-tags'),
1217 'h6' => esc_attr__('H6', 'simple-tags'),
1218 //html elements
1219 'a' => esc_attr__('a', 'simple-tags'),
1220 'script' => esc_attr__('script', 'simple-tags'),
1221 'style' => esc_attr__('style', 'simple-tags'),
1222 'pre' => esc_attr__('pre', 'simple-tags'),
1223 'code' => esc_attr__('code', 'simple-tags'),
1224 ];
1225
1226 echo '<tr valign="top"><th scope="row"><label>' . esc_html__(
1227 'Prevent Auto Term inside elements',
1228 'simple-tags'
1229 ) . '</label><br /><small style=" color: #646970;">' . esc_html__(
1230 'Terms inside these HTML tags will not be used to generate terms.',
1231 'simple-tags'
1232 ) . '</small></th><td>
1233 <table class="visbile-table st-html-exclusion-table" style="width: 100%;">';
1234 foreach ($html_exclusions as $key => $value) {
1235
1236 echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($key) . '">' . esc_html($value) . '</label></th><td>';
1237
1238 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1239 echo $ui->get_check_input([
1240 'checkvalue' => $key,
1241 'checked' => (!empty($current['html_exclusion']) && is_array($current['html_exclusion']) && in_array(
1242 $key,
1243 $current['html_exclusion'],
1244 true
1245 )) ? 'true' : 'false',
1246 'name' => esc_attr($key),
1247 'namearray' => 'html_exclusion',
1248 'textvalue' => esc_attr($key),
1249 'labeltext' => esc_html($key),
1250 'labeldescription' => true,
1251 'wrap' => false,
1252 ]);
1253
1254 echo '</td></tr>';
1255
1256 if ($key === 'h6') {
1257 echo '<tr valign="top"><th style="padding: 0;" scope="row"><hr /></th><td style="padding: 0;"><hr /></td></tr>';
1258 }
1259 }
1260
1261 /**
1262 * Fires after the autoterms html_exclusions.
1263 * @param $current array
1264 * @param taxopress_admin_ui $ui Admin UI instance.
1265 */
1266 do_action('taxopress_autoterms_after_html_exclusions', $current, $ui);
1267
1268 echo '</table></td></tr>';
1269
1270 /**
1271 * Fires after the autoterms html_exclusions tr.
1272 * @param $current array
1273 * @param taxopress_admin_ui $ui Admin UI instance.
1274 */
1275 do_action('taxopress_autoterms_after_html_exclusions_tr', $current, $ui);
1276
1277 ?>
1278
1279 </table>
1280
1281
1282 <table class="form-table taxopress-table autoterm_oldcontent"
1283 style="<?php echo $active_tab === 'autoterm_oldcontent' ? '' : 'display:none;'; ?>">
1284
1285 <?php
1286
1287 $select = [
1288 'options' => [
1289 [
1290 'attr' => '0',
1291 'text' => esc_attr__('False', 'simple-tags'),
1292 'default' => 'true',
1293 ],
1294 [
1295 'attr' => '1',
1296 'text' => esc_attr__('True', 'simple-tags'),
1297 ],
1298 ],
1299 ];
1300 $selected = (isset($current) && isset($current['autoterm_existing_content_exclude'])) ? taxopress_disp_boolean($current['autoterm_existing_content_exclude']) : '';
1301 $select['selected'] = !empty($selected) ? $current['autoterm_existing_content_exclude'] : '';
1302 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1303 echo $ui->get_select_checkbox_input([
1304 'namearray' => 'taxopress_autoterm',
1305 'name' => 'autoterm_existing_content_exclude',
1306 'class' => '',
1307 'labeltext' => esc_html__('Exclude previously analyzed content', 'simple-tags'),
1308 'aftertext' => esc_html__('This enables you to skip posts that have already been analyzed by the Existing Content feature.', 'simple-tags'),
1309 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1310 ]);
1311
1312 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1313 echo $ui->get_number_input([
1314 'namearray' => 'taxopress_autoterm',
1315 'name' => 'existing_terms_batches',
1316 'textvalue' => isset($current['existing_terms_batches']) ? esc_attr($current['existing_terms_batches']) : '2',
1317 'labeltext' => esc_html__('Limit per batches',
1318 'simple-tags'),
1319 'helptext' => esc_html__('This enables you to add Auto Terms to existing content in batches. If you have a lot of existing content, set this to a lower number to avoid timeouts.', 'simple-tags'),
1320 'min' => '1',
1321 'required' => true,
1322 ]);
1323
1324 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1325 echo $ui->get_number_input([
1326 'namearray' => 'taxopress_autoterm',
1327 'name' => 'existing_terms_sleep',
1328 'textvalue' => isset($current['existing_terms_sleep']) ? esc_attr($current['existing_terms_sleep']) : '10',
1329 'labeltext' => esc_html__('Batches wait time', 'simple-tags'),
1330 'helptext' => esc_html__('This is the wait time (in seconds) between processing batches of Auto Terms. If you have a lot of existing content, set this to a higher number to avoid timeouts.', 'simple-tags'),
1331 'min' => '0',
1332 'required' => true,
1333 ]);
1334
1335 $select = [
1336 'options' => [
1337 [
1338 'attr' => '1',
1339 'text' => esc_attr__('24 hours ago', 'simple-tags')
1340 ],
1341 [
1342 'attr' => '7',
1343 'text' => esc_attr__('7 days ago', 'simple-tags')
1344 ],
1345 [
1346 'attr' => '14',
1347 'text' => esc_attr__('2 weeks ago', 'simple-tags')
1348 ],
1349 [
1350 'attr' => '30',
1351 'text' => esc_attr__('1 month ago', 'simple-tags'),
1352 'default' => 'true'
1353 ],
1354 [
1355 'attr' => '180',
1356 'text' => esc_attr__('6 months ago', 'simple-tags')
1357 ],
1358 [
1359 'attr' => '365',
1360 'text' => esc_attr__('1 year ago', 'simple-tags')
1361 ],
1362 [
1363 'attr' => '0',
1364 'text' => esc_attr__('No limit', 'simple-tags')
1365 ],
1366 ],
1367 ];
1368
1369 if(isset($current) && is_array($current)){
1370 $select = [
1371 'options' => [
1372 [
1373 'attr' => '1',
1374 'text' => esc_attr__('24 hours ago', 'simple-tags')
1375 ],
1376 [
1377 'attr' => '7',
1378 'text' => esc_attr__('7 days ago', 'simple-tags')
1379 ],
1380 [
1381 'attr' => '14',
1382 'text' => esc_attr__('2 weeks ago', 'simple-tags')
1383 ],
1384 [
1385 'attr' => '30',
1386 'text' => esc_attr__('1 month ago', 'simple-tags'),
1387 ],
1388 [
1389 'attr' => '180',
1390 'text' => esc_attr__('6 months ago', 'simple-tags')
1391 ],
1392 [
1393 'attr' => '365',
1394 'text' => esc_attr__('1 year ago', 'simple-tags')
1395 ],
1396 [
1397 'attr' => '0',
1398 'text' => esc_attr__('No limit', 'simple-tags'),
1399 'default' => 'true'
1400 ],
1401 ],
1402 ];
1403 }
1404
1405 $selected = (isset($current) && isset($current['limit_days'])) ? taxopress_disp_boolean($current['limit_days']) : '';
1406 $select['selected'] = !empty($selected) ? $current['limit_days'] : '';
1407 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1408 echo $ui->get_select_number_select([
1409 'namearray' => 'taxopress_autoterm',
1410 'name' => 'limit_days',
1411 'labeltext' => esc_html__('Limit Auto Terms, based on published date',
1412 'simple-tags'),
1413 'aftertext' => esc_html__('This setting allows you to add Auto Terms only to recent content.', 'simple-tags'),
1414 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1415 ]);
1416 ?>
1417
1418 <tr valign="top"><th scope="row"><label><?php echo esc_html__('Existing Content', 'simple-tags'); ?></label></th>
1419
1420 <td>
1421 <input type="submit" class="button taxopress-autoterm-all-content" value="<?php echo esc_attr(__('Add Auto Terms to existing content', 'simple-tags')); ?>">
1422 <span class="spinner taxopress-spinner"></span>
1423
1424 <p class="taxopress-field-description description">
1425 <?php echo esc_html__('Click the button to add Auto Terms to existing content.', 'simple-tags'); ?>
1426 </p>
1427
1428 <div class="auto-term-content-result-title"></div>
1429
1430 </div>
1431
1432 <ul class="auto-term-content-result"></ul>
1433 </td></tr>
1434
1435 </table>
1436
1437
1438 <table class="form-table taxopress-table autoterm_advanced"
1439 style="<?php echo $active_tab === 'autoterm_advanced' ? '' : 'display:none;'; ?>">
1440
1441 <?php do_action('taxopress_autoterms_after_autoterm_advanced', $current); ?>
1442
1443 </table>
1444
1445
1446 <table class="form-table taxopress-table autoterm_preview"
1447 style="<?php echo $active_tab === 'autoterm_preview' ? '' : 'display:none;'; ?>">
1448 <tr class="autoterm-description-tr">
1449 <td colspan="2">
1450 <p class="description" style="margin-bottom: 20px;"><?php echo esc_attr__('Save changes to the settings before using this feature.', 'simple-tags'); ?></p>
1451 <div class="taxopress-autoterm-fetch-wrap">
1452 <select class="preview-post-types-select"
1453 style="width: auto;max-width: 33%;display: none;">
1454 <?php foreach (TaxoPressAiUtilities::get_post_types_options() as $post_type => $post_type_object):
1455 if (!in_array($post_type, ['attachment'])) {
1456 if (empty($default_post_type)) {
1457 $default_post_type = $post_type;
1458 $posts = $posts = get_posts(['post_type' => $post_type, 'numberposts' => 1, 'post_status' => 'publish', 'orderby' => 'date', 'order' => 'DESC']);
1459 if (!empty($posts)) {
1460 $post = $posts[0];
1461 }
1462 }
1463 ?>
1464 <option value='<?php echo esc_attr($post_type); ?>'
1465 data-singular_label="<?php echo esc_html($post_type_object->labels->singular_name); ?>">
1466 <?php echo esc_html($post_type_object->labels->name); ?>
1467 </option>
1468 <?php
1469 }
1470 endforeach; ?>
1471 </select>
1472
1473 <select class="preview-post-select taxopress-post-search"
1474 style="max-width: 250px; width: 250px;"
1475 data-placeholder="<?php echo esc_attr__('Select...', 'simple-tags'); ?>"
1476 data-allow-clear="true"
1477 data-nonce="<?php echo esc_attr(wp_create_nonce('taxopress-post-search')); ?>">
1478 <?php if (is_object($post)) : ?>
1479 <option value='<?php echo esc_attr($post->ID); ?>'>
1480 <?php echo esc_html($post->post_title); ?>
1481 </option>
1482 <?php endif; ?>
1483 </select>
1484 <button class="button button-secondary preview-button">
1485 <div class="spinner"></div>
1486 <span class="btn-text"><?php echo esc_attr__('Preview', 'simple-tags'); ?></span>
1487 </button>
1488 </div>
1489
1490 <div class="taxopress-autoterm-result">
1491 <div class="output"></div>
1492 <div class="response"></div>
1493 </div>
1494 </td>
1495 </tr>
1496
1497 </table>
1498
1499
1500 </div>
1501
1502
1503 <?php }//end new fields
1504 ?>
1505
1506
1507 <div class="clear"></div>
1508
1509
1510 </div>
1511 </div>
1512 </div>
1513
1514
1515 <?php if ($autoterm_limit) { ?>
1516
1517 <div class="pp-version-notice-bold-purple" style="margin-left:0px;">
1518 <div class="pp-version-notice-bold-purple-message"><?php echo esc_html__('You\'re using TaxoPress Free.
1519 The Pro version has more features and support.', 'simple-tags'); ?>
1520 </div>
1521 <div class="pp-version-notice-bold-purple-button"><a
1522 href="https://taxopress.com/taxopress/" target="_blank"><?php echo esc_html__('Upgrade to Pro', 'simple-tags'); ?></a>
1523 </div>
1524 </div>
1525
1526 <?php } ?>
1527 <?php
1528 /**
1529 * Fires after the default fieldsets on the taxonomy screen.
1530 *
1531 * @param taxopress_admin_ui $ui Admin UI instance.
1532 */
1533 do_action('taxopress_taxonomy_after_fieldsets', $ui);
1534 ?>
1535
1536 </div>
1537 </div>
1538
1539
1540 </div>
1541
1542 <div class="taxopress-right-sidebar">
1543 <div class="taxopress-right-sidebar-wrapper" style="min-height: 205px;<?php echo ($autoterm_limit) ? 'display: none;' : ''; ?>">
1544
1545
1546 <?php
1547 if (!$autoterm_limit) { ?>
1548 <p class="submit">
1549
1550 <?php
1551 wp_nonce_field('taxopress_addedit_autoterm_nonce_action',
1552 'taxopress_addedit_autoterm_nonce_field');
1553 if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?>
1554 <input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-autoterm-submit"
1555 name="autoterm_submit"
1556 value="<?php echo esc_attr(esc_attr__('Save Auto Terms',
1557 'simple-tags')); ?>"/>
1558 <?php
1559 } else { ?>
1560 <input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-autoterm-submit"
1561 name="autoterm_submit"
1562 value="<?php echo esc_attr(esc_attr__('Add Auto Terms',
1563 'simple-tags')); ?>"/>
1564 <?php } ?>
1565
1566
1567 <input type="hidden" name="cpt_tax_status" id="cpt_tax_status"
1568 value="<?php echo esc_attr($tab); ?>"/>
1569 </p>
1570
1571 <?php
1572 }
1573 ?>
1574
1575 </div>
1576
1577 <?php do_action('taxopress_admin_after_sidebar'); ?>
1578 <div class="taxopress-advertisement-right-sidebar">
1579 <div id="postbox-container-1" class="postbox-container">
1580 <div class="meta-box-sortables">
1581 <div class="advertisement-box-content postbox">
1582 <div class="postbox-header">
1583 <h3 class="advertisement-box-header hndle is-non-sortable">
1584 <span><?php echo esc_html__('TaxoPress and Languages', 'simple-tags'); ?></span>
1585 </h3>
1586 </div>
1587 <div class="inside">
1588 <p><?php echo sprintf(esc_html__('Please note that this is an automatic tool. It does have limitations around languages, types of content, and other factors. %1s Please read this documentation. %2s', 'simple-tags'), '<a href="https://taxopress.com/docs/characters/">', '</a>'); ?>
1589 </p>
1590 </div>
1591 </div>
1592 </div>
1593 </div>
1594 </div>
1595
1596
1597 </div>
1598
1599 <div class="clear"></div>
1600
1601
1602
1603 </form>
1604
1605 </div><!-- End .wrap -->
1606
1607 <div class="clear"></div>
1608
1609 <?php # Modal Windows; ?>
1610 <div class="remodal" data-remodal-id="taxopress-modal-alert"
1611 data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
1612 <div class="" style="color:red;"><?php echo esc_html__('Please complete the following required fields to save your changes:', 'simple-tags'); ?></div>
1613 <div id="taxopress-modal-alert-content"></div>
1614 <br>
1615 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('Okay', 'simple-tags'); ?></button>
1616 </div>
1617
1618 <div class="remodal" data-remodal-id="taxopress-modal-confirm"
1619 data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
1620 <div id="taxopress-modal-confirm-content"></div>
1621 <br>
1622 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('No', 'simple-tags'); ?></button>
1623 <button data-remodal-action="confirm"
1624 class="remodal-confirm"><?php echo esc_html__('Yes', 'simple-tags'); ?></button>
1625 </div>
1626
1627 <?php
1628 }
1629
1630 }
1631