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

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

1,148 lines 82.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 * 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' => 'post_title',
447 'text' => esc_attr__('Post Title', 'simple-tags')
448 ],
449 [
450 'attr' => 'posts',
451 'text' => esc_attr__(
452 'Post Content and Title',
453 'simple-tags'
454 )
455 ],
456 ],
457 ];
458 $selected = isset($current) ? taxopress_disp_boolean($current['autolink_display']) : '';
459 $select['selected'] = !empty($selected) ? $current['autolink_display'] : '';
460 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
461 echo $ui->get_select_number_select([
462 'namearray' => 'taxopress_autolink',
463 'name' => 'autolink_display',
464 'labeltext' => esc_html__(
465 'Auto Link areas',
466 'simple-tags'
467 ),
468 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
469 ]);
470
471 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
472 echo $ui->get_text_input([
473 'namearray' => 'taxopress_autolink',
474 'name' => 'autolink_title_attribute',
475 'textvalue' => isset($current['autolink_title_attribute']) ? esc_attr($current['autolink_title_attribute']) : 'Posts tagged with %s',
476 'labeltext' => esc_html__(
477 'Auto Link title when linking to terms',
478 'simple-tags'
479 ),
480 'helptext' => '',
481 'required' => false,
482 ]);
483
484 echo $ui->get_text_input([
485 'namearray' => 'taxopress_autolink',
486 'name' => 'autolink_title_attribute_when_using_custom_url',
487 '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',
488 'labeltext' => esc_html__(
489 'Auto Link title attribute when using a custom URL',
490 'simple-tags'
491 ),
492 'helptext' => '',
493 'required' => false,
494 ]);
495
496 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
497 echo $ui->get_td_end() . $ui->get_tr_end();
498 ?>
499 </table>
500
501
502 <table class="form-table taxopress-table autolink_display" style="<?php echo $active_tab === 'autolink_display' ? '' : 'display:none;'; ?>">
503 <?php
504
505
506 /**
507 * Filters the arguments for post types to list for taxonomy association.
508 *
509 *
510 * @param array $value Array of default arguments.
511 */
512 $args = apply_filters(
513 'taxopress_attach_post_types_to_taxonomy',
514 ['public' => true]
515 );
516
517 // 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.
518 if (!is_array($args)) {
519 $args = ['public' => true];
520 }
521 $output = 'objects'; // Or objects.
522
523 /**
524 * Filters the results returned to display for available post types for taxonomy.
525 *
526 * @param array $value Array of post type objects.
527 * @param array $args Array of arguments for the post type query.
528 * @param string $output The output type we want for the results.
529 */
530 $post_types = apply_filters(
531 'taxopress_get_post_types_for_taxonomies',
532 get_post_types($args, $output),
533 $args,
534 $output
535 );
536
537 $term_auto_locations = [];
538 foreach ($post_types as $post_type) {
539 if (!in_array($post_type->name, ['attachment'])) {
540 $term_auto_locations[$post_type->name] = $post_type->label;
541 }
542 }
543
544 echo '<tr valign="top"><th scope="row"><label>' . esc_html__(
545 'Enable this Auto Links instance for:',
546 'simple-tags'
547 ) . '</label><br /><small style=" color: #646970;">' . esc_html__(
548 'TaxoPress will attempt to automatically insert Auto Links in this content. It may not be successful for all post types and layouts.',
549 'simple-tags'
550 ) . '</small></th><td>
551 <table class="visbile-table">';
552 foreach ($term_auto_locations as $key => $value) {
553
554
555 echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($key) . '">' . esc_html($value) . '</label></th><td>';
556 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
557 echo $ui->get_check_input([
558 'checkvalue' => $key,
559 'checked' => (!empty($current['embedded']) && is_array($current['embedded']) && in_array(
560 $key,
561 $current['embedded'],
562 true
563 )) ? 'true' : 'false',
564 'name' => esc_attr($key),
565 'namearray' => 'embedded',
566 'textvalue' => esc_attr($key),
567 'labeltext' => "",
568 'wrap' => false,
569 ]);
570
571 echo '</td></tr>';
572 }
573 echo '</table></td></tr>';
574
575
576 ?>
577
578 </table>
579
580
581 <table class="form-table taxopress-table autolink_control" style="<?php echo $active_tab === 'autolink_control' ? '' : 'display:none;'; ?>">
582 <?php
583 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
584 echo $ui->get_number_input([
585 'namearray' => 'taxopress_autolink',
586 'name' => 'autolink_usage_min',
587 'textvalue' => isset($current['autolink_usage_min']) ? esc_attr($current['autolink_usage_min']) : '1',
588 'labeltext' => esc_html__(
589 'Minimum term usage for Auto Links',
590 'simple-tags'
591 ),
592 'helptext' => esc_html__(
593 'To be included in Auto Links, a term must be used at least this many times.',
594 'simple-tags'
595 ),
596 'min' => '0',
597 'required' => true,
598 ]);
599
600 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
601 echo $ui->get_number_input([
602 'namearray' => 'taxopress_autolink',
603 'name' => 'autolink_usage_max',
604 'textvalue' => isset($current['autolink_usage_max']) ? esc_attr($current['autolink_usage_max']) : '10',
605 'labeltext' => esc_html__(
606 'Maximum number of links per post',
607 'simple-tags'
608 ),
609 'helptext' => esc_html__(
610 'This setting determines the maximum number of Auto Links in one post.',
611 'simple-tags'
612 ),
613 'min' => '1',
614 'required' => true,
615 ]);
616
617 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
618 echo $ui->get_number_input([
619 'namearray' => 'taxopress_autolink',
620 'name' => 'autolink_same_usage_max',
621 'textvalue' => isset($current['autolink_same_usage_max']) ? esc_attr($current['autolink_same_usage_max']) : '1',
622 'labeltext' => esc_html__(
623 'Maximum number of links for the same term',
624 'simple-tags'
625 ),
626 'helptext' => esc_html__(
627 'This setting determines the maximum number of Auto Links for each term in one post.',
628 'simple-tags'
629 ),
630 'min' => '1',
631 'required' => true,
632 ]);
633
634 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
635 echo $ui->get_number_input([
636 'namearray' => 'taxopress_autolink',
637 'name' => 'autolink_min_char',
638 'textvalue' => isset($current['autolink_min_char']) ? esc_attr($current['autolink_min_char']) : '',
639 'labeltext' => esc_html__(
640 'Minimum character length for an Auto Link',
641 'simple-tags'
642 ),
643 'helptext' => esc_html__(
644 'For example, \'4\' would only link terms that are of 4 characters or more in length.',
645 'simple-tags'
646 ),
647 'min' => '0',
648 'required' => false,
649 ]);
650
651 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
652 echo $ui->get_number_input([
653 'namearray' => 'taxopress_autolink',
654 'name' => 'autolink_max_char',
655 'textvalue' => isset($current['autolink_max_char']) ? esc_attr($current['autolink_max_char']) : '',
656 'labeltext' => esc_html__(
657 'Maximum character length for an Auto Link',
658 'simple-tags'
659 ),
660 'helptext' => esc_html__(
661 'For example, \'4\' would only link terms that are of 4 characters or less in length.',
662 'simple-tags'
663 ),
664 'min' => '0',
665 'required' => false,
666 ]);
667
668
669 ?>
670
671 </table>
672
673
674 <table class="form-table taxopress-table autolink_exceptions fixed" style="<?php echo $active_tab === 'autolink_exceptions' ? '' : 'display:none;'; ?>">
675 <?php
676 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
677 echo $ui->get_textarea_input([
678 'namearray' => 'taxopress_autolink',
679 'name' => 'auto_link_exclude',
680 'rows' => '4',
681 'cols' => '40',
682 'class' => 'autocomplete-input',
683 'textvalue' => isset($current['auto_link_exclude']) ? esc_attr($current['auto_link_exclude']) : '',
684 'labeltext' => esc_html__(
685 'Exclude terms from Auto Links',
686 'simple-tags'
687 ),
688 'helptext' => esc_html__(
689 'If you enter the terms "WordPress", "Website" the Auto Links feature will never replace these terms. Separate multiple entries with a comma.',
690 'simple-tags'
691 ),
692 'required' => false,
693 ]);
694
695 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
696 echo $ui->get_text_input([
697 'namearray' => 'taxopress_autolink',
698 'name' => 'autolink_exclude_class',
699 'textvalue' => isset($current['autolink_exclude_class']) ? esc_attr($current['autolink_exclude_class']) : '',
700 'labeltext' => esc_html__(
701 'Prevent Auto Links inside classes or IDs',
702 'simple-tags'
703 ),
704 'helptext' => esc_html__(
705 'Separate multiple entries with a comma. For example: .notag, #main-header',
706 'simple-tags'
707 ),
708 'required' => false,
709 ]);
710
711 $html_exclusions = [
712 //headers
713 'h1' => esc_attr__('H1', 'simple-tags'),
714 'h2' => esc_attr__('H2', 'simple-tags'),
715 'h3' => esc_attr__('H3', 'simple-tags'),
716 'h4' => esc_attr__('H4', 'simple-tags'),
717 'h5' => esc_attr__('H5', 'simple-tags'),
718 'h6' => esc_attr__('H6', 'simple-tags'),
719 //html elements
720 'script' => esc_attr__('script', 'simple-tags'),
721 'style' => esc_attr__('style', 'simple-tags'),
722 'pre' => esc_attr__('pre', 'simple-tags'),
723 'code' => esc_attr__('code', 'simple-tags'),
724 ];
725
726 echo '<tr valign="top"><th scope="row"><label>' . esc_html__(
727 'Prevent Auto Links inside elements',
728 'simple-tags'
729 ) . '</label><br /><small style=" color: #646970;">' . esc_html__(
730 'Terms inside these HTML tags will not have Auto Links applied.',
731 'simple-tags'
732 ) . '</small></th><td>
733 <table class="visbile-table st-html-exclusion-table">';
734 foreach ($html_exclusions as $key => $value) {
735
736 echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($key) . '">' . esc_html($value) . '</label></th><td>';
737
738 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
739 echo $ui->get_check_input([
740 'checkvalue' => $key,
741 'checked' => (!empty($current['html_exclusion']) && is_array($current['html_exclusion']) && in_array(
742 $key,
743 $current['html_exclusion'],
744 true
745 )) ? 'true' : 'false',
746 'name' => esc_attr($key),
747 'namearray' => 'html_exclusion',
748 'textvalue' => esc_attr($key),
749 'labeltext' => esc_html($key),
750 'labeldescription' => true,
751 'wrap' => false,
752 ]);
753
754 echo '</td></tr>';
755
756 if ($key === 'h6') {
757 echo '<tr valign="top"><th style="padding: 0;" scope="row"><hr /></th><td style="padding: 0;"><hr /></td></tr>';
758 }
759 }
760
761 /**
762 * Fires after the autolinks html_exclusions.
763 * @param $current array
764 * @param taxopress_admin_ui $ui Admin UI instance.
765 */
766 do_action('taxopress_autolinks_after_html_exclusions', $current, $ui);
767
768 echo '</table></td></tr>';
769
770 /**
771 * Fires after the autolinks html_exclusions tr.
772 * @param $current array
773 * @param taxopress_admin_ui $ui Admin UI instance.
774 */
775 do_action('taxopress_autolinks_after_html_exclusions_tr', $current, $ui);
776
777 ?>
778
779 </table>
780
781
782 <table class="form-table taxopress-table autolink_options" style="<?php echo $active_tab === 'autolink_options' ? '' : 'display:none;'; ?>">
783 <?php
784 if (taxopress_is_pro_version() && taxopress_is_synonyms_enabled()) {
785 $select = [
786 'options' => [
787 [
788 'attr' => '0',
789 'text' => esc_attr__('False', 'simple-tags'),
790 ],
791 [
792 'attr' => '1',
793 'text' => esc_attr__('True', 'simple-tags'),
794 'default' => 'true',
795 ],
796 ],
797 ];
798 $selected = (isset($current) && isset($current['synonyms_link'])) ? taxopress_disp_boolean($current['synonyms_link']) : '';
799 $select['selected'] = !empty($selected) ? $current['synonyms_link'] : '';
800
801 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
802 echo $ui->get_select_checkbox_input([
803 'namearray' => 'taxopress_autolink',
804 'name' => 'synonyms_link',
805 'labeltext' => esc_html__(
806 'Add links to synonyms',
807 'simple-tags'
808 ),
809 'aftertext' => esc_html__(
810 'Add links to the term synonyms.',
811 'simple-tags'
812 ),
813 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
814 ]);
815 }
816
817
818 $select = [
819 'options' => [
820 [
821 'attr' => '0',
822 'text' => esc_attr__('False', 'simple-tags'),
823 'default' => 'true',
824 ],
825 [
826 'attr' => '1',
827 'text' => esc_attr__('True', 'simple-tags'),
828 ],
829 ],
830 ];
831 $selected = (isset($current) && isset($current['unattached_terms'])) ? taxopress_disp_boolean($current['unattached_terms']) : '';
832 $select['selected'] = !empty($selected) ? $current['unattached_terms'] : '';
833 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
834 echo $ui->get_select_checkbox_input([
835 'namearray' => 'taxopress_autolink',
836 'name' => 'unattached_terms',
837 'labeltext' => esc_html__(
838 'Add links for all terms',
839 'simple-tags'
840 ),
841 'aftertext' => esc_html__(
842 '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.',
843 'simple-tags'
844 ),
845 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
846 ]);
847
848 ?>
849 <?php
850 $select = [
851 'options' => [
852 [
853 'attr' => '0',
854 'text' => esc_attr__('False', 'simple-tags'),
855 ],
856 [
857 'attr' => '1',
858 'text' => esc_attr__('True', 'simple-tags'),
859 'default' => 'true',
860 ],
861 ],
862 ];
863 $selected = (isset($current) && isset($current['autolink_dom'])) ? taxopress_disp_boolean($current['autolink_dom']) : '';
864 $select['selected'] = !empty($selected) ? $current['autolink_dom'] : '';
865
866 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
867 echo $ui->get_select_checkbox_input([
868 'namearray' => 'taxopress_autolink',
869 'name' => 'autolink_dom',
870 'labeltext' => esc_html__(
871 'Use new Auto Links engine',
872 'simple-tags'
873 ),
874 'aftertext' => esc_html__(
875 '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.',
876 'simple-tags'
877 ),
878 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
879 ]);
880 ?>
881 </table>
882
883 <table class="form-table taxopress-table autolink_custom_url" style="<?php echo $active_tab === 'autolink_custom_url' ? '' : 'display:none;'; ?>">
884 <?php
885
886
887 $select = [
888 'options' => [
889 [
890 'attr' => '1',
891 'text' => esc_attr__('True', 'simple-tags'),
892 'default' => 'true',
893 ],
894 [
895 'attr' => '0',
896 'text' => esc_attr__('False', 'simple-tags'),
897 ],
898 ],
899 ];
900 $selected = (isset($current) && isset($current['archivepage'])) ? taxopress_disp_boolean($current['archivepage']) : '';
901 $select['selected'] = !empty($selected) ? $current['archivepage'] : '';
902
903 echo $ui->get_select_checkbox_input([
904 'namearray' => 'taxopress_autolink',
905 'name' => 'archivepage',
906 'labeltext' => esc_html__('Enable Auto Link to archive pages', 'simple-tags'),
907 'aftertext' => esc_html__('When enabled, terms will be linked to the archive page for that term.', 'simple-tags'),
908 'selections' => $select,
909 ]);
910
911 $select = [
912 'options' => [
913 [
914 'attr' => '1',
915 'text' => esc_attr__('True', 'simple-tags'),
916 'default' => 'true',
917 ],
918 [
919 'attr' => '0',
920 'text' => esc_attr__('False', 'simple-tags'),
921 ],
922 ],
923 ];
924 $selected = (isset($current) && isset($current['enable_custom_urls'])) ? taxopress_disp_boolean($current['enable_custom_urls']) : '';
925 $select['selected'] = !empty($selected) ? $current['enable_custom_urls'] : '';
926
927 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
928 echo $ui->get_select_checkbox_input([
929 'namearray' => 'taxopress_autolink',
930 'name' => 'enable_custom_urls',
931 'labeltext' => esc_html__('Enable Custom URLs', 'simple-tags'),
932 'aftertext' => esc_html__('When enabled, terms can be linked to custom URLs instead of their archive pages.', 'simple-tags'),
933 'selections' => $select,
934 ]);
935 // Fetch all taxonomies
936 $all_taxonomies = get_taxonomies([], 'objects');
937
938 $selected_taxonomies = [];
939 if (isset($current['taxonomy'])) {
940 if (is_array($current['taxonomy'])) {
941 $selected_taxonomies = $current['taxonomy'];
942 } else {
943 $selected_taxonomies = [$current['taxonomy']];
944 }
945 }
946
947
948 if (!is_array($current) || !array_key_exists('enable_customurl_field', $current)) {
949 $enable_customurl_field = isset($_POST['taxopress_autolink']) ? [] : ['post_tag', 'category'];
950 } else {
951 $enable_customurl_field = is_array($current['enable_customurl_field']) ? $current['enable_customurl_field'] : [];
952 }
953
954 echo '<tr valign="top"><th scope="row"><label>' . esc_html__(
955 'Enable the Custom URL Field:',
956 'simple-tags'
957 ) . '</label><br /><small style=" color: #646970;">' . esc_html__(
958 'Enable the Custom URL field for this taxonomy.',
959 'simple-tags'
960 ) . '</small></th><td><table class="visbile-table">';
961
962 $enable_custom_urls = isset($current['enable_custom_urls']) && $current['enable_custom_urls'] == '1';
963
964 foreach ($all_taxonomies as $taxonomy) {
965 if (!in_array($taxonomy->name, $selected_taxonomies, true)) {
966 continue;
967 }
968 $disabled = !$enable_custom_urls ? 'disabled' : '';
969 echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($taxonomy->name) . '">' . esc_html($taxonomy->label) . '</label></th><td>';
970 echo $ui->get_check_input([
971 'checkvalue' => $taxonomy->name,
972 'checked' => in_array($taxonomy->name, $enable_customurl_field, true) ? 'true' : 'false',
973 'name' => esc_attr($taxonomy->name),
974 'namearray' => 'taxopress_autolink[enable_customurl_field]',
975 'textvalue' => esc_attr($taxonomy->name),
976 'labeltext' => '',
977 'wrap' => false,
978 ]);
979 echo '</td></tr>';
980 }
981 echo '</table></td></tr>';
982 ?>
983 </table>
984
985 <table class="form-table taxopress-table autolink_advanced" style="<?php echo $active_tab === 'autolink_advanced' ? '' : 'display:none;'; ?>">
986 <?php
987 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
988 echo $ui->get_text_input([
989 'namearray' => 'taxopress_autolink',
990 'name' => 'link_class',
991 'class' => '',
992 'textvalue' => isset($current['link_class']) ? esc_attr($current['link_class']) : '',
993 'labeltext' => esc_html__('Term link class', 'simple-tags'),
994 'helptext' => '',
995 'required' => false,
996 ]);
997
998 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
999 echo $ui->get_number_input([
1000 'namearray' => 'taxopress_autolink',
1001 'name' => 'hook_priority',
1002 'textvalue' => isset($current['hook_priority']) ? esc_attr($current['hook_priority']) : '12',
1003 'labeltext' => esc_html__(
1004 'Priority on the_content and the_title hook',
1005 'simple-tags'
1006 ),
1007 'helptext' => esc_html__(
1008 '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.',
1009 'simple-tags'
1010 ),
1011 'min' => '1',
1012 'required' => false,
1013 ]);
1014
1015 ?>
1016 </table>
1017
1018
1019 </div>
1020
1021
1022 <?php } //end new fields
1023 ?>
1024
1025
1026 <div class="clear"></div>
1027
1028
1029 </div>
1030 </div>
1031 </div>
1032
1033
1034 <?php if ($autolink_limit) { ?>
1035
1036 <div class="pp-version-notice-bold-purple" style="margin-left:0px;">
1037 <div class="pp-version-notice-bold-purple-message"><?php esc_html_e('You\'re using TaxoPress Free.
1038 The Pro version has more features and support.', 'simple-tags'); ?>
1039 </div>
1040 <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>
1041 </div>
1042 </div>
1043
1044 <?php } ?>
1045 <?php
1046 /**
1047 * Fires after the default fieldsets on the taxonomy screen.
1048 *
1049 * @param taxopress_admin_ui $ui Admin UI instance.
1050 */
1051 do_action('taxopress_taxonomy_after_fieldsets', $ui);
1052 ?>
1053
1054 </div>
1055 </div>
1056
1057
1058 </div>
1059
1060 <div class="taxopress-right-sidebar">
1061 <div class="taxopress-right-sidebar-wrapper" style="min-height: 205px;<?php echo ($autolink_limit) ? 'display: none;' : ''; ?>">
1062
1063
1064 <?php
1065 if (!$autolink_limit) { ?>
1066 <p class="submit">
1067
1068 <?php
1069 wp_nonce_field(
1070 'taxopress_addedit_autolink_nonce_action',
1071 'taxopress_addedit_autolink_nonce_field'
1072 );
1073 if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?>
1074 <input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-autolink-submit" name="autolink_submit" value="<?php echo esc_attr(esc_attr__(
1075 'Save Auto Links',
1076 'simple-tags'
1077 )); ?>" />
1078 <?php
1079 } else { ?>
1080 <input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-autolink-submit" name="autolink_submit" value="<?php echo esc_attr(esc_attr__(
1081 'Add Auto Links',
1082 'simple-tags'
1083 )); ?>" />
1084 <?php } ?>
1085
1086
1087 <input type="hidden" name="cpt_tax_status" id="cpt_tax_status" value="<?php echo esc_attr($tab); ?>" />
1088 </p>
1089
1090 <?php
1091 }
1092 ?>
1093
1094 </div>
1095
1096 <?php do_action('taxopress_admin_after_sidebar'); ?>
1097 <div class="taxopress-advertisement-right-sidebar">
1098 <div id="postbox-container-1" class="postbox-container">
1099 <div class="meta-box-sortables">
1100 <div class="advertisement-box-content postbox">
1101 <div class="postbox-header">
1102 <h3 class="advertisement-box-header hndle is-non-sortable">
1103 <span><?php echo esc_html__('TaxoPress and Languages', 'simple-tags'); ?></span>
1104 </h3>
1105 </div>
1106 <div class="inside">
1107 <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>'); ?>
1108 </p>
1109 </div>
1110 </div>
1111 </div>
1112 </div>
1113 </div>
1114
1115
1116 </div>
1117
1118 <div class="clear"></div>
1119
1120
1121
1122 </form>
1123
1124 </div><!-- End .wrap -->
1125
1126 <div class="clear"></div>
1127
1128 <?php # Modal Windows;
1129 ?>
1130 <div class="remodal" data-remodal-id="taxopress-modal-alert" data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
1131 <div class="" style="color:red;"><?php echo esc_html__('Please complete the following required fields to save your changes:', 'simple-tags'); ?></div>
1132 <div id="taxopress-modal-alert-content"></div>
1133 <br>
1134 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('Okay', 'simple-tags'); ?></button>
1135 </div>
1136
1137 <div class="remodal" data-remodal-id="taxopress-modal-confirm" data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
1138 <div id="taxopress-modal-confirm-content"></div>
1139 <br>
1140 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('No', 'simple-tags'); ?></button>
1141 <button data-remodal-action="confirm" class="remodal-confirm"><?php echo esc_html__('Yes', 'simple-tags'); ?></button>
1142 </div>
1143
1144 <?php
1145 do_action( 'simpletags-autolinks');
1146 }
1147 }
1148