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