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

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

1,174 lines 85.0 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 * Init somes JS and CSS need for this feature
33 *
34 * @return void
35 * @author Olatechpro
36 */
37 public static function admin_enqueue_scripts()
38 {
39
40 // add JS for manage click tags
41 if (isset($_GET['page']) && $_GET['page'] == 'st_autolinks') {
42 wp_enqueue_style('st-taxonomies-css');
43 }
44 }
45
46 public static function set_screen($status, $option, $value)
47 {
48 return $value;
49 }
50
51 /** Singleton instance */
52 public static function get_instance()
53 {
54 if (!isset(self::$instance)) {
55 self::$instance = new self();
56 }
57
58 return self::$instance;
59 }
60
61 /**
62 * Add WP admin menu for Tags
63 *
64 * @return void
65 * @author Olatechpro
66 */
67 public function admin_menu()
68 {
69 $hook = add_submenu_page(
70 self::MENU_SLUG,
71 esc_html__('Auto Links', 'simple-tags'),
72 esc_html__('Auto Links', 'simple-tags'),
73 'simple_tags',
74 'st_autolinks',
75 [
76 $this,
77 'page_manage_autolinks',
78 ]
79 );
80
81 if (taxopress_is_screen_main_page()) {
82 add_action("load-$hook", [$this, 'screen_option']);
83 }
84 }
85
86 /**
87 * Screen options
88 */
89 public function screen_option()
90 {
91
92 $option = 'per_page';
93 $args = [
94 'label' => esc_html__('Number of items per page', 'simple-tags'),
95 'default' => 20,
96 'option' => 'st_autolinks_per_page'
97 ];
98
99 add_screen_option($option, $args);
100
101 $this->terms_table = new Autolinks_List();
102 }
103
104 /**
105 * Method for build the page HTML manage tags
106 *
107 * @return void
108 * @author Olatechpro
109 */
110 public function page_manage_autolinks()
111 {
112 // Default order
113 if (!isset($_GET['order'])) {
114 $_GET['order'] = 'name-asc';
115 }
116
117 settings_errors(__CLASS__);
118
119 if (!isset($_GET['add'])) {
120 //all tax
121 ?>
122 <div class="wrap st_wrap st-manage-taxonomies-page">
123
124 <div id="">
125 <h1 class="wp-heading-inline"><?php esc_html_e('Auto Links', 'simple-tags'); ?></h1>
126 <a href="<?php echo esc_url(admin_url('admin.php?page=st_autolinks&add=new_item')); ?>"
127 class="page-title-action taxopress">
128 <span class="dashicons dashicons-lock"></span>
129 <?php esc_html_e('Add New Auto Link', 'simple-tags'); ?></a>
130
131 <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>
132
133
134 <?php
135 if (isset($_REQUEST['s']) && $search = sanitize_text_field(wp_unslash($_REQUEST['s']))) {
136 /* translators: %s: search keywords */
137 printf(' <span class="subtitle">' . esc_html__(
138 'Search results for &#8220;%s&#8221;',
139 'simple-tags'
140 ) . '</span>', esc_html($search));
141 }
142 ?>
143 <?php
144
145 //the terms table instance
146 $this->terms_table->prepare_items();
147 ?>
148
149
150 <hr class="wp-header-end">
151 <div id="ajax-response"></div>
152 <form class="search-form wp-clearfix st-taxonomies-search-form" method="get">
153 <?php $this->terms_table->search_box(esc_html__('Search Auto Links', 'simple-tags'), 'term'); ?>
154 </form>
155 <div class="clear"></div>
156
157 <div id="col-container" class="wp-clearfix">
158
159 <div class="col-wrap">
160 <form action="<?php echo esc_url(add_query_arg('', '')); ?>" method="post">
161 <?php $this->terms_table->display(); //Display the table
162 ?>
163 </form>
164 <div class="form-wrap edit-term-notes">
165 <p><?php esc_html__('Description here.', 'simple-tags') ?></p>
166 </div>
167 </div>
168
169
170 </div>
171
172
173 </div>
174 <?php } else {
175 if ($_GET['add'] == 'new_item') {
176 //add/edit taxonomy
177 $this->taxopress_manage_autolinks();
178 echo '<div>';
179 }
180 } ?>
181
182
183 <?php SimpleTags_Admin::printAdminFooter(); ?>
184 </div>
185 <?php
186 }
187
188
189 /**
190 * Create our settings page output.
191 *
192 * @internal
193 */
194 public function taxopress_manage_autolinks()
195 {
196
197 $tab = (!empty($_GET) && !empty($_GET['action']) && 'edit' == $_GET['action']) ? 'edit' : 'new';
198 $tab_class = 'taxopress-' . $tab;
199 $current = null;
200
201 ?>
202
203 <div class="wrap <?php echo esc_attr($tab_class); ?>">
204
205 <?php
206
207 $autolinks = taxopress_get_autolink_data();
208 $autolink_edit = false;
209 $autolink_limit = false;
210
211 if ('edit' === $tab) {
212
213
214 $selected_autolink = taxopress_get_current_autolink();
215
216 if ($selected_autolink && array_key_exists($selected_autolink, $autolinks)) {
217 $current = $autolinks[$selected_autolink];
218 $autolink_edit = true;
219 }
220 }
221
222
223 if (!isset($current['title']) && count($autolinks) > 0 && apply_filters(
224 'taxopress_autolinks_create_limit',
225 true
226 )) {
227 $autolink_limit = true;
228 }
229
230
231 $ui = new taxopress_admin_ui();
232 ?>
233
234
235 <div class="wrap <?php echo esc_attr($tab_class); ?>">
236 <h1><?php echo esc_html__('Manage Auto Links', 'simple-tags'); ?></h1>
237 <div class="wp-clearfix"></div>
238
239 <form method="post" action="">
240
241
242 <div class="tagcloudui st-tabbed">
243
244
245 <div class="autolinks-postbox-container">
246 <div id="poststuff">
247 <div class="taxopress-section postbox">
248 <div class="postbox-header">
249 <h2 class="hndle ui-sortable-handle">
250 <?php
251 if ($autolink_edit) {
252 $active_tab = (isset($current['active_tab']) && !empty(trim($current['active_tab']))) ? $current['active_tab'] : 'autolink_general';
253 echo esc_html__('Edit Auto Links', 'simple-tags');
254 echo '<input type="hidden" name="edited_autolink" value="' . esc_attr($current['ID']) . '" />';
255 echo '<input type="hidden" name="taxopress_autolink[ID]" value="' . esc_attr($current['ID']) . '" />';
256 echo '<input type="hidden" name="taxopress_autolink[active_tab]" class="taxopress-active-subtab" value="' . esc_attr($active_tab) . '" />';
257 } else {
258 $active_tab = 'autolink_general';
259 echo '<input type="hidden" name="taxopress_autolink[active_tab]" class="taxopress-active-subtab" value="" />';
260 echo esc_html__('Add new Auto Links', 'simple-tags');
261 }
262 ?>
263 </h2>
264 </div>
265 <div class="inside">
266 <div class="main">
267
268
269 <?php if ($autolink_limit) {
270 echo '<div class="st-taxonomy-content promo-box-area"><div class="taxopress-warning upgrade-pro">
271
272 <h2 style="margin-bottom: 5px;">' . esc_html__(
273 'To create more Auto Links, please upgrade to TaxoPress Pro.',
274 'simple-tags'
275 ) . '</h2>
276 <p>
277 ' . esc_html__(
278 'With TaxoPress Pro, you can create unlimited Auto Links. You can create Auto Links for any taxonomy.',
279 'simple-tags'
280 ) . '
281
282 </p>
283 </div></div>';
284 } else {
285 ?>
286
287
288 <ul class="taxopress-tab">
289 <li aria-current="<?php echo $active_tab === 'autolink_general' ? 'true' : 'false'; ?>" class="autolink_general_tab <?php echo $active_tab === 'autolink_general' ? 'active' : ''; ?>" data-content="autolink_general">
290 <a href="#autolink_general"><span><?php esc_html_e(
291 'General',
292 'simple-tags'
293 ); ?></span></a>
294 </li>
295
296 <li aria-current="<?php echo $active_tab === 'autolink_display' ? 'true' : 'false'; ?>" class="autolink_display_tab <?php echo $active_tab === 'autolink_display' ? 'active' : ''; ?>" data-content="autolink_display">
297 <a href="#autolink_display"><span><?php esc_html_e(
298 'Post Types',
299 'simple-tags'
300 ); ?></span></a>
301 </li>
302
303 <li aria-current="<?php echo $active_tab === 'autolink_control' ? 'true' : 'false'; ?>" class="autolink_control_tab <?php echo $active_tab === 'autolink_control' ? 'active' : ''; ?>" data-content="autolink_control">
304 <a href="#autolink_control"><span><?php esc_html_e(
305 'Control',
306 'simple-tags'
307 ); ?></span></a>
308 </li>
309
310 <li aria-current="<?php echo $active_tab === 'autolink_exceptions' ? 'true' : 'false'; ?>" class="autolink_exceptions_tab <?php echo $active_tab === 'autolink_exceptions' ? 'active' : ''; ?>" data-content="autolink_exceptions">
311 <a href="#autolink_exceptions"><span><?php esc_html_e(
312 'Exceptions',
313 'simple-tags'
314 ); ?></span></a>
315 </li>
316
317 <li aria-current="<?php echo $active_tab === 'autolink_options' ? 'true' : 'false'; ?>" class="autolink_options_tab <?php echo $active_tab === 'autolink_options' ? 'active' : ''; ?>" data-content="autolink_options">
318 <a href="#autolink_options"><span><?php esc_html_e(
319 'Options',
320 'simple-tags'
321 ); ?></span></a>
322 </li>
323
324 <li aria-current="<?php echo $active_tab === 'autolink_advanced' ? 'true' : 'false'; ?>" class="autolink_advanced_tab <?php echo $active_tab === 'autolink_advanced' ? 'active' : ''; ?>" data-content="autolink_advanced">
325 <a href="#autolink_advanced"><span><?php esc_html_e(
326 'Advanced',
327 'simple-tags'
328 ); ?></span></a>
329 </li>
330
331 <li aria-current="<?php echo $active_tab === 'autolink_custom_url' ? 'true' : 'false'; ?>" class="autolink_custom_url_tab <?php echo $active_tab === 'autolink_custom_url' ? 'active' : ''; ?>" data-content="autolink_custom_url">
332 <a href="#autolink_custom_url"><span><?php esc_html_e('Link Types', 'simple-tags'); ?></span></a>
333 </li>
334
335 </ul>
336
337 <div class="st-taxonomy-content taxopress-tab-content">
338
339
340 <table class="form-table taxopress-table autolink_general" style="<?php echo $active_tab === 'autolink_general' ? '' : 'display:none;'; ?>">
341 <?php
342 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
343 echo $ui->get_tr_start();
344
345 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
346 echo $ui->get_th_start();
347 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
348 echo $ui->get_label('title', esc_html__('Title', 'simple-tags')) . $ui->get_required_span();
349 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
350 echo $ui->get_th_end() . $ui->get_td_start();
351 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
352 echo $ui->get_text_input([
353 'namearray' => 'taxopress_autolink',
354 'name' => 'title',
355 'textvalue' => isset($current['title']) ? esc_attr($current['title']) : '',
356 'maxlength' => '32',
357 'helptext' => '',
358 'required' => true,
359 'placeholder' => false,
360 'wrap' => false,
361 ]);
362
363
364 $options = [];
365 foreach (get_all_taxopress_taxonomies() as $_taxonomy) {
366 $_taxonomy = $_taxonomy->name;
367 $tax = get_taxonomy($_taxonomy);
368 if (empty($tax->labels->name)) {
369 continue;
370 }
371 if ($tax->name === 'post_tag') {
372 $options[] = [
373 'attr' => $tax->name,
374 'text' => $tax->labels->name . ' (' . $tax->name . ')',
375 'default' => 'true',
376 ];
377 } else {
378 $options[] = [
379 'attr' => $tax->name,
380 'text' => $tax->labels->name . ' (' . $tax->name . ')',
381 ];
382 }
383 }
384
385 $select = [
386 'options' => $options,
387 ];
388 $selected = isset($current) ? taxopress_disp_boolean($current['taxonomy']) : '';
389 $select['selected'] = !empty($selected) ? $current['taxonomy'] : '';
390 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
391 echo $ui->get_select_checkbox_input_main([
392 'namearray' => 'taxopress_autolink',
393 'name' => 'taxonomy',
394 'class' => 'taxopress-dynamic-taxonomy st-post-taxonomy-select',
395 'labeltext' => esc_html__('Taxonomy', 'simple-tags'),
396 'required' => true,
397 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
398 ]);
399
400
401 $select = [
402 'options' => [
403 [
404 'attr' => 'none',
405 'text' => esc_attr__(
406 'Use case of text in content',
407 'simple-tags'
408 ),
409 'default' => 'true'
410 ],
411 [
412 'attr' => 'termcase',
413 'text' => esc_attr__('Use case of term', 'simple-tags')
414 ],
415 [
416 'attr' => 'uppercase',
417 'text' => esc_attr__('All uppercase', 'simple-tags')
418 ],
419 [
420 'attr' => 'lowercase',
421 'text' => esc_attr__('All lowercase', 'simple-tags')
422 ],
423 ],
424 ];
425 $selected = isset($current) ? taxopress_disp_boolean($current['autolink_case']) : '';
426 $select['selected'] = !empty($selected) ? $current['autolink_case'] : '';
427 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
428 echo $ui->get_select_number_select([
429 'namearray' => 'taxopress_autolink',
430 'name' => 'autolink_case',
431 'labeltext' => esc_html__(
432 'Auto Link case',
433 'simple-tags'
434 ),
435 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
436 ]);
437
438 $select = [
439 'options' => [
440 [
441 'attr' => 'post_content',
442 'text' => esc_attr__('Post Content', 'simple-tags'),
443 'default' => 'true'
444 ],
445 [
446 'attr' => 'posts',
447 'text' => esc_attr__(
448 'Post Content and Title',
449 'simple-tags'
450 )
451 ],
452 ],
453 ];
454 $selected = isset($current) ? taxopress_disp_boolean($current['autolink_display']) : '';
455 $select['selected'] = !empty($selected) ? $current['autolink_display'] : '';
456 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
457 echo $ui->get_select_number_select([
458 'namearray' => 'taxopress_autolink',
459 'name' => 'autolink_display',
460 'labeltext' => esc_html__(
461 'Auto Link areas',
462 'simple-tags'
463 ),
464 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
465 ]);
466
467 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
468 echo $ui->get_text_input([
469 'namearray' => 'taxopress_autolink',
470 'name' => 'autolink_title_attribute',
471 'textvalue' => isset($current['autolink_title_attribute']) ? esc_attr($current['autolink_title_attribute']) : 'Posts tagged with %s',
472 'labeltext' => esc_html__(
473 'Auto Link title when linking to terms',
474 'simple-tags'
475 ),
476 'helptext' => '',
477 'required' => false,
478 ]);
479
480 echo $ui->get_text_input([
481 'namearray' => 'taxopress_autolink',
482 'name' => 'autolink_title_attribute_when_using_custom_url',
483 'textvalue' => isset($current['autolink_title_attribute_when_using_custom_url']) ? esc_attr($current['autolink_title_attribute_when_using_custom_url']) : 'Visit this URL for more on %s',
484 'labeltext' => esc_html__(
485 'Auto Link title attribute when using a custom URL',
486 'simple-tags'
487 ),
488 'helptext' => '',
489 'required' => false,
490 ]);
491
492 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
493 echo $ui->get_td_end() . $ui->get_tr_end();
494 ?>
495 </table>
496
497
498 <table class="form-table taxopress-table autolink_display" style="<?php echo $active_tab === 'autolink_display' ? '' : 'display:none;'; ?>">
499 <?php
500
501
502 /**
503 * Filters the arguments for post types to list for taxonomy association.
504 *
505 *
506 * @param array $value Array of default arguments.
507 */
508 $args = apply_filters(
509 'taxopress_attach_post_types_to_taxonomy',
510 ['public' => true]
511 );
512
513 // 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.
514 if (!is_array($args)) {
515 $args = ['public' => true];
516 }
517 $output = 'objects'; // Or objects.
518
519 /**
520 * Filters the results returned to display for available post types for taxonomy.
521 *
522 * @param array $value Array of post type objects.
523 * @param array $args Array of arguments for the post type query.
524 * @param string $output The output type we want for the results.
525 */
526 $post_types = apply_filters(
527 'taxopress_get_post_types_for_taxonomies',
528 get_post_types($args, $output),
529 $args,
530 $output
531 );
532
533 $term_auto_locations = [];
534 foreach ($post_types as $post_type) {
535 if (!in_array($post_type->name, ['attachment'])) {
536 $term_auto_locations[$post_type->name] = $post_type->label;
537 }
538 }
539
540 echo '<tr valign="top"><th scope="row"><label>' . esc_html__(
541 'Enable this Auto Links instance for:',
542 'simple-tags'
543 ) . '</label><br /><small style=" color: #646970;">' . esc_html__(
544 'TaxoPress will attempt to automatically insert Auto Links in this content. It may not be successful for all post types and layouts.',
545 'simple-tags'
546 ) . '</small></th><td>
547 <table class="visbile-table">';
548 foreach ($term_auto_locations as $key => $value) {
549
550
551 echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($key) . '">' . esc_html($value) . '</label></th><td>';
552 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
553 echo $ui->get_check_input([
554 'checkvalue' => $key,
555 'checked' => (!empty($current['embedded']) && is_array($current['embedded']) && in_array(
556 $key,
557 $current['embedded'],
558 true
559 )) ? 'true' : 'false',
560 'name' => esc_attr($key),
561 'namearray' => 'embedded',
562 'textvalue' => esc_attr($key),
563 'labeltext' => "",
564 'wrap' => false,
565 ]);
566
567 echo '</td></tr>';
568 }
569 echo '</table></td></tr>';
570
571
572 ?>
573
574 </table>
575
576
577 <table class="form-table taxopress-table autolink_control" style="<?php echo $active_tab === 'autolink_control' ? '' : 'display:none;'; ?>">
578 <?php
579 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
580 echo $ui->get_number_input([
581 'namearray' => 'taxopress_autolink',
582 'name' => 'autolink_usage_min',
583 'textvalue' => isset($current['autolink_usage_min']) ? esc_attr($current['autolink_usage_min']) : '1',
584 'labeltext' => esc_html__(
585 'Minimum term usage for Auto Links',
586 'simple-tags'
587 ),
588 'helptext' => esc_html__(
589 'To be included in Auto Links, a term must be used at least this many times.',
590 'simple-tags'
591 ),
592 'min' => '0',
593 'required' => true,
594 ]);
595
596 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
597 echo $ui->get_number_input([
598 'namearray' => 'taxopress_autolink',
599 'name' => 'autolink_usage_max',
600 'textvalue' => isset($current['autolink_usage_max']) ? esc_attr($current['autolink_usage_max']) : '10',
601 'labeltext' => esc_html__(
602 'Maximum number of links per post',
603 'simple-tags'
604 ),
605 'helptext' => esc_html__(
606 'This setting determines the maximum number of Auto Links in one post.',
607 'simple-tags'
608 ),
609 'min' => '1',
610 'required' => true,
611 ]);
612
613 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
614 echo $ui->get_number_input([
615 'namearray' => 'taxopress_autolink',
616 'name' => 'autolink_same_usage_max',
617 'textvalue' => isset($current['autolink_same_usage_max']) ? esc_attr($current['autolink_same_usage_max']) : '1',
618 'labeltext' => esc_html__(
619 'Maximum number of links for the same term',
620 'simple-tags'
621 ),
622 'helptext' => esc_html__(
623 'This setting determines the maximum number of Auto Links for each term in one post.',
624 'simple-tags'
625 ),
626 'min' => '1',
627 'required' => true,
628 ]);
629
630 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
631 echo $ui->get_number_input([
632 'namearray' => 'taxopress_autolink',
633 'name' => 'autolink_min_char',
634 'textvalue' => isset($current['autolink_min_char']) ? esc_attr($current['autolink_min_char']) : '',
635 'labeltext' => esc_html__(
636 'Minimum character length for an Auto Link',
637 'simple-tags'
638 ),
639 'helptext' => esc_html__(
640 'For example, \'4\' would only link terms that are of 4 characters or more in length.',
641 'simple-tags'
642 ),
643 'min' => '0',
644 'required' => false,
645 ]);
646
647 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
648 echo $ui->get_number_input([
649 'namearray' => 'taxopress_autolink',
650 'name' => 'autolink_max_char',
651 'textvalue' => isset($current['autolink_max_char']) ? esc_attr($current['autolink_max_char']) : '',
652 'labeltext' => esc_html__(
653 'Maximum character length for an Auto Link',
654 'simple-tags'
655 ),
656 'helptext' => esc_html__(
657 'For example, \'4\' would only link terms that are of 4 characters or less in length.',
658 'simple-tags'
659 ),
660 'min' => '0',
661 'required' => false,
662 ]);
663
664 $select = [
665 'options' => [
666 [
667 'attr' => '0',
668 'text' => esc_attr__('False', 'simple-tags'),
669 ],
670 [
671 'attr' => '1',
672 'text' => esc_attr__('True', 'simple-tags'),
673 'default' => 'true',
674 ],
675 ],
676 ];
677 $selected = (isset($current) && isset($current['whole_words'])) ? taxopress_disp_boolean($current['whole_words']) : '';
678 $select['selected'] = !empty($selected) ? $current['whole_words'] : '';
679 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
680 echo $ui->get_select_checkbox_input([
681 'namearray' => 'taxopress_autolink',
682 'name' => 'whole_words',
683 'labeltext' => esc_html__(
684 'Whole words only',
685 'simple-tags'
686 ),
687 'aftertext' => esc_html__(
688 'Only add links when the term is an exact whole word match. Do not autolink partial matches.',
689 'simple-tags'
690 ),
691 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
692 ]);
693
694
695 ?>
696
697 </table>
698
699
700 <table class="form-table taxopress-table autolink_exceptions fixed" style="<?php echo $active_tab === 'autolink_exceptions' ? '' : 'display:none;'; ?>">
701 <?php
702 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
703 echo $ui->get_textarea_input([
704 'namearray' => 'taxopress_autolink',
705 'name' => 'auto_link_exclude',
706 'rows' => '4',
707 'cols' => '40',
708 'class' => 'autocomplete-input',
709 'textvalue' => isset($current['auto_link_exclude']) ? esc_attr($current['auto_link_exclude']) : '',
710 'labeltext' => esc_html__(
711 'Exclude terms from Auto Links',
712 'simple-tags'
713 ),
714 'helptext' => esc_html__(
715 'If you enter the terms "WordPress", "Website" the Auto Links feature will never replace these terms. Separate multiple entries with a comma.',
716 'simple-tags'
717 ),
718 'required' => false,
719 ]);
720
721 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
722 echo $ui->get_text_input([
723 'namearray' => 'taxopress_autolink',
724 'name' => 'autolink_exclude_class',
725 'textvalue' => isset($current['autolink_exclude_class']) ? esc_attr($current['autolink_exclude_class']) : '',
726 'labeltext' => esc_html__(
727 'Prevent Auto Links inside classes or IDs',
728 'simple-tags'
729 ),
730 'helptext' => esc_html__(
731 'Separate multiple entries with a comma. For example: .notag, #main-header',
732 'simple-tags'
733 ),
734 'required' => false,
735 ]);
736
737 $html_exclusions = [
738 //headers
739 'h1' => esc_attr__('H1', 'simple-tags'),
740 'h2' => esc_attr__('H2', 'simple-tags'),
741 'h3' => esc_attr__('H3', 'simple-tags'),
742 'h4' => esc_attr__('H4', 'simple-tags'),
743 'h5' => esc_attr__('H5', 'simple-tags'),
744 'h6' => esc_attr__('H6', 'simple-tags'),
745 //html elements
746 'script' => esc_attr__('script', 'simple-tags'),
747 'style' => esc_attr__('style', 'simple-tags'),
748 'pre' => esc_attr__('pre', 'simple-tags'),
749 'code' => esc_attr__('code', 'simple-tags'),
750 ];
751
752 echo '<tr valign="top"><th scope="row"><label>' . esc_html__(
753 'Prevent Auto Links inside elements',
754 'simple-tags'
755 ) . '</label><br /><small style=" color: #646970;">' . esc_html__(
756 'Terms inside these HTML tags will not have Auto Links applied.',
757 'simple-tags'
758 ) . '</small></th><td>
759 <table class="visbile-table st-html-exclusion-table">';
760 foreach ($html_exclusions as $key => $value) {
761
762 echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($key) . '">' . esc_html($value) . '</label></th><td>';
763
764 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
765 echo $ui->get_check_input([
766 'checkvalue' => $key,
767 'checked' => (!empty($current['html_exclusion']) && is_array($current['html_exclusion']) && in_array(
768 $key,
769 $current['html_exclusion'],
770 true
771 )) ? 'true' : 'false',
772 'name' => esc_attr($key),
773 'namearray' => 'html_exclusion',
774 'textvalue' => esc_attr($key),
775 'labeltext' => esc_html($key),
776 'labeldescription' => true,
777 'wrap' => false,
778 ]);
779
780 echo '</td></tr>';
781
782 if ($key === 'h6') {
783 echo '<tr valign="top"><th style="padding: 0;" scope="row"><hr /></th><td style="padding: 0;"><hr /></td></tr>';
784 }
785 }
786
787 /**
788 * Fires after the autolinks html_exclusions.
789 * @param $current array
790 * @param taxopress_admin_ui $ui Admin UI instance.
791 */
792 do_action('taxopress_autolinks_after_html_exclusions', $current, $ui);
793
794 echo '</table></td></tr>';
795
796 /**
797 * Fires after the autolinks html_exclusions tr.
798 * @param $current array
799 * @param taxopress_admin_ui $ui Admin UI instance.
800 */
801 do_action('taxopress_autolinks_after_html_exclusions_tr', $current, $ui);
802
803 ?>
804
805 </table>
806
807
808 <table class="form-table taxopress-table autolink_options" style="<?php echo $active_tab === 'autolink_options' ? '' : 'display:none;'; ?>">
809 <?php
810 if (taxopress_is_pro_version() && taxopress_is_synonyms_enabled()) {
811 $select = [
812 'options' => [
813 [
814 'attr' => '0',
815 'text' => esc_attr__('False', 'simple-tags'),
816 ],
817 [
818 'attr' => '1',
819 'text' => esc_attr__('True', 'simple-tags'),
820 'default' => 'true',
821 ],
822 ],
823 ];
824 $selected = (isset($current) && isset($current['synonyms_link'])) ? taxopress_disp_boolean($current['synonyms_link']) : '';
825 $select['selected'] = !empty($selected) ? $current['synonyms_link'] : '';
826
827 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
828 echo $ui->get_select_checkbox_input([
829 'namearray' => 'taxopress_autolink',
830 'name' => 'synonyms_link',
831 'labeltext' => esc_html__(
832 'Add links to synonyms',
833 'simple-tags'
834 ),
835 'aftertext' => esc_html__(
836 'Add links to the term synonyms.',
837 'simple-tags'
838 ),
839 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
840 ]);
841 }
842
843
844 $select = [
845 'options' => [
846 [
847 'attr' => '0',
848 'text' => esc_attr__('False', 'simple-tags'),
849 'default' => 'true',
850 ],
851 [
852 'attr' => '1',
853 'text' => esc_attr__('True', 'simple-tags'),
854 ],
855 ],
856 ];
857 $selected = (isset($current) && isset($current['unattached_terms'])) ? taxopress_disp_boolean($current['unattached_terms']) : '';
858 $select['selected'] = !empty($selected) ? $current['unattached_terms'] : '';
859 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
860 echo $ui->get_select_checkbox_input([
861 'namearray' => 'taxopress_autolink',
862 'name' => 'unattached_terms',
863 'labeltext' => esc_html__(
864 'Add links for all terms',
865 'simple-tags'
866 ),
867 'aftertext' => esc_html__(
868 'By default, TaxoPress will add links for all terms. If this box is unchecked, Auto Links will only add links for terms that are attached to the post.',
869 'simple-tags'
870 ),
871 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
872 ]);
873
874 ?>
875 <?php
876 $select = [
877 'options' => [
878 [
879 'attr' => '0',
880 'text' => esc_attr__('False', 'simple-tags'),
881 ],
882 [
883 'attr' => '1',
884 'text' => esc_attr__('True', 'simple-tags'),
885 'default' => 'true',
886 ],
887 ],
888 ];
889 $selected = (isset($current) && isset($current['autolink_dom'])) ? taxopress_disp_boolean($current['autolink_dom']) : '';
890 $select['selected'] = !empty($selected) ? $current['autolink_dom'] : '';
891
892 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
893 echo $ui->get_select_checkbox_input([
894 'namearray' => 'taxopress_autolink',
895 'name' => 'autolink_dom',
896 'labeltext' => esc_html__(
897 'Use new Auto Links engine',
898 'simple-tags'
899 ),
900 'aftertext' => esc_html__(
901 '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.',
902 'simple-tags'
903 ),
904 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
905 ]);
906 ?>
907 </table>
908
909 <table class="form-table taxopress-table autolink_custom_url" style="<?php echo $active_tab === 'autolink_custom_url' ? '' : 'display:none;'; ?>">
910 <?php
911
912
913 $select = [
914 'options' => [
915 [
916 'attr' => '1',
917 'text' => esc_attr__('True', 'simple-tags'),
918 'default' => 'true',
919 ],
920 [
921 'attr' => '0',
922 'text' => esc_attr__('False', 'simple-tags'),
923 ],
924 ],
925 ];
926 $selected = (isset($current) && isset($current['archivepage'])) ? taxopress_disp_boolean($current['archivepage']) : '';
927 $select['selected'] = !empty($selected) ? $current['archivepage'] : '';
928
929 echo $ui->get_select_checkbox_input([
930 'namearray' => 'taxopress_autolink',
931 'name' => 'archivepage',
932 'labeltext' => esc_html__('Enable Auto Link to archive pages', 'simple-tags'),
933 'aftertext' => esc_html__('When enabled, terms will be linked to the archive page for that term.', 'simple-tags'),
934 'selections' => $select,
935 ]);
936
937 $select = [
938 'options' => [
939 [
940 'attr' => '1',
941 'text' => esc_attr__('True', 'simple-tags'),
942 'default' => 'true',
943 ],
944 [
945 'attr' => '0',
946 'text' => esc_attr__('False', 'simple-tags'),
947 ],
948 ],
949 ];
950 $selected = (isset($current) && isset($current['enable_custom_urls'])) ? taxopress_disp_boolean($current['enable_custom_urls']) : '';
951 $select['selected'] = !empty($selected) ? $current['enable_custom_urls'] : '';
952
953 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
954 echo $ui->get_select_checkbox_input([
955 'namearray' => 'taxopress_autolink',
956 'name' => 'enable_custom_urls',
957 'labeltext' => esc_html__('Enable Custom URLs', 'simple-tags'),
958 'aftertext' => esc_html__('When enabled, terms can be linked to custom URLs instead of their archive pages.', 'simple-tags'),
959 'selections' => $select,
960 ]);
961 // Fetch all taxonomies
962 $all_taxonomies = get_taxonomies([], 'objects');
963
964 $selected_taxonomies = [];
965 if (isset($current['taxonomy'])) {
966 if (is_array($current['taxonomy'])) {
967 $selected_taxonomies = $current['taxonomy'];
968 } else {
969 $selected_taxonomies = [$current['taxonomy']];
970 }
971 }
972
973
974 if (!is_array($current) || !array_key_exists('enable_customurl_field', $current)) {
975 $enable_customurl_field = isset($_POST['taxopress_autolink']) ? [] : ['post_tag', 'category'];
976 } else {
977 $enable_customurl_field = is_array($current['enable_customurl_field']) ? $current['enable_customurl_field'] : [];
978 }
979
980 echo '<tr valign="top"><th scope="row"><label>' . esc_html__(
981 'Enable the Custom URL Field:',
982 'simple-tags'
983 ) . '</label><br /><small style=" color: #646970;">' . esc_html__(
984 'Enable the Custom URL field for this taxonomy.',
985 'simple-tags'
986 ) . '</small></th><td><table class="visbile-table">';
987
988 $enable_custom_urls = isset($current['enable_custom_urls']) && $current['enable_custom_urls'] == '1';
989
990 foreach ($all_taxonomies as $taxonomy) {
991 if (!in_array($taxonomy->name, $selected_taxonomies, true)) {
992 continue;
993 }
994 $disabled = !$enable_custom_urls ? 'disabled' : '';
995 echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($taxonomy->name) . '">' . esc_html($taxonomy->label) . '</label></th><td>';
996 echo $ui->get_check_input([
997 'checkvalue' => $taxonomy->name,
998 'checked' => in_array($taxonomy->name, $enable_customurl_field, true) ? 'true' : 'false',
999 'name' => esc_attr($taxonomy->name),
1000 'namearray' => 'taxopress_autolink[enable_customurl_field]',
1001 'textvalue' => esc_attr($taxonomy->name),
1002 'labeltext' => '',
1003 'wrap' => false,
1004 ]);
1005 echo '</td></tr>';
1006 }
1007 echo '</table></td></tr>';
1008 ?>
1009 </table>
1010
1011 <table class="form-table taxopress-table autolink_advanced" style="<?php echo $active_tab === 'autolink_advanced' ? '' : 'display:none;'; ?>">
1012 <?php
1013 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1014 echo $ui->get_text_input([
1015 'namearray' => 'taxopress_autolink',
1016 'name' => 'link_class',
1017 'class' => '',
1018 'textvalue' => isset($current['link_class']) ? esc_attr($current['link_class']) : '',
1019 'labeltext' => esc_html__('Term link class', 'simple-tags'),
1020 'helptext' => '',
1021 'required' => false,
1022 ]);
1023
1024 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
1025 echo $ui->get_number_input([
1026 'namearray' => 'taxopress_autolink',
1027 'name' => 'hook_priority',
1028 'textvalue' => isset($current['hook_priority']) ? esc_attr($current['hook_priority']) : '12',
1029 'labeltext' => esc_html__(
1030 'Priority on the_content and the_title hook',
1031 'simple-tags'
1032 ),
1033 'helptext' => esc_html__(
1034 '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.',
1035 'simple-tags'
1036 ),
1037 'min' => '1',
1038 'required' => false,
1039 ]);
1040
1041 ?>
1042 </table>
1043
1044
1045 </div>
1046
1047
1048 <?php } //end new fields
1049 ?>
1050
1051
1052 <div class="clear"></div>
1053
1054
1055 </div>
1056 </div>
1057 </div>
1058
1059
1060 <?php if ($autolink_limit) { ?>
1061
1062 <div class="pp-version-notice-bold-purple" style="margin-left:0px;">
1063 <div class="pp-version-notice-bold-purple-message"><?php esc_html_e('You\'re using TaxoPress Free.
1064 The Pro version has more features and support.', 'simple-tags'); ?>
1065 </div>
1066 <div class="pp-version-notice-bold-purple-button"><a href="https://taxopress.com/taxopress/" target="_blank"><?php esc_html_e('Upgrade to Pro', 'simple-tags'); ?></a>
1067 </div>
1068 </div>
1069
1070 <?php } ?>
1071 <?php
1072 /**
1073 * Fires after the default fieldsets on the taxonomy screen.
1074 *
1075 * @param taxopress_admin_ui $ui Admin UI instance.
1076 */
1077 do_action('taxopress_taxonomy_after_fieldsets', $ui);
1078 ?>
1079
1080 </div>
1081 </div>
1082
1083
1084 </div>
1085
1086 <div class="taxopress-right-sidebar">
1087 <div class="taxopress-right-sidebar-wrapper" style="min-height: 205px;<?php echo ($autolink_limit) ? 'display: none;' : ''; ?>">
1088
1089
1090 <?php
1091 if (!$autolink_limit) { ?>
1092 <p class="submit">
1093
1094 <?php
1095 wp_nonce_field(
1096 'taxopress_addedit_autolink_nonce_action',
1097 'taxopress_addedit_autolink_nonce_field'
1098 );
1099 if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?>
1100 <input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-autolink-submit" name="autolink_submit" value="<?php echo esc_attr(esc_attr__(
1101 'Save Auto Links',
1102 'simple-tags'
1103 )); ?>" />
1104 <?php
1105 } else { ?>
1106 <input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-autolink-submit" name="autolink_submit" value="<?php echo esc_attr(esc_attr__(
1107 'Add Auto Links',
1108 'simple-tags'
1109 )); ?>" />
1110 <?php } ?>
1111
1112
1113 <input type="hidden" name="cpt_tax_status" id="cpt_tax_status" value="<?php echo esc_attr($tab); ?>" />
1114 </p>
1115
1116 <?php
1117 }
1118 ?>
1119
1120 </div>
1121
1122 <?php do_action('taxopress_admin_after_sidebar'); ?>
1123 <div class="taxopress-advertisement-right-sidebar">
1124 <div id="postbox-container-1" class="postbox-container">
1125 <div class="meta-box-sortables">
1126 <div class="advertisement-box-content postbox">
1127 <div class="postbox-header">
1128 <h3 class="advertisement-box-header hndle is-non-sortable">
1129 <span><?php echo esc_html__('TaxoPress and Languages', 'simple-tags'); ?></span>
1130 </h3>
1131 </div>
1132 <div class="inside">
1133 <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>'); ?>
1134 </p>
1135 </div>
1136 </div>
1137 </div>
1138 </div>
1139 </div>
1140
1141
1142 </div>
1143
1144 <div class="clear"></div>
1145
1146
1147
1148 </form>
1149
1150 </div><!-- End .wrap -->
1151
1152 <div class="clear"></div>
1153
1154 <?php # Modal Windows;
1155 ?>
1156 <div class="remodal" data-remodal-id="taxopress-modal-alert" data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
1157 <div class="" style="color:red;"><?php echo esc_html__('Please complete the following required fields to save your changes:', 'simple-tags'); ?></div>
1158 <div id="taxopress-modal-alert-content"></div>
1159 <br>
1160 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('Okay', 'simple-tags'); ?></button>
1161 </div>
1162
1163 <div class="remodal" data-remodal-id="taxopress-modal-confirm" data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
1164 <div id="taxopress-modal-confirm-content"></div>
1165 <br>
1166 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('No', 'simple-tags'); ?></button>
1167 <button data-remodal-action="confirm" class="remodal-confirm"><?php echo esc_html__('Yes', 'simple-tags'); ?></button>
1168 </div>
1169
1170 <?php
1171 do_action( 'simpletags-autolinks');
1172 }
1173 }
1174