PluginProbe
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms / 3.40.0
Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms v3.40.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 / tag-clouds.php

tag-clouds.php in Tag, Category, and Taxonomy Manager – Autotagger Automatically Add Terms 3.40.0, at inc/tag-clouds.php

1,129 lines 70.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 class SimpleTags_Tag_Clouds
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 add_action('wp_ajax_taxopress_terms_display_preview', [$this, 'handle_termsdisplay_preview']);
31
32 }
33
34 /**
35 * Init somes JS and CSS need for this feature
36 *
37 * @return void
38 * @author Olatechpro
39 */
40 public static function admin_enqueue_scripts()
41 {
42
43 // add JS for manage click tags
44 if (isset($_GET['page']) && $_GET['page'] == 'st_terms_display') {
45 wp_enqueue_style('st-taxonomies-css');
46 }
47 }
48
49 public static function set_screen($status, $option, $value)
50 {
51 return $value;
52 }
53
54 /** Singleton instance */
55 public static function get_instance()
56 {
57 if (!isset(self::$instance)) {
58 self::$instance = new self();
59 }
60
61 return self::$instance;
62 }
63
64 /**
65 * Add WP admin menu for Tags
66 *
67 * @return void
68 * @author Olatechpro
69 */
70 public function admin_menu()
71 {
72 $hook = add_submenu_page(
73 self::MENU_SLUG,
74 esc_html__('Terms Display', 'simple-tags'),
75 esc_html__('Terms Display', 'simple-tags'),
76 'simple_tags',
77 'st_terms_display',
78 [
79 $this,
80 'page_manage_tagclouds',
81 ]
82 );
83
84 if(taxopress_is_screen_main_page()){
85 add_action("load-$hook", [$this, 'screen_option']);
86 }
87 }
88
89 /**
90 * Screen options
91 */
92 public function screen_option()
93 {
94
95 $option = 'per_page';
96 $args = [
97 'label' => esc_html__('Number of items per page', 'simple-tags'),
98 'default' => 20,
99 'option' => 'st_terms_display_per_page'
100 ];
101
102 add_screen_option($option, $args);
103
104 $this->terms_table = new TagClouds_List();
105 }
106
107 /**
108 * Method for build the page HTML manage tags
109 *
110 * @return void
111 * @author Olatechpro
112 */
113 public function page_manage_tagclouds()
114 {
115 // Default order
116 if (!isset($_GET['order'])) {
117 $_GET['order'] = 'name-asc';
118 }
119
120 settings_errors(__CLASS__);
121
122 if (!isset($_GET['add'])) {
123 //all tax
124 ?>
125 <div class="wrap st_wrap st-manage-taxonomies-page">
126
127 <div id="">
128 <h1 class="wp-heading-inline"><?php _e('Terms Display', 'simple-tags'); ?></h1>
129 <a href="<?php echo esc_url(admin_url('admin.php?page=st_terms_display&add=new_item')); ?>"
130 class="page-title-action taxopress">
131 <span class="dashicons dashicons-lock"></span>
132 <?php esc_html_e('Add New Terms Display', 'simple-tags'); ?>
133 </a>
134
135 <div class="taxopress-description"><?php esc_html_e('This feature allows you to create a customizable display of all the terms in one taxonomy.', 'simple-tags'); ?></div>
136
137
138 <?php
139 if (isset($_REQUEST['s']) && $search = sanitize_text_field(wp_unslash($_REQUEST['s']))) {
140 /* translators: %s: search keywords */
141 printf(' <span class="subtitle">' . esc_html__('Search results for &#8220;%s&#8221;',
142 'simple-tags') . '</span>', esc_html($search));
143 }
144 ?>
145 <?php
146
147 //the terms table instance
148 $this->terms_table->prepare_items();
149 ?>
150
151
152 <hr class="wp-header-end">
153 <div id="ajax-response"></div>
154 <form class="search-form wp-clearfix st-taxonomies-search-form" method="get">
155 <?php $this->terms_table->search_box(esc_html__('Search Terms Display', 'simple-tags'), 'term'); ?>
156 </form>
157 <div class="clear"></div>
158
159 <div id="col-container" class="wp-clearfix">
160
161 <div class="col-wrap">
162 <form action="<?php echo esc_url(add_query_arg('', '')); ?>" method="post">
163 <?php $this->terms_table->display(); //Display the table ?>
164 </form>
165 <div class="form-wrap edit-term-notes">
166 <p><?php esc_html__('Description here.', 'simple-tags') ?></p>
167 </div>
168 </div>
169
170
171 </div>
172
173
174 </div>
175 <?php } else {
176 if ($_GET['add'] == 'new_item') {
177 //add/edit taxonomy
178 $this->taxopress_manage_tagclouds();
179 echo '<div>';
180 }
181 } ?>
182
183
184 <?php SimpleTags_Admin::printAdminFooter(); ?>
185 </div>
186 <?php
187 }
188
189
190 /**
191 * Create our settings page output.
192 *
193 * @internal
194 */
195 public function taxopress_manage_tagclouds()
196 {
197
198 $tab = (!empty($_GET) && !empty($_GET['action']) && 'edit' == $_GET['action']) ? 'edit' : 'new';
199 $tab_class = 'taxopress-' . $tab;
200 $current = null;
201
202 ?>
203
204 <div class="wrap <?php echo esc_attr($tab_class); ?>">
205
206 <?php
207
208 $tagclouds = taxopress_get_tagcloud_data();
209 $tag_cloud_edit = false;
210 $tag_cloud_limit = false;
211
212 if ('edit' === $tab) {
213
214
215 $selected_tagcloud = taxopress_get_current_tagcloud();
216
217 if ($selected_tagcloud && array_key_exists($selected_tagcloud, $tagclouds)) {
218 $current = $tagclouds[$selected_tagcloud];
219 $tag_cloud_edit = true;
220 }
221
222 }
223
224
225 if(!isset($current['title']) && count($tagclouds) > 0 && apply_filters('taxopress_tag_clouds_create_limit', true)){
226 $tag_cloud_limit = true;
227 }
228
229
230 $ui = new taxopress_admin_ui();
231 ?>
232
233
234
235
236 <div class="wrap <?php echo esc_attr($tab_class); ?>">
237 <h1><?php echo esc_html__('Manage Terms Display', 'simple-tags'); ?></h1>
238 <div class="wp-clearfix"></div>
239
240 <form method="post" action="">
241
242
243 <div class="tagcloudui st-tabbed">
244
245 <?php if (isset($_GET['action']) && $_GET['action'] === 'edit') : ?>
246
247 <div class="tagclouds-postbox-container terms-display-preview">
248 <div id="poststuff" class="taxopress-preview-box">
249 <div class="taxopress-section postbox">
250 <div class="postbox-header">
251 <h2 class="hndle ui-sortable-handle">
252 <?php echo esc_html__('Preview Terms Display', 'simple-tags'); ?>
253 </h2>
254
255 <div class="handle-actions hide-if-no-js">
256 <span class="term-panel-move up dashicons dashicons-arrow-up-alt2"
257 title="<?php esc_attr_e('Move up', 'simple-tags'); ?>">
258 </span>
259 <span class="term-panel-move down dashicons dashicons-arrow-down-alt2"
260 title="<?php esc_attr_e('Move down', 'simple-tags'); ?>">
261 </span>
262 <button type="button" class="handlediv" aria-expanded="true">
263 <span class="screen-reader-text">
264 <?php esc_html_e('Toggle panel', 'simple-tags'); ?>
265 </span>
266 <span class="toggle-indicator dashicons dashicons-arrow-down" aria-hidden="true"></span>
267 </button>
268 </div>
269 </div>
270
271 <div class="inside">
272 <div class="taxopress-preview-wrapper">
273 <div class="taxopress-preview-control">
274 <?php
275 $preview_display_id = isset($current['ID']) ? (int) $current['ID'] : 0;
276 ?>
277 <span class="spinner" style="visibility:hidden;"></span>
278 </div>
279 <div id="term-display-preview" class="taxopress-preview-content">
280 </div>
281 </div>
282 </div>
283 </div>
284 </div>
285 </div>
286 <?php endif; ?>
287
288
289 <div class="tagclouds-postbox-container">
290 <div id="poststuff">
291 <div class="taxopress-section postbox">
292 <div class="postbox-header">
293 <h2 class="hndle ui-sortable-handle">
294 <?php
295 if ($tag_cloud_edit) {
296 $active_tab = ( isset($current['active_tab']) && !empty(trim($current['active_tab'])) ) ? $current['active_tab'] : 'tagcloud_general';
297 echo esc_html__('Edit Terms Display', 'simple-tags');
298 echo '<input type="hidden" name="edited_tagcloud" value="' . esc_attr($current['ID']) . '" />';
299 echo '<input type="hidden" name="taxopress_tag_cloud[ID]" value="' . esc_attr($current['ID']) . '" />';
300 echo '<input type="hidden" name="taxopress_tag_cloud[active_tab]" class="taxopress-active-subtab" value="'.esc_attr($active_tab).'" />';
301 } else {
302 $active_tab = 'tagcloud_general';
303 echo '<input type="hidden" name="taxopress_tag_cloud[active_tab]" class="taxopress-active-subtab" value="" />';
304 echo esc_html__('Add new Terms Display', 'simple-tags');
305 }
306 ?>
307 </h2>
308 </div>
309 <div class="inside">
310 <div class="main">
311
312
313 <?php if ($tag_cloud_limit) {
314 echo '<div class="st-taxonomy-content promo-box-area"><div class="taxopress-warning upgrade-pro">
315 <h2 style="margin-bottom: 5px;">' . esc_html__('To create more Terms Display, please upgrade to TaxoPress Pro.','simple-tags').'</h2>
316 <p>
317
318 ' . esc_html__('With TaxoPress Pro, you can create unlimited Terms Display. You can create Terms Display for any taxonomy and then display those Terms Display anywhere on your site.','simple-tags').'
319
320 </p>
321 </div></div>';
322
323 } else {
324 ?>
325
326
327 <ul class="taxopress-tab">
328 <li aria-current="<?php echo $active_tab === 'tagcloud_general' ? 'true' : 'false'; ?>" class="tagcloud_general_tab <?php echo $active_tab === 'tagcloud_general' ? 'active' : ''; ?>" data-content="tagcloud_general">
329 <a href="#tagcloud_general"><span><?php esc_html_e('General',
330 'simple-tags'); ?></span></a>
331 </li>
332
333 <li aria-current="<?php echo $active_tab === 'tagcloud_terms' ? 'true' : 'false'; ?>" class="tagcloud_terms_tab <?php echo $active_tab === 'tagcloud_terms' ? 'active' : ''; ?>" data-content="tagcloud_terms">
334 <a href="#tagcloud_terms"><span><?php esc_html_e('Choose Terms',
335 'simple-tags'); ?></span></a>
336 </li>
337
338 <li aria-current="<?php echo $active_tab === 'tagcloud_options' ? 'true' : 'false'; ?>" class="tagcloud_options_tab <?php echo $active_tab === 'tagcloud_options' ? 'active' : ''; ?>" data-content="tagcloud_options">
339 <a href="#tagcloud_options"><span><?php esc_html_e('Options',
340 'simple-tags'); ?></span></a>
341 </li>
342
343 <li aria-current="<?php echo $active_tab === 'tagcloud_layout' ? 'true' : 'false'; ?>" class="tagcloud_layout_tab <?php echo $active_tab === 'tagcloud_layout' ? 'active' : ''; ?>" data-content="tagcloud_layout">
344 <a href="#tagcloud_layout"><span><?php esc_html_e('Layout',
345 'simple-tags'); ?></span></a>
346 </li>
347
348 <li aria-current="<?php echo $active_tab === 'tagcloud_exceptions' ? 'true' : 'false'; ?>" class="tagcloud_exceptions_tab <?php echo $active_tab === 'tagcloud_exceptions' ? 'active' : ''; ?>" data-content="tagcloud_exceptions">
349 <a href="#tagcloud_exceptions"><span><?php esc_html_e('Exceptions',
350 'simple-tags'); ?></span></a>
351 </li>
352
353 <li aria-current="<?php echo $active_tab === 'tagcloud_design' ? 'true' : 'false'; ?>" class="tagcloud_design_tab <?php echo $active_tab === 'tagcloud_design' ? 'active' : ''; ?>" data-content="tagcloud_design">
354 <a href="#tagcloud_design"><span><?php esc_html_e('Design',
355 'simple-tags'); ?></span></a>
356 </li>
357
358 <li aria-current="<?php echo $active_tab === 'tagcloud_advanced' ? 'true' : 'false'; ?>" class="tagcloud_advanced_tab <?php echo $active_tab === 'tagcloud_advanced' ? 'active' : ''; ?>" data-content="tagcloud_advanced">
359 <a href="#tagcloud_advanced"><span><?php esc_html_e('Display Format',
360 'simple-tags'); ?></span></a>
361 </li>
362
363 </ul>
364
365 <div class="st-taxonomy-content taxopress-tab-content">
366
367
368 <table class="form-table taxopress-table tagcloud_general"
369 style="<?php echo $active_tab === 'tagcloud_general' ? '' : 'display:none;'; ?>">
370 <?php
371 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
372 echo $ui->get_tr_start();
373
374
375 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
376 echo $ui->get_th_start();
377
378 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
379 echo $ui->get_label('name', esc_html__('Title', 'simple-tags')) . $ui->get_required_span();
380 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
381 echo $ui->get_th_end() . $ui->get_td_start();
382
383 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
384 echo $ui->get_text_input([
385 'namearray' => 'taxopress_tag_cloud',
386 'name' => 'title',
387 'textvalue' => isset($current['title']) ? esc_attr($current['title']) : '',
388 'maxlength' => '32',
389 'helptext' => '',
390 'required' => true,
391 'placeholder' => false,
392 'wrap' => false,
393 ]);
394
395 $select = [
396 'options' => [
397 [
398 'attr' => '0',
399 'text' => esc_attr__('False', 'simple-tags'),
400 'default' => 'true',
401 ],
402 [
403 'attr' => '1',
404 'text' => esc_attr__('True', 'simple-tags'),
405 ],
406 ],
407 ];
408 $selected = ( isset($current) && isset($current['hide_title']) ) ? taxopress_disp_boolean($current['hide_title']) : '';
409 $select['selected'] = !empty($selected) ? $current['hide_title'] : '';
410 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
411 echo $ui->get_select_checkbox_input([
412 'namearray' => 'taxopress_tag_cloud',
413 'name' => 'hide_title',
414 'labeltext' => esc_html__('Hide title in output?', 'simple-tags'),
415 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
416 ]);
417
418
419
420 $options[] = [ 'attr' => '', 'text' => esc_html__('All post types', 'simple-tags'), 'default' => 'true' ];
421 foreach ( get_post_types(['public' => true], 'objects') as $post_type ) {
422 if (!in_array($post_type->name, ['attachment'])) {
423 $options[] = [ 'attr' => $post_type->name, 'text' => $post_type->label ];
424 }
425 }
426
427 $select = [
428 'options' => $options,
429 ];
430 $selected = ( isset( $current ) && isset($current['post_type']) ) ? taxopress_disp_boolean( $current['post_type'] ) : '';
431 $select['selected'] = ! empty( $selected ) ? $current['post_type'] : '';
432 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
433 echo $ui->get_select_checkbox_input_main( [
434 'namearray' => 'taxopress_tag_cloud',
435 'name' => 'post_type',
436 'class' => 'st-post-type-select',
437 'labeltext' => esc_html__( 'Post Type', 'simple-tags' ),
438 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
439 ] );
440
441 $options = [];
442 foreach ( get_all_taxopress_taxonomies() as $_taxonomy ) {
443 $_taxonomy = $_taxonomy->name;
444 $tax = get_taxonomy( $_taxonomy );
445 if ( ! $tax->show_tagcloud || empty( $tax->labels->name ) || $_taxonomy === 'link_category' ) {
446 continue;
447 }
448 if($tax->name === 'post_tag'){
449 $options[] = [ 'post_type' => join(',', $tax->object_type), 'attr' => $tax->name, 'text' => $tax->labels->name. ' ('.$tax->name.')', 'default' => 'true' ];
450 }else{
451 $options[] = [ 'post_type' => join(',', $tax->object_type), 'attr' => $tax->name, 'text' => $tax->labels->name. ' ('.$tax->name.')' ];
452 }
453 }
454
455 $select = [
456 'options' => $options,
457 ];
458 $selected = isset( $current ) ? taxopress_disp_boolean( $current['taxonomy'] ) : '';
459 $select['selected'] = ! empty( $selected ) ? $current['taxonomy'] : '';
460 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
461 echo $ui->get_select_checkbox_input_main( [
462 'namearray' => 'taxopress_tag_cloud',
463 'name' => 'taxonomy',
464 'class' => 'st-post-taxonomy-select',
465 'labeltext' => esc_html__( 'Taxonomy', 'simple-tags' ),
466 'required' => true,
467 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
468 ] );
469
470 $options = [
471 ['attr' => 'all', 'text' => esc_html__('All Parent Terms', 'simple-tags'), 'default' => 'true']
472 ];
473 if (!empty($current['taxonomy'])) {
474 $taxonomy = $current['taxonomy'];
475
476 $all_terms = get_terms([
477 'taxonomy' => $taxonomy,
478 'hide_empty' => false,
479 ]);
480
481 if (!empty($all_terms) && !is_wp_error($all_terms)) {
482 $child_term_ids = [];
483 $parent_term_ids = [];
484
485 // Build child-parent mapping
486 foreach ($all_terms as $term) {
487 if ($term->parent) {
488 $child_term_ids[] = $term->term_id;
489 $parent_term_ids[] = $term->parent;
490 }
491 }
492
493 $parent_term_ids = array_unique($parent_term_ids);
494
495 foreach ($all_terms as $term) {
496 $term_id = $term->term_id;
497
498 if (in_array($term_id, $parent_term_ids, true) || $term->parent == 0) {
499 $options[] = [
500 'attr' => strval($term_id),
501 'text' => esc_html($term->name)
502 ];
503 }
504 }
505 }
506 }
507
508 $selected = isset($current['parent_term']) ? (array) $current['parent_term'] : ['all'];
509 $select['selected'] = isset($current['parent_term']) ? $current['parent_term'] : 'all';
510
511 $select = [
512 'options' => $options,
513 'selected' => $selected
514 ];
515
516 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
517 echo $ui->get_select_checkbox_input_main([
518 'namearray' => 'taxopress_tag_cloud',
519 'name' => 'parent_term',
520 'class' => 'taxopress-single-select2',
521 'labeltext' => esc_html__('Parent Term', 'simple-tags'),
522 'selections' => $select // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
523 ]);
524
525 $select = [
526 'options' => [
527 [ 'attr' => 'parents_only', 'text' => esc_attr__('Display only Parent Terms', 'simple-tags') ],
528 [ 'attr' => 'sub_terms_only', 'text' => esc_attr__('Display only Sub-Terms', 'simple-tags') ],
529 [ 'attr' => 'parents_and_sub', 'text' => esc_attr__('Display Parents and Sub-Terms', 'simple-tags'), 'default' => 'true' ]
530 ]
531 ];
532
533 $selected = isset($current['display_mode']) ? taxopress_disp_boolean($current['display_mode']) : '';
534 $select['selected'] = ! empty( $selected ) ? $current['display_mode'] : '';
535 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
536 echo $ui->get_select_checkbox_input_main([
537 'namearray' => 'taxopress_tag_cloud',
538 'name' => 'display_mode',
539 'labeltext' => esc_html__('Display Mode', 'simple-tags'),
540 'selections' => $select // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
541 ]);
542 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
543 echo $ui->get_td_end() . $ui->get_tr_end();
544 ?>
545 </table>
546
547
548
549
550 <table class="form-table taxopress-table tagcloud_terms"
551 style="<?php echo $active_tab === 'tagcloud_terms' ? '' : 'display:none;'; ?>">
552 <?php
553
554
555 $select = [
556 'options' => [
557 [ 'attr' => '1', 'text' => esc_attr__( '24 hours', 'simple-tags' ) ],
558 [ 'attr' => '7', 'text' => esc_attr__( '7 days', 'simple-tags' ) ],
559 [ 'attr' => '14', 'text' => esc_attr__( '2 weeks', 'simple-tags' ) ],
560 [ 'attr' => '30', 'text' => esc_attr__( '1 month', 'simple-tags' ) ],
561 [ 'attr' => '180', 'text' => esc_attr__( '6 months', 'simple-tags' ) ],
562 [ 'attr' => '365', 'text' => esc_attr__( '1 year', 'simple-tags' ) ],
563 [ 'attr' => '0', 'text' => esc_attr__( 'No limit', 'simple-tags'), 'default' => 'true' ],
564 ],
565 ];
566 $selected = isset( $current ) ? taxopress_disp_boolean( $current['limit_days'] ) : '';
567 $select['selected'] = ! empty( $selected ) ? $current['limit_days'] : '';
568 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
569 echo $ui->get_select_number_select( [
570 'namearray' => 'taxopress_tag_cloud',
571 'name' => 'limit_days',
572 'labeltext' => esc_html__( 'Limit terms based on timeframe', 'simple-tags' ),
573 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
574 ] );
575
576 do_action('taxopress_tagcloud_ordering_method', $current);
577
578
579 $select = [
580 'options' => [
581 [ 'attr' => 'asc', 'text' => esc_attr__( 'Ascending', 'simple-tags' ) ],
582 [ 'attr' => 'desc', 'text' => esc_attr__( 'Descending', 'simple-tags'), 'default' => 'true' ],
583 ],
584 ];
585 $selected = isset( $current ) ? taxopress_disp_boolean( $current['order'] ) : '';
586 $select['selected'] = ! empty( $selected ) ? $current['order'] : '';
587 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
588 echo $ui->get_select_checkbox_input_main( [
589 'namearray' => 'taxopress_tag_cloud',
590 'name' => 'order',
591 'labeltext' => esc_html__( 'Ordering for choosing terms for display', 'simple-tags' ),
592 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
593 ] );
594
595
596
597 ?>
598 </table>
599
600
601 <table class="form-table taxopress-table tagcloud_layout"
602 style="<?php echo $active_tab === 'tagcloud_layout' ? '' : 'display:none;'; ?>">
603 <?php
604
605 $select = [
606 'options' => [
607 [ 'attr' => 'flat', 'text' => esc_attr__( 'Cloud', 'simple-tags' )],
608 [ 'attr' => 'list', 'text' => esc_attr__( 'Unordered List (UL/LI)', 'simple-tags' ) ],
609 [ 'attr' => 'ol', 'text' => esc_attr__( 'Ordered List (OL/LI)', 'simple-tags' ) ],
610 [ 'attr' => 'comma', 'text' => esc_attr__( 'WordPress Default', 'simple-tags' ), 'default' => 'true'],
611 ['attr' => 'table', 'text' => esc_attr__('Table List', 'simple-tags')],
612 ['attr' => 'border', 'text' => esc_attr__('Border Cloud', 'simple-tags'), 'default' => 'true' ],
613 ['attr' => 'parent/child', 'text' => esc_attr__('Parent / Child', 'simple-tags')],
614 ],
615 ];
616 $selected = isset( $current ) ? taxopress_disp_boolean( $current['format'] ) : '';
617 $select['selected'] = ! empty( $selected ) ? $current['format'] : '';
618 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
619 echo $ui->get_select_checkbox_input_main( [
620 'namearray' => 'taxopress_tag_cloud',
621 'name' => 'format',
622 'labeltext' => esc_html__( 'Display format', 'simple-tags' ),
623 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
624 ] );
625 ?>
626
627 </table>
628
629
630
631 <table class="form-table taxopress-table tagcloud_options"
632 style="<?php echo $active_tab === 'tagcloud_options' ? '' : 'display:none;'; ?>">
633 <?php
634
635 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
636 echo $ui->get_text_input([
637 'namearray' => 'taxopress_tag_cloud',
638 'name' => 'before',
639 'textvalue' => isset($current['before']) ? esc_attr($current['before']) : '',
640 'labeltext' => esc_html__(
641 'Text to display before terms list',
642 'simple-tags'
643 ),
644 'helptext' => esc_html__(
645 'Enter the text that should be display before terms list. This field accepts basic HTML.',
646 'simple-tags'
647 ),
648 'required' => false,
649 ]);
650
651 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
652 echo $ui->get_text_input([
653 'namearray' => 'taxopress_tag_cloud',
654 'name' => 'after',
655 'textvalue' => isset($current['after']) ? esc_attr($current['after']) : '',
656 'labeltext' => esc_html__(
657 'Text to display after terms list',
658 'simple-tags'
659 ),
660 'helptext' => esc_html__(
661 'Enter the text that should be display after terms list. This field accepts basic HTML.',
662 'simple-tags'
663 ),
664 'required' => false,
665 ]);
666 ?>
667 </table>
668
669 <table class="form-table taxopress-table tagcloud_exceptions"
670 style="<?php echo $active_tab === 'tagcloud_exceptions' ? '' : 'display:none;'; ?>">
671 <?php
672
673 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
674 echo $ui->get_textarea_input([
675 'namearray' => 'taxopress_tag_cloud',
676 'name' => 'exclude_terms',
677 'rows' => '4',
678 'cols' => '40',
679 'class' => 'autocomplete-input tagclouds-exclude',
680 'textvalue' => isset($current['exclude_terms']) ? esc_attr($current['exclude_terms']) : '',
681 'labeltext' => esc_html__('Exclude terms from terms display', 'simple-tags'),
682 'helptext' => esc_html__('Enter terms (comma-separated) to exclude from the terms display.', 'simple-tags'),
683 'required' => false,
684 ]);
685
686 $enable_hidden_terms = SimpleTags_Plugin::get_option_value('enable_hidden_terms');
687
688 if ($enable_hidden_terms) {
689 $select = [
690 'options' => [
691 [
692 'attr' => '0',
693 'text' => esc_attr__('False', 'simple-tags'),
694 'default' => 'true',
695 ],
696 [
697 'attr' => '1',
698 'text' => esc_attr__('True', 'simple-tags'),
699 ],
700 ],
701 ];
702
703 $selected = isset($current['hide_terms']) ? taxopress_disp_boolean($current['hide_terms']) : '0';
704 $select['selected'] = !empty($selected) ? $selected : '0';
705
706 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
707 echo $ui->get_select_checkbox_input([
708 'namearray' => 'taxopress_tag_cloud',
709 'name' => 'hide_terms',
710 'labeltext' => esc_html__('Exclude hidden terms from Terms Display?', 'simple-tags'),
711 'selections' => $select, // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
712 ]);
713 } else {
714 if (isset($current['hide_terms']) && $current['hide_terms'] !== '0') {
715 $current['hide_terms'] = '0';
716 }
717 }
718
719 ?>
720 </table>
721
722
723 <table class="form-table taxopress-table tagcloud_design"
724 style="<?php echo $active_tab === 'tagcloud_design' ? '' : 'display:none;'; ?>">
725 <?php
726
727 $select = [
728 'options' => [
729 [
730 'attr' => '0',
731 'text' => esc_attr__('False', 'simple-tags'),
732 'default' => 'true',
733 ],
734 [
735 'attr' => '1',
736 'text' => esc_attr__('True', 'simple-tags'),
737 ],
738 ],
739 ];
740 $selected = ( isset($current) && isset($current['hide_output']) ) ? taxopress_disp_boolean($current['hide_output']) : '';
741 $select['selected'] = !empty($selected) ? $current['hide_output'] : '';
742 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
743 echo $ui->get_select_checkbox_input([
744 'namearray' => 'taxopress_tag_cloud',
745 'name' => 'hide_output',
746 'labeltext' => esc_html__('Hide display output if no terms?', 'simple-tags'),
747 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
748 ]);
749
750 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
751 echo $ui->get_number_input([
752 'namearray' => 'taxopress_tag_cloud',
753 'name' => 'max',
754 'textvalue' => isset($current['max']) ? esc_attr($current['max']) : '20 ',
755 'labeltext' => esc_html__('Maximum terms to display', 'simple-tags'),
756 'helptext' => '',
757 'required' => true,
758 ]);
759
760 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
761 echo $ui->get_number_input([
762 'namearray' => 'taxopress_tag_cloud',
763 'name' => 'smallest',
764 'textvalue' => isset($current['smallest']) ? esc_attr($current['smallest']) : '12',
765 'labeltext' => esc_html__('Font size minimum', 'simple-tags'),
766 'helptext' => '',
767 'required' => true,
768 ]);
769
770 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
771 echo $ui->get_number_input([
772 'namearray' => 'taxopress_tag_cloud',
773 'name' => 'largest',
774 'textvalue' => isset($current['largest']) ? esc_attr($current['largest']) : '12',
775 'labeltext' => esc_html__('Font size maximum', 'simple-tags'),
776 'helptext' => '',
777 'required' => true,
778 ]);
779
780 $select = [
781 'options' => [
782 [ 'attr' => 'pt', 'text' => esc_attr__( 'Point', 'simple-tags' ), 'default' => 'true' ],
783 [ 'attr' => 'px', 'text' => esc_attr__( 'Pixel', 'simple-tags' ) ],
784 [ 'attr' => 'em', 'text' => esc_attr__( 'Em', 'simple-tags') ],
785 [ 'attr' => '%', 'text' => esc_attr__( 'Percent', 'simple-tags') ],
786 ],
787 ];
788 $selected = isset( $current ) ? taxopress_disp_boolean( $current['unit'] ) : '';
789 $select['selected'] = ! empty( $selected ) ? $current['unit'] : '';
790 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
791 echo $ui->get_select_checkbox_input_main( [
792 'namearray' => 'taxopress_tag_cloud',
793 'name' => 'unit',
794 'labeltext' => esc_html__( 'Unit font size', 'simple-tags' ),
795 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
796 ] );
797
798
799
800 $select = [
801 'options' => [
802 [
803 'attr' => '0',
804 'text' => esc_attr__('False', 'simple-tags'),
805 ],
806 [
807 'attr' => '1',
808 'text' => esc_attr__('True', 'simple-tags'),
809 //'default' => 'true', removed when default value is checked as this mean box is always checked even when user uncheck it since it's defau;t
810 ],
811 ],
812 ];
813 $selected = ( isset($current) && isset($current['color']) ) ? taxopress_disp_boolean($current['color']) : '';
814
815 if($tag_cloud_edit){
816 $select['selected'] = !empty($selected) ? $current['color'] : '';
817 }else{
818 $select['selected'] = 1; //makeup for default when creating new term display
819 }
820 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
821 echo $ui->get_select_checkbox_input([
822 'namearray' => 'taxopress_tag_cloud',
823 'name' => 'color',
824 'class' => 'tag-cloud-color-option',
825 'labeltext' => esc_html__('Enable colors for terms', 'simple-tags'),
826 'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
827 ]);
828
829 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
830 echo $ui->get_text_input([
831 'namearray' => 'taxopress_tag_cloud',
832 'name' => 'mincolor',
833 'class' => 'text-color tag-cloud-min',
834 'textvalue' => isset($current['mincolor']) ? esc_attr($current['mincolor']) : '#353535',
835 'labeltext' => esc_html__('Font color minimum', 'simple-tags'),
836 'helptext' => esc_html__('This is the color of the least popular term', 'simple-tags'),
837 'required' => true,
838 ]);
839
840 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
841 echo $ui->get_text_input([
842 'namearray' => 'taxopress_tag_cloud',
843 'name' => 'maxcolor',
844 'class' => 'text-color tag-cloud-max',
845 'textvalue' => isset($current['maxcolor']) ? esc_attr($current['maxcolor']) : '#000000',
846 'labeltext' => esc_html__('Font color maximum', 'simple-tags'),
847 'helptext' => esc_html__('This is the color of the most popular term', 'simple-tags'),
848 'required' => true,
849 ]);
850
851
852 ?>
853
854 </table>
855
856
857 <table class="form-table taxopress-table tagcloud_advanced"
858 style="<?php echo $active_tab === 'tagcloud_advanced' ? '' : 'display:none;'; ?>">
859 <?php
860
861 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
862 echo $ui->get_text_input([
863 'namearray' => 'taxopress_tag_cloud',
864 'name' => 'wrap_class',
865 'class' => '',
866 'textvalue' => isset($current['wrap_class']) ? esc_attr($current['wrap_class']) : '',
867 'labeltext' => esc_html__('Term display div class', 'simple-tags'),
868 'helptext' => '',
869 'required' => false,
870 ]);
871
872 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
873 echo $ui->get_text_input([
874 'namearray' => 'taxopress_tag_cloud',
875 'name' => 'link_class',
876 'class' => '',
877 'textvalue' => isset($current['link_class']) ? esc_attr($current['link_class']) : '',
878 'labeltext' => esc_html__('Term link class', 'simple-tags'),
879 'helptext' => '',
880 'required' => false,
881 ]);
882
883 // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
884 echo $ui->get_textarea_input([
885 'namearray' => 'taxopress_tag_cloud',
886 'name' => 'xformat',
887 'class' => 'st-full-width',
888 'rows' => '4',
889 'cols' => '40',
890 'textvalue' => isset($current['xformat']) ? esc_attr($current['xformat']) : esc_attr('<a href="%tag_link%" id="tag-link-%tag_id%" class="st-tags t%tag_scale%" title="%tag_count% topics" %tag_rel% style="%tag_size% %tag_color%">%tag_name%</a>'),
891 'labeltext' => esc_html__('Term link format', 'simple-tags'),
892 'helptext' => sprintf(esc_html__('This option allows you to change the format of your terms. You can use any of the tokens in the "Terms Display format" sidebar". Find more details %1sin the documentation%2s.', 'simple-tags'), '<a target="blank" href="https://taxopress.com/docs/format-tag-clouds/">', '</a>'),
893 'required' => false,
894 ]);
895
896
897 ?>
898 </table>
899
900
901 </div>
902
903
904 <?php }//end new fields
905 ?>
906
907
908 <div class="clear"></div>
909
910
911 </div>
912 </div>
913 </div>
914
915
916 <?php if ($tag_cloud_limit) { ?>
917
918 <div class="pp-version-notice-bold-purple" style="margin-left:0px;">
919 <div class="pp-version-notice-bold-purple-message"><?php echo esc_html__('You\'re using TaxoPress Free.
920 The Pro version has more features and support.', 'simple-tags'); ?>
921 </div>
922 <div class="pp-version-notice-bold-purple-button"><a
923 href="https://taxopress.com/taxopress/" target="_blank"><?php echo esc_html__('Upgrade to Pro', 'simple-tags'); ?></a>
924 </div>
925 </div>
926
927 <?php } ?>
928 <input type="hidden" class="pp-terms-display-fontsize-warning" value="<?php echo esc_attr__('Font size minimum must not be greater than Font size maximum value.', 'simple-tags'); ?>" />
929 <?php
930 /**
931 * Fires after the default fieldsets on the taxonomy screen.
932 *
933 * @param taxopress_admin_ui $ui Admin UI instance.
934 */
935 do_action('taxopress_taxonomy_after_fieldsets', $ui);
936 ?>
937
938 </div>
939 </div>
940
941
942 </div>
943
944 <div class="taxopress-right-sidebar">
945 <div class="taxopress-right-sidebar-wrapper" style="min-height: 205px;<?php echo ($tag_cloud_limit) ? 'display: none;' : ''; ?>">
946
947
948 <?php
949 if(!$tag_cloud_limit){ ?>
950 <p class="submit">
951
952 <?php
953 wp_nonce_field('taxopress_addedit_tagcloud_nonce_action',
954 'taxopress_addedit_tagcloud_nonce_field');
955 if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?>
956 <input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-tag-cloud-submit" name="tagcloud_submit"
957 value="<?php echo esc_attr(esc_attr__('Save Terms Display', 'simple-tags')); ?>"/>
958 <?php
959 } else { ?>
960 <input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-tag-cloud-submit" name="tagcloud_submit"
961 value="<?php echo esc_attr(esc_attr__('Add Terms Display', 'simple-tags')); ?>"/>
962 <?php } ?>
963
964 <input type="hidden" name="cpt_tax_status" id="cpt_tax_status"
965 value="<?php echo esc_attr($tab); ?>"/>
966 </p>
967
968 <?php if (!empty($current)) {
969 ?>
970 <p>
971 <?php echo '<div class="taxopress-warning" style="">' . esc_html__('Shortcode: ','simple-tags'); ?> &nbsp;
972 <textarea style="resize: none;padding: 5px;" readonly>[taxopress_termsdisplay id="<?php echo (int)$current['ID']; ?>"]</textarea>
973 </div>
974 </p>
975 <?php } ?>
976
977 <?php
978 }
979 ?>
980
981 </div>
982
983 <div class="taxopress-token-right-sidebar">
984 <div id="postbox-container-1" class="postbox-container">
985 <div class="meta-box-sortables">
986 <div class="postbox">
987 <div class="postbox-header">
988 <h3 class="hndle is-non-sortable">
989 <span><?php echo esc_html__('Terms Display format', 'simple-tags'); ?></span>
990 </h3>
991 </div>
992
993 <div class="inside">
994 <p><?php echo esc_html__('Here are the tokens you can use for Term link format', 'simple-tags'); ?>:</p>
995 <ul>
996 <li><code>%tag_link%</code> – <?php echo esc_html__('The URL of the term', 'simple-tags'); ?></li>
997 <li><code>%tag_id%</code> – <?php echo esc_html__('The ID of the term', 'simple-tags'); ?></li>
998 <li><code>t%tag_scale%</code> – <?php echo esc_html__('The weighted size of the term in the display', 'simple-tags'); ?></li>
999 <li><code>%tag_count%</code> – <?php echo esc_html__('The number of times the term is used', 'simple-tags'); ?></li>
1000 <li><code>%tag_rel%</code> – <?php echo esc_html__('This provides rel tag markup', 'simple-tags'); ?> (<?php echo esc_html__('it creates', 'simple-tags'); ?> <code>rel="tag"</code>)</li>
1001 <li><code>%tag_size%</code> – <?php echo esc_html__('The font size for the term', 'simple-tags'); ?></li>
1002 <li><code>%tag_color%</code> – <?php echo esc_html__('The font color for the term', 'simple-tags'); ?></li>
1003 <li><code>%tag_name%</code> – <?php echo esc_html__('The name of the term', 'simple-tags'); ?></li>
1004 <li><code>%tag_name_attribute%</code> – <?php echo esc_html__('The name of the term with any HTML stripped out', 'simple-tags'); ?></li>
1005 <li><code>%tag_description%</code> – <?php echo esc_html__('The description of the term', 'simple-tags'); ?></li>
1006 </ul>
1007 </div>
1008 </div>
1009 </div>
1010 </div>
1011 </div>
1012
1013
1014 <?php do_action('taxopress_admin_after_sidebar'); ?>
1015 </div>
1016
1017 <div class="clear"></div>
1018
1019
1020
1021 </form>
1022
1023 </div><!-- End .wrap -->
1024
1025 <div class="clear"></div>
1026
1027
1028
1029 <?php # Modal Windows; ?>
1030 <div class="remodal" data-remodal-id="taxopress-modal-alert"
1031 data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
1032 <div class="" style="color:red;"><?php echo esc_html__('Please complete the following required fields to save your changes:', 'simple-tags'); ?></div>
1033 <div id="taxopress-modal-alert-content"></div>
1034 <br>
1035 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('Okay', 'simple-tags'); ?></button>
1036 </div>
1037
1038 <div class="remodal" data-remodal-id="taxopress-modal-confirm"
1039 data-remodal-options="hashTracking: false, closeOnOutsideClick: false">
1040 <div id="taxopress-modal-confirm-content"></div>
1041 <br>
1042 <button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('No', 'simple-tags'); ?></button>
1043 <button data-remodal-action="confirm"
1044 class="remodal-confirm"><?php echo esc_html__('Yes', 'simple-tags'); ?></button>
1045 </div>
1046
1047 <?php
1048 do_action( 'simpletags-terms_display' );
1049 }
1050
1051 /**
1052 * Handle the AJAX request for previewing terms display.
1053 */
1054 public function handle_termsdisplay_preview() {
1055 // Validate nonce
1056 if (!isset($_POST['nonce']) || !check_ajax_referer('st-admin-js', 'nonce', false)) {
1057 wp_send_json_error(['message' => __('Invalid nonce', 'simple-tags')]);
1058 }
1059
1060 if (!current_user_can('simple_tags')) {
1061 wp_send_json_error(['message' => __('Permission denied.', 'simple-tags')]);
1062 }
1063
1064 if (!isset($_POST['taxopress_termsdisplay'])) {
1065 wp_send_json_error(['message' => __('Missing display ID.', 'simple-tags')]);
1066 }
1067
1068 $display_id = sanitize_text_field($_POST['taxopress_termsdisplay']);
1069
1070 // Get the display configuration
1071 $tagclouds = taxopress_get_tagcloud_data();
1072 if (!array_key_exists($display_id, $tagclouds)) {
1073 wp_send_json_error(['message' => __('Invalid terms display configuration.', 'simple-tags')]);
1074 }
1075
1076 $config = $tagclouds[$display_id];
1077
1078 // Create tag cloud client instance
1079 $client = new SimpleTags_Client_TagCloud();
1080
1081 // Convert config to query args format
1082 $args = http_build_query([
1083 'taxonomy' => $config['taxonomy'] ?? 'post_tag',
1084 'selectionby' => $config['selectionby'] ?? 'count',
1085 'selection' => $config['selection'] ?? 'desc',
1086 'orderby' => $config['orderby'] ?? 'random',
1087 'order' => $config['order'] ?? 'desc',
1088 'format' => $config['format'] ?? 'border',
1089 'number' => $config['max'] ?? 20,
1090 'largest' => $config['largest'] ?? 12,
1091 'smallest' => $config['smallest'] ?? 12,
1092 'unit' => $config['unit'] ?? 'pt',
1093 'color' => !empty($config['color']),
1094 'mincolor' => $config['mincolor'] ?? '#353535',
1095 'maxcolor' => $config['maxcolor'] ?? '#000000',
1096 'hide_empty' => !empty($config['hide_empty']),
1097 'hide_title' => !empty($config['hide_title']),
1098 'hide_output' => !empty($config['hide_output']),
1099 'notagstext' => !empty($config['notagstext']),
1100 'title' => $config['title'] ?? '',
1101 'exclude_terms'=> $config['exclude_terms'] ?? '',
1102 'hide_terms' => !empty($config['hide_terms']),
1103 'before' => $config['before'] ?? '',
1104 'after' => $config['after'] ?? '',
1105 'xformat' => $config['xformat'] ?? '',
1106 'wrap_class' => $config['wrap_class'] ?? '',
1107 'link_class' => $config['link_class'] ?? '',
1108 'parent_term' => $config['parent_term'] ?? 'all',
1109 'display_mode'=> $config['display_mode'] ?? 'parents_and_sub',
1110 'max' => $config['max'] ?? 20,
1111 'limit_days' => $config['limit_days'] ?? '',
1112 ]);
1113
1114 // Get the tag cloud output
1115 $output = $client->extendedTagCloud($args);
1116
1117 if (empty($output)) {
1118 if (!empty($config['hide_output'])) {
1119 wp_send_json_success(['html' => '']);
1120 }
1121 $notagstext = esc_html__('There are no terms in this taxonomy.', 'simple-tags');
1122 wp_send_json_success(['html' => '<p>' . $notagstext . '</p>']);
1123 }
1124
1125 wp_send_json_success(['html' => $output]);
1126 }
1127
1128 }
1129