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

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

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