PluginProbe
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms / 3.6.2
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms v3.6.2
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 3.6.2 All 177 releases
simple-tags / inc / autolinks.php

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

897 lines 54.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class SimpleTags_Autolink
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 }
31
32 /**
33 * Init somes JS and CSS need for this feature
34 *
35 * @return void
36 * @author Olatechpro
37 */
38 public static function admin_enqueue_scripts()
39 {
40
41 // add JS for manage click tags
42 if (isset($_GET['page']) && $_GET['page'] == 'st_autolinks') {
43 wp_enqueue_style('st-taxonomies-css');
44 }
45 }
46
47 public static function set_screen($status, $option, $value)
48 {
49 return $value;
50 }
51
52 /** Singleton instance */
53 public static function get_instance()
54 {
55 if (!isset(self::$instance)) {
56 self::$instance = new self();
57 }
58
59 return self::$instance;
60 }
61
62 /**
63 * Add WP admin menu for Tags
64 *
65 * @return void
66 * @author Olatechpro
67 */
68 public function admin_menu()
69 {
70 $hook = add_submenu_page(
71 self::MENU_SLUG,
72 esc_html__('Auto Links', 'simple-tags'),
73 esc_html__('Auto Links', 'simple-tags'),
74 'simple_tags',
75 'st_autolinks',
76 [
77 $this,
78 'page_manage_autolinks',
79 ]
80 );
81
82 if(taxopress_is_screen_main_page()){
83 add_action("load-$hook", [$this, 'screen_option']);
84 }
85 }
86
87 /**
88 * Screen options
89 */
90 public function screen_option()
91 {
92
93 $option = 'per_page';
94 $args = [
95 'label' => esc_html__('Number of items per page', 'simple-tags'),
96 'default' => 20,
97 'option' => 'st_autolinks_per_page'
98 ];
99
100 add_screen_option($option, $args);
101
102 $this->terms_table = new Autolinks_List();
103 }
104
105 /**
106 * Method for build the page HTML manage tags
107 *
108 * @return void
109 * @author Olatechpro
110 */
111 public function page_manage_autolinks()
112 {
113 // Default order
114 if (!isset($_GET['order'])) {
115 $_GET['order'] = 'name-asc';
116 }
117
118 settings_errors(__CLASS__);
119
120 if (!isset($_GET['add'])) {
121 //all tax
122 ?>
123 <div class="wrap st_wrap st-manage-taxonomies-page">
124
125 <div id="">
126 <h1 class="wp-heading-inline"><?php esc_html_e('Auto Links', 'simple-tags'); ?></h1>
127 <a href="<?php echo esc_url(admin_url('admin.php?page=st_autolinks&add=new_item')); ?>"
128 class="page-title-action"><?php esc_html_e('Add New', 'simple-tags'); ?></a>
129
130 <div class="taxopress-description"><?php esc_html_e('Auto Links can automatically create links to your defined terms. For example, if you have a term called “WordPress”, the Auto Links feature can find the word “WordPress” in your content and add links to the archive page for that term.', 'simple-tags'); ?></div>
131
132
133 <?php
134 if (isset($_REQUEST['s']) && $search = sanitize_text_field(wp_unslash($_REQUEST['s']))) {
135 /* translators: %s: search keywords */
136 printf(' <span class="subtitle">' . esc_html__('Search results for &#8220;%s&#8221;',
137 'simple-tags') . '</span>', esc_html($search));
138 }
139 ?>
140 <?php
141
142 //the terms table instance
143 $this->terms_table->prepare_items();
144 ?>
145
146
147 <hr class="wp-header-end">
148 <div id="ajax-response"></div>
149 <form class="search-form wp-clearfix st-taxonomies-search-form" method="get">
150 <?php $this->terms_table->search_box(esc_html__('Search Auto Links', 'simple-tags'), 'term'); ?>
151 </form>
152 <div class="clear"></div>
153
154 <div id="col-container" class="wp-clearfix">
155
156 <div class="col-wrap">
157 <form action="<?php echo esc_url(add_query_arg('', '')); ?>" method="post">
158 <?php $this->terms_table->display(); //Display the table ?>
159 </form>
160 <div class="form-wrap edit-term-notes">
161 <p><?php esc_html__('Description here.', 'simple-tags') ?></p>
162 </div>
163 </div>
164
165
166 </div>
167
168
169 </div>
170 <?php } else {
171 if ($_GET['add'] == 'new_item') {
172 //add/edit taxonomy
173 $this->taxopress_manage_autolinks();
174 echo '<div>';
175 }
176 } ?>
177
178
179 <?php SimpleTags_Admin::printAdminFooter(); ?>
180 </div>
181 <?php
182 }
183
184
185 /**
186 * Create our settings page output.
187 *
188 * @internal
189 */
190 public function taxopress_manage_autolinks()
191 {
192
193 $tab = (!empty($_GET) && !empty($_GET['action']) && 'edit' == $_GET['action']) ? 'edit' : 'new';
194 $tab_class = 'taxopress-' . $tab;
195 $current = null;
196
197 ?>
198
199 <div class="wrap <?php echo esc_attr($tab_class); ?>">
200
201 <?php
202
203 $autolinks = taxopress_get_autolink_data();
204 $autolink_edit = false;
205 $autolink_limit = false;
206
207 if ('edit' === $tab) {
208
209
210 $selected_autolink = taxopress_get_current_autolink();
211
212 if ($selected_autolink && array_key_exists($selected_autolink, $autolinks)) {
213 $current = $autolinks[$selected_autolink];
214 $autolink_edit = true;
215 }
216
217 }
218
219
220 if (!isset($current['title']) && count($autolinks) > 0 && apply_filters('taxopress_autolinks_create_limit',
221 true)) {
222 $autolink_limit = true;
223 }
224
225
226 $ui = new taxopress_admin_ui();
227 ?>
228
229
230 <div class="wrap <?php echo esc_attr($tab_class); ?>">
231 <h1><?php echo esc_html__('Manage Auto Links', 'simple-tags'); ?></h1>
232 <div class="wp-clearfix"></div>
233
234 <form method="post" action="">
235
236
237 <div class="tagcloudui st-tabbed">
238
239
240 <div class="autolinks-postbox-container">
241 <div id="poststuff">
242 <div class="taxopress-section postbox">
243 <div class="postbox-header">
244 <h2 class="hndle ui-sortable-handle">
245 <?php
246 if ($autolink_edit) {
247 $active_tab = ( isset($current['active_tab']) && !empty(trim($current['active_tab'])) ) ? $current['active_tab'] : 'autolink_general';
248 echo esc_html__('Edit Auto Links', 'simple-tags');
249 echo '<input type="hidden" name="edited_autolink" value="' . esc_attr($current['ID']) . '" />';
250 echo '<input type="hidden" name="taxopress_autolink[ID]" value="' . esc_attr($current['ID']) . '" />';
251 echo '<input type="hidden" name="taxopress_autolink[active_tab]" class="taxopress-active-subtab" value="'.esc_attr($active_tab).'" />';
252 } else {
253 $active_tab = 'autolink_general';
254 echo '<input type="hidden" name="taxopress_autolink[active_tab]" class="taxopress-active-subtab" value="" />';
255 echo esc_html__('Add new Auto Links', 'simple-tags');
256 }
257 ?>
258 </h2>
259 </div>
260 <div class="inside">
261 <div class="main">
262
263
264 <?php if ($autolink_limit) {
265 echo '<div class="st-taxonomy-content"><div class="taxopress-warning upgrade-pro">
266 <p>
267
268 <h2 style="margin-bottom: 5px;">' . esc_html__('To create more Auto Links, please upgrade to TaxoPress Pro.',
269 'simple-tags') . '</h2>
270 ' . esc_html__('With TaxoPress Pro, you can create unlimited Auto Links. You can create Auto Links for any taxonomy.',
271 'simple-tags') . '
272
273 </p>
274 </div></div>';
275
276 } else {
277 ?>
278
279
280 <ul class="taxopress-tab">
281 <li class="autolink_general_tab <?php echo $active_tab === 'autolink_general' ? 'active' : ''; ?>" data-content="autolink_general">
282 <a href="#autolink_general"><span><?php esc_html_e('General',
283 'simple-tags'); ?></span></a>
284 </li>
285
286 <li class="autolink_display_tab <?php echo $active_tab === 'autolink_display' ? 'active' : ''; ?>" data-content="autolink_display">
287 <a href="#autolink_display"><span><?php esc_html_e('Post Types',
288 'simple-tags'); ?></span></a>
289 </li>
290
291 <li class="autolink_control_tab <?php echo $active_tab === 'autolink_control' ? 'active' : ''; ?>" data-content="autolink_control">
292 <a href="#autolink_control"><span><?php esc_html_e('Control',
293 'simple-tags'); ?></span></a>
294 </li>
295
296 <li class="autolink_exceptions_tab <?php echo $active_tab === 'autolink_exceptions' ? 'active' : ''; ?>" data-content="autolink_exceptions">
297 <a href="#autolink_exceptions"><span><?php esc_html_e('Exceptions',
298 'simple-tags'); ?></span></a>
299 </li>
300
301 <li class="autolink_advanced_tab <?php echo $active_tab === 'autolink_advanced' ? 'active' : ''; ?>" data-content="autolink_advanced">
302 <a href="#autolink_advanced"><span><?php esc_html_e('Advanced',
303 'simple-tags'); ?></span></a>
304 </li>
305
306 </ul>
307
308 <div class="st-taxonomy-content taxopress-tab-content">
309
310
311 <table class="form-table taxopress-table autolink_general"
312 style="<?php echo $active_tab === 'autolink_general' ? '' : 'display:none;'; ?>">
313 <?php
314 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
315 echo $ui->get_tr_start();
316
317 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
318 echo $ui->get_th_start();
319 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
320 echo $ui->get_label('title', esc_html__('Title', 'simple-tags')) . $ui->get_required_span();
321 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
322 echo $ui->get_th_end() . $ui->get_td_start();
323 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
324 echo $ui->get_text_input([
325 'namearray' => 'taxopress_autolink',
326 'name' => 'title',
327 'textvalue' => isset($current['title']) ? esc_attr($current['title']) : '',
328 'maxlength' => '32',
329 'helptext' => '',
330 'required' => true,
331 'placeholder' => false,
332 'wrap' => false,
333 ]);
334
335
336 $options = [];
337 foreach (get_all_taxopress_taxonomies() as $_taxonomy) {
338 $_taxonomy = $_taxonomy->name;
339 $tax = get_taxonomy($_taxonomy);
340 if (empty($tax->labels->name)) {
341 continue;
342 }
343 if ($tax->name === 'post_tag') {
344 $options[] = [
345 'attr' => $tax->name,
346 'text' => $tax->labels->name. ' ('.$tax->name.')',
347 'default' => 'true',
348 ];
349 } else {
350 $options[] = [
351 'attr' => $tax->name,
352 'text' => $tax->labels->name. ' ('.$tax->name.')',
353 ];
354 }
355 }
356
357 $select = [
358 'options' => $options,
359 ];
360 $selected = isset($current) ? taxopress_disp_boolean($current['taxonomy']) : '';
361 $select['selected'] = !empty($selected) ? $current['taxonomy'] : '';
362 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
363 echo $ui->get_select_checkbox_input_main([
364 'namearray' => 'taxopress_autolink',
365 'name' => 'taxonomy',
366 'class' => 'st-post-taxonomy-select',
367 'labeltext' => esc_html__('Taxonomy', 'simple-tags'),
368 'required' => true,
369 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
370 ]);
371
372
373 $select = [
374 'options' => [
375 [
376 'attr' => 'none',
377 'text' => esc_attr__('Use case of text in content',
378 'simple-tags'),
379 'default' => 'true'
380 ],
381 [
382 'attr' => 'termcase',
383 'text' => esc_attr__('Use case of term', 'simple-tags')
384 ],
385 [
386 'attr' => 'uppercase',
387 'text' => esc_attr__('All uppercase', 'simple-tags')
388 ],
389 [
390 'attr' => 'lowercase',
391 'text' => esc_attr__('All lowercase', 'simple-tags')
392 ],
393 ],
394 ];
395 $selected = isset($current) ? taxopress_disp_boolean($current['autolink_case']) : '';
396 $select['selected'] = !empty($selected) ? $current['autolink_case'] : '';
397 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
398 echo $ui->get_select_number_select([
399 'namearray' => 'taxopress_autolink',
400 'name' => 'autolink_case',
401 'labeltext' => esc_html__('Auto Link case',
402 'simple-tags'),
403 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
404 ]);
405
406 $select = [
407 'options' => [
408 [
409 'attr' => 'post_content',
410 'text' => esc_attr__('Post Content', 'simple-tags'),
411 'default' => 'true'
412 ],
413 [
414 'attr' => 'post_title',
415 'text' => esc_attr__('Post Title', 'simple-tags')
416 ],
417 [
418 'attr' => 'posts',
419 'text' => esc_attr__('Post Content and Title',
420 'simple-tags')
421 ],
422 ],
423 ];
424 $selected = isset($current) ? taxopress_disp_boolean($current['autolink_display']) : '';
425 $select['selected'] = !empty($selected) ? $current['autolink_display'] : '';
426 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
427 echo $ui->get_select_number_select([
428 'namearray' => 'taxopress_autolink',
429 'name' => 'autolink_display',
430 'labeltext' => esc_html__('Auto Link areas',
431 'simple-tags'),
432 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
433 ]);
434
435 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
436 echo $ui->get_text_input([
437 'namearray' => 'taxopress_autolink',
438 'name' => 'autolink_title_attribute',
439 'textvalue' => isset($current['autolink_title_attribute']) ? esc_attr($current['autolink_title_attribute']) : 'Posts tagged with %s',
440 'labeltext' => esc_html__('Auto Link title attribute',
441 'simple-tags'),
442 'helptext' => '',
443 'required' => false,
444 ]);
445
446
447
448 $select = [
449 'options' => [
450 [
451 'attr' => '0',
452 'text' => esc_attr__('False', 'simple-tags'),
453 'default' => 'true',
454 ],
455 [
456 'attr' => '1',
457 'text' => esc_attr__('True', 'simple-tags'),
458 ],
459 ],
460 ];
461 $selected = (isset($current) && isset($current['unattached_terms'])) ? taxopress_disp_boolean($current['unattached_terms']) : '';
462 $select['selected'] = !empty($selected) ? $current['unattached_terms'] : '';
463 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
464 echo $ui->get_select_checkbox_input([
465 'namearray' => 'taxopress_autolink',
466 'name' => 'unattached_terms',
467 'labeltext' => esc_html__('Add links for unattached terms',
468 'simple-tags'),
469 'aftertext' => esc_html__('By default, TaxoPress will only add Auto Links for terms that are attached to the post. If this box is checked, TaxoPress will add links for all terms.',
470 'simple-tags'),
471 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
472 ]);
473
474
475 $select = [
476 'options' => [
477 [
478 'attr' => '0',
479 'text' => esc_attr__('False', 'simple-tags'),
480 'default' => 'true',
481 ],
482 [
483 'attr' => '1',
484 'text' => esc_attr__('True', 'simple-tags'),
485 ],
486 ],
487 ];
488 $selected = (isset($current) && isset($current['ignore_attached'])) ? taxopress_disp_boolean($current['ignore_attached']) : '';
489 $select['selected'] = !empty($selected) ? $current['ignore_attached'] : '';
490 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
491 echo $ui->get_select_checkbox_input([
492 'namearray' => 'taxopress_autolink',
493 'name' => 'ignore_attached',
494 'labeltext' => esc_html__('Don\'t add links for attached terms',
495 'simple-tags'),
496 'aftertext' => esc_html__('Don\'t add Auto Links if the term is already attached to the post.',
497 'simple-tags'),
498 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
499 ]);
500
501 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
502 echo $ui->get_td_end() . $ui->get_tr_end();
503 ?>
504 </table>
505
506
507 <table class="form-table taxopress-table autolink_display"
508 style="<?php echo $active_tab === 'autolink_display' ? '' : 'display:none;'; ?>">
509 <?php
510
511
512 /**
513 * Filters the arguments for post types to list for taxonomy association.
514 *
515 *
516 * @param array $value Array of default arguments.
517 */
518 $args = apply_filters('taxopress_attach_post_types_to_taxonomy',
519 ['public' => true]);
520
521 // 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.
522 if (!is_array($args)) {
523 $args = ['public' => true];
524 }
525 $output = 'objects'; // Or objects.
526
527 /**
528 * Filters the results returned to display for available post types for taxonomy.
529 *
530 * @param array $value Array of post type objects.
531 * @param array $args Array of arguments for the post type query.
532 * @param string $output The output type we want for the results.
533 */
534 $post_types = apply_filters('taxopress_get_post_types_for_taxonomies',
535 get_post_types($args, $output), $args, $output);
536
537 $term_auto_locations = [];
538 foreach ($post_types as $post_type) {
539 $term_auto_locations[$post_type->name] = $post_type->label;
540 }
541
542 echo '<tr valign="top"><th scope="row"><label>' . esc_html__('Enable this Auto Links instance for:',
543 'simple-tags') . '</label><br /><small style=" color: #646970;">' . esc_html__('TaxoPress will attempt to automatically insert Auto Links in this content. It may not be successful for all post types and layouts.',
544 'simple-tags') . '</small></th><td>
545 <table class="visbile-table">';
546 foreach ($term_auto_locations as $key => $value) {
547
548
549 echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($key) . '">' . esc_html($value) . '</label></th><td>';
550 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
551 echo $ui->get_check_input([
552 'checkvalue' => $key,
553 'checked' => (!empty($current['embedded']) && is_array($current['embedded']) && in_array($key,
554 $current['embedded'], true)) ? 'true' : 'false',
555 'name' => esc_attr($key),
556 'namearray' => 'embedded',
557 'textvalue' => esc_attr($key),
558 'labeltext' => "",
559 'wrap' => false,
560 ]);
561
562 echo '</td></tr>';
563
564
565 }
566 echo '</table></td></tr>';
567
568
569 ?>
570
571 </table>
572
573
574 <table class="form-table taxopress-table autolink_control"
575 style="<?php echo $active_tab === 'autolink_control' ? '' : 'display:none;'; ?>">
576 <?php
577 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
578 echo $ui->get_number_input([
579 'namearray' => 'taxopress_autolink',
580 'name' => 'autolink_usage_min',
581 'textvalue' => isset($current['autolink_usage_min']) ? esc_attr($current['autolink_usage_min']) : '1',
582 'labeltext' => esc_html__('Minimum term usage for Auto Links',
583 'simple-tags'),
584 'helptext' => esc_html__('To be included in Auto Links, a term must be used at least this many times.',
585 'simple-tags'),
586 'min' => '1',
587 'required' => true,
588 ]);
589
590 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
591 echo $ui->get_number_input([
592 'namearray' => 'taxopress_autolink',
593 'name' => 'autolink_usage_max',
594 'textvalue' => isset($current['autolink_usage_max']) ? esc_attr($current['autolink_usage_max']) : '10',
595 'labeltext' => esc_html__('Maximum number of links per post',
596 'simple-tags'),
597 'helptext' => esc_html__('This setting determines the maximum number of Auto Links in one post.',
598 'simple-tags'),
599 'min' => '1',
600 'required' => true,
601 ]);
602
603 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
604 echo $ui->get_number_input([
605 'namearray' => 'taxopress_autolink',
606 'name' => 'autolink_same_usage_max',
607 'textvalue' => isset($current['autolink_same_usage_max']) ? esc_attr($current['autolink_same_usage_max']) : '1',
608 'labeltext' => esc_html__('Maximum number of links for the same term',
609 'simple-tags'),
610 'helptext' => esc_html__('This setting determines the maximum number of Auto Links for each term in one post.',
611 'simple-tags'),
612 'min' => '1',
613 'required' => true,
614 ]);
615
616 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
617 echo $ui->get_number_input([
618 'namearray' => 'taxopress_autolink',
619 'name' => 'autolink_min_char',
620 'textvalue' => isset($current['autolink_min_char']) ? esc_attr($current['autolink_min_char']) : '',
621 'labeltext' => esc_html__('Minimum character length for an Auto Link',
622 'simple-tags'),
623 'helptext' => esc_html__('For example, \'4\' would only link terms that are of 4 characters or more in length.',
624 'simple-tags'),
625 'min' => '0',
626 'required' => false,
627 ]);
628
629 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
630 echo $ui->get_number_input([
631 'namearray' => 'taxopress_autolink',
632 'name' => 'autolink_max_char',
633 'textvalue' => isset($current['autolink_max_char']) ? esc_attr($current['autolink_max_char']) : '',
634 'labeltext' => esc_html__('Maximum character length for an Auto Link',
635 'simple-tags'),
636 'helptext' => esc_html__('For example, \'4\' would only link terms that are of 4 characters or less in length.',
637 'simple-tags'),
638 'min' => '0',
639 'required' => false,
640 ]);
641
642
643 ?>
644
645 </table>
646
647
648 <table class="form-table taxopress-table autolink_exceptions"
649 style="<?php echo $active_tab === 'autolink_exceptions' ? '' : 'display:none;'; ?>">
650 <?php
651 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
652 echo $ui->get_text_input([
653 'namearray' => 'taxopress_autolink',
654 'name' => 'auto_link_exclude',
655 'textvalue' => isset($current['auto_link_exclude']) ? esc_attr($current['auto_link_exclude']) : '',
656 'labeltext' => esc_html__('Exclude terms from Auto Links',
657 'simple-tags'),
658 'helptext' => esc_html__('If you enter the terms "WordPress", "Website" the Auto Links feature will never replace these terms. Separate multiple entries with a comma.',
659 'simple-tags'),
660 'required' => false,
661 ]);
662
663 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
664 echo $ui->get_text_input([
665 'namearray' => 'taxopress_autolink',
666 'name' => 'autolink_exclude_class',
667 'textvalue' => isset($current['autolink_exclude_class']) ? esc_attr($current['autolink_exclude_class']) : '',
668 'labeltext' => esc_html__('Prevent Auto Links inside classes or IDs',
669 'simple-tags'),
670 'helptext' => esc_html__('Separate multiple entries with a comma. For example: .notag, #main-header',
671 'simple-tags'),
672 'required' => false,
673 ]);
674
675 $html_exclusions = [
676 //headers
677 'h1' => esc_attr__('H1', 'simple-tags'),
678 'h2' => esc_attr__('H2', 'simple-tags'),
679 'h3' => esc_attr__('H3', 'simple-tags'),
680 'h4' => esc_attr__('H4', 'simple-tags'),
681 'h5' => esc_attr__('H5', 'simple-tags'),
682 'h6' => esc_attr__('H6', 'simple-tags'),
683 //html elements
684 'script' => esc_attr__('script', 'simple-tags'),
685 'style' => esc_attr__('style', 'simple-tags'),
686 'pre' => esc_attr__('pre', 'simple-tags'),
687 'code' => esc_attr__('code', 'simple-tags'),
688 ];
689
690 echo '<tr valign="top"><th scope="row"><label>' . esc_html__('Prevent Auto Links inside elements',
691 'simple-tags') . '</label><br /><small style=" color: #646970;">' . esc_html__('Terms inside these html tags will not be auto link.',
692 'simple-tags') . '</small></th><td>
693 <table class="visbile-table st-html-exclusion-table">';
694 foreach ($html_exclusions as $key => $value) {
695
696 echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($key) . '">' . esc_html($value) . '</label></th><td>';
697
698 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
699 echo $ui->get_check_input([
700 'checkvalue' => $key,
701 'checked' => (!empty($current['html_exclusion']) && is_array($current['html_exclusion']) && in_array($key,
702 $current['html_exclusion'],
703 true)) ? 'true' : 'false',
704 'name' => esc_attr($key),
705 'namearray' => 'html_exclusion',
706 'textvalue' => esc_attr($key),
707 'labeltext' => esc_html($key),
708 'labeldescription' => true,
709 'wrap' => false,
710 ]);
711
712 echo '</td></tr>';
713
714 if ($key === 'h6') {
715 echo '<tr valign="top"><th style="padding: 0;" scope="row"><hr /></th><td style="padding: 0;"><hr /></td></tr>';
716 }
717
718
719 }
720 echo '</table></td></tr>';
721
722 ?>
723
724 </table>
725
726
727 <table class="form-table taxopress-table autolink_advanced"
728 style="<?php echo $active_tab === 'autolink_advanced' ? '' : 'display:none;'; ?>">
729 <?php
730 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
731 echo $ui->get_text_input([
732 'namearray' => 'taxopress_autolink',
733 'name' => 'link_class',
734 'class' => '',
735 'textvalue' => isset($current['link_class']) ? esc_attr($current['link_class']) : '',
736 'labeltext' => esc_html__('Term link class', 'simple-tags'),
737 'helptext' => '',
738 'required' => false,
739 ]);
740
741 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
742 echo $ui->get_number_input([
743 'namearray' => 'taxopress_autolink',
744 'name' => 'hook_priority',
745 'textvalue' => isset($current['hook_priority']) ? esc_attr($current['hook_priority']) : '12',
746 'labeltext' => esc_html__('Priority on the_content and the_title hook',
747 'simple-tags'),
748 'helptext' => esc_html__('Change the priority of the Auto Links functions on the_content hook. This is useful for fixing conflicts with other plugins. Higher number means autolink will be executed only after hooks with lower number has been executed.',
749 'simple-tags'),
750 'min' => '1',
751 'required' => false,
752 ]);
753
754 $select = [
755 'options' => [
756 [
757 'attr' => '0',
758 'text' => esc_attr__('False', 'simple-tags'),
759 ],
760 [
761 'attr' => '1',
762 'text' => esc_attr__('True', 'simple-tags'),
763 'default' => 'true',
764 ],
765 ],
766 ];
767 $selected = (isset($current) && isset($current['autolink_dom'])) ? taxopress_disp_boolean($current['autolink_dom']) : '';
768 $select['selected'] = !empty($selected) ? $current['autolink_dom'] : '';
769
770 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
771 echo $ui->get_select_checkbox_input([
772 'namearray' => 'taxopress_autolink',
773 'name' => 'autolink_dom',
774 'labeltext' => esc_html__('Use new Auto Links engine',
775 'simple-tags'),
776 'aftertext' => esc_html__('The new Auto Links engine uses the DOMDocument PHP class and may offer better performance. If your server does not support this functionality, TaxoPress will use the usual engine.',
777 'simple-tags'),
778 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
779 ]);
780
781 ?>
782 </table>
783
784
785 </div>
786
787
788 <?php }//end new fields
789 ?>
790
791
792 <div class="clear"></div>
793
794
795 </div>
796 </div>
797 </div>
798
799
800 <?php if ($autolink_limit) { ?>
801
802 <div class="pp-version-notice-bold-purple" style="margin-left:0px;">
803 <div class="pp-version-notice-bold-purple-message"><?php esc_html_e('You\'re using TaxoPress Free.
804 The Pro version has more features and support.', 'simple-tags'); ?>
805 </div>
806 <div class="pp-version-notice-bold-purple-button"><a
807 href="https://taxopress.com/pro" target="_blank"><?php esc_html_e('Upgrade to Pro', 'simple-tags'); ?></a>
808 </div>
809 </div>
810
811 <?php } ?>
812 <?php
813 /**
814 * Fires after the default fieldsets on the taxonomy screen.
815 *
816 * @param taxopress_admin_ui $ui Admin UI instance.
817 */
818 do_action('taxopress_taxonomy_after_fieldsets', $ui);
819 ?>
820
821 </div>
822 </div>
823
824
825 </div>
826
827 <div class="taxopress-right-sidebar">
828 <div class="taxopress-right-sidebar-wrapper" style="min-height: 205px;">
829
830
831 <?php
832 if (!$autolink_limit) { ?>
833 <p class="submit">
834
835 <?php
836 wp_nonce_field('taxopress_addedit_autolink_nonce_action',
837 'taxopress_addedit_autolink_nonce_field');
838 if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?>
839 <input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-autolink-submit"
840 name="autolink_submit"
841 value="<?php echo esc_attr(esc_attr__('Save Auto Links',
842 'simple-tags')); ?>"/>
843 <?php
844 } else { ?>
845 <input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-autolink-submit"
846 name="autolink_submit"
847 value="<?php echo esc_attr(esc_attr__('Add Auto Links',
848 'simple-tags')); ?>"/>
849 <?php } ?>
850
851
852 <input type="hidden" name="cpt_tax_status" id="cpt_tax_status"
853 value="<?php echo esc_attr($tab); ?>"/>
854 </p>
855
856 <?php
857 }
858 ?>
859
860 </div>
861
862 <?php do_action('taxopress_admin_after_sidebar'); ?>
863 </div>
864
865 <div class="clear"></div>
866
867
868
869 </form>
870
871 </div><!-- End .wrap -->
872
873 <div class="clear"></div>
874
875 <?php # Modal Windows; ?>
876 <div class="remodal" data-remodal-id="taxopress-modal-alert"
877 data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
878 <div class="" style="color:red;"><?php echo esc_html__('Please complete the following required fields to save your changes:', 'simple-tags'); ?></div>
879 <div id="taxopress-modal-alert-content"></div>
880 <br>
881 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('Okay', 'simple-tags'); ?></button>
882 </div>
883
884 <div class="remodal" data-remodal-id="taxopress-modal-confirm"
885 data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
886 <div id="taxopress-modal-confirm-content"></div>
887 <br>
888 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('No', 'simple-tags'); ?></button>
889 <button data-remodal-action="confirm"
890 class="remodal-confirm"><?php echo esc_html__('Yes', 'simple-tags'); ?></button>
891 </div>
892
893 <?php
894 }
895
896 }
897