| 1 |
<?php |
| 2 |
|
| 3 |
class SimpleTags_SuggestTerms |
| 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 |
// Javascript |
| 27 |
add_action('admin_enqueue_scripts', [__CLASS__, 'admin_enqueue_scripts'], 11); |
| 28 |
|
| 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_suggestterms') { |
| 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__('Suggest Terms', 'simple-tags'), |
| 72 |
esc_html__('Suggest Terms', 'simple-tags'), |
| 73 |
'simple_tags', |
| 74 |
'st_suggestterms', |
| 75 |
[ |
| 76 |
$this, |
| 77 |
'page_manage_suggestterms', |
| 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_suggestterms_per_page' |
| 97 |
]; |
| 98 |
|
| 99 |
add_screen_option($option, $args); |
| 100 |
|
| 101 |
$this->terms_table = new SuggestTerms_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_suggestterms() |
| 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('Suggest Terms', 'simple-tags'); ?></h1> |
| 126 |
<a href="<?php echo esc_url(admin_url('admin.php?page=st_suggestterms&add=new_item')); ?>" |
| 127 |
class="page-title-action"><?php esc_html_e('Add New', 'simple-tags'); ?></a> |
| 128 |
|
| 129 |
<div class="taxopress-description"> |
| 130 |
<?php esc_html_e('This feature helps when you\'re writing content. "Suggest Terms" can show a metabox where you can browse all your existing terms. "Suggest Terms" can also analyze your content and find new ideas for terms.', |
| 131 |
'simple-tags'); ?> |
| 132 |
</div> |
| 133 |
|
| 134 |
|
| 135 |
<?php |
| 136 |
if (isset($_REQUEST['s']) && $search = esc_attr(sanitize_text_field(wp_unslash($_REQUEST['s'])))) { |
| 137 |
/* translators: %s: search keywords */ |
| 138 |
printf(' <span class="subtitle">' . esc_html__('Search results for “%s”', |
| 139 |
'simple-tags') . '</span>', esc_html($search)); |
| 140 |
} |
| 141 |
?> |
| 142 |
<?php |
| 143 |
|
| 144 |
//the terms table instance |
| 145 |
$this->terms_table->prepare_items(); |
| 146 |
?> |
| 147 |
|
| 148 |
|
| 149 |
<hr class="wp-header-end"> |
| 150 |
<div id="ajax-response"></div> |
| 151 |
<form class="search-form wp-clearfix st-taxonomies-search-form" method="get"> |
| 152 |
<?php $this->terms_table->search_box(esc_html__('Search Suggest Terms', 'simple-tags'), 'term'); ?> |
| 153 |
</form> |
| 154 |
<div class="clear"></div> |
| 155 |
|
| 156 |
<div id="col-container" class="wp-clearfix"> |
| 157 |
|
| 158 |
<div class="col-wrap"> |
| 159 |
<form action="<?php echo esc_url(add_query_arg('', '')); ?>" method="post"> |
| 160 |
<?php $this->terms_table->display(); //Display the table ?> |
| 161 |
</form> |
| 162 |
<div class="form-wrap edit-term-notes"> |
| 163 |
<p><?php esc_html__('Description here.', 'simple-tags') ?></p> |
| 164 |
</div> |
| 165 |
</div> |
| 166 |
|
| 167 |
|
| 168 |
</div> |
| 169 |
|
| 170 |
|
| 171 |
</div> |
| 172 |
<?php } else { |
| 173 |
if ($_GET['add'] == 'new_item') { |
| 174 |
//add/edit taxonomy |
| 175 |
$this->taxopress_manage_suggestterms(); |
| 176 |
echo '<div>'; |
| 177 |
} |
| 178 |
} ?> |
| 179 |
|
| 180 |
|
| 181 |
<?php SimpleTags_Admin::printAdminFooter(); ?> |
| 182 |
</div> |
| 183 |
<?php |
| 184 |
} |
| 185 |
|
| 186 |
|
| 187 |
/** |
| 188 |
* Create our settings page output. |
| 189 |
* |
| 190 |
* @internal |
| 191 |
*/ |
| 192 |
public function taxopress_manage_suggestterms() |
| 193 |
{ |
| 194 |
|
| 195 |
$tab = (!empty($_GET) && !empty($_GET['action']) && 'edit' == $_GET['action']) ? 'edit' : 'new'; |
| 196 |
$tab_class = 'taxopress-' . $tab; |
| 197 |
$current = null; |
| 198 |
|
| 199 |
?> |
| 200 |
|
| 201 |
<div class="wrap <?php echo esc_attr($tab_class); ?>"> |
| 202 |
|
| 203 |
<?php |
| 204 |
|
| 205 |
$suggestterms = taxopress_get_suggestterm_data(); |
| 206 |
$suggestterm_edit = false; |
| 207 |
$suggestterm_limit = false; |
| 208 |
|
| 209 |
if ('edit' === $tab) { |
| 210 |
|
| 211 |
|
| 212 |
$selected_suggestterm = taxopress_get_current_suggestterm(); |
| 213 |
|
| 214 |
if ($selected_suggestterm && array_key_exists($selected_suggestterm, $suggestterms)) { |
| 215 |
$current = $suggestterms[$selected_suggestterm]; |
| 216 |
$suggestterm_edit = true; |
| 217 |
} |
| 218 |
|
| 219 |
} |
| 220 |
|
| 221 |
|
| 222 |
if (!isset($current['title']) && count($suggestterms) > 0 && apply_filters('taxopress_suggestterms_create_limit', |
| 223 |
true)) { |
| 224 |
$suggestterm_limit = true; |
| 225 |
} |
| 226 |
|
| 227 |
|
| 228 |
$ui = new taxopress_admin_ui(); |
| 229 |
?> |
| 230 |
|
| 231 |
|
| 232 |
<div class="wrap <?php echo esc_attr($tab_class); ?>"> |
| 233 |
<h1><?php echo esc_html__('Manage Suggest Terms', 'simple-tags'); ?></h1> |
| 234 |
<div class="wp-clearfix"></div> |
| 235 |
|
| 236 |
<form method="post" action=""> |
| 237 |
|
| 238 |
|
| 239 |
<div class="tagcloudui st-tabbed"> |
| 240 |
|
| 241 |
|
| 242 |
<div class="suggestterms-postbox-container"> |
| 243 |
<div id="poststuff"> |
| 244 |
<div class="taxopress-section postbox"> |
| 245 |
<div class="postbox-header"> |
| 246 |
<h2 class="hndle ui-sortable-handle"> |
| 247 |
<?php |
| 248 |
if ($suggestterm_edit) { |
| 249 |
$active_tab = (isset($current['active_tab']) && !empty(trim($current['active_tab']))) ? $current['active_tab'] : 'suggestterm_general'; |
| 250 |
echo esc_html__('Edit Suggest Terms', 'simple-tags'); |
| 251 |
echo '<input type="hidden" name="edited_suggestterm" value="' . esc_attr($current['ID']) . '" />'; |
| 252 |
echo '<input type="hidden" name="taxopress_suggestterm[ID]" value="' . esc_attr($current['ID']) . '" />'; |
| 253 |
echo '<input type="hidden" name="taxopress_suggestterm[active_tab]" class="taxopress-active-subtab" value="' . esc_attr($active_tab) . '" />'; |
| 254 |
} else { |
| 255 |
$active_tab = 'suggestterm_general'; |
| 256 |
echo '<input type="hidden" name="taxopress_suggestterm[active_tab]" class="taxopress-active-subtab" value="" />'; |
| 257 |
echo esc_html__('Add new Suggest Terms', 'simple-tags'); |
| 258 |
} |
| 259 |
?> |
| 260 |
</h2> |
| 261 |
</div> |
| 262 |
<div class="inside"> |
| 263 |
<div class="main"> |
| 264 |
|
| 265 |
|
| 266 |
<?php if ($suggestterm_limit) { |
| 267 |
echo '<div class="st-taxonomy-content"><div class="taxopress-warning upgrade-pro"> |
| 268 |
<p> |
| 269 |
|
| 270 |
<h2 style="margin-bottom: 5px;">' . esc_html__('To create more Suggest Terms, please upgrade to TaxoPress Pro.', |
| 271 |
'simple-tags') . '</h2> |
| 272 |
' . esc_html__('With TaxoPress Pro, you can create unlimited Suggest Terms. You can create Suggest Terms for any taxonomy.', |
| 273 |
'simple-tags') . ' |
| 274 |
|
| 275 |
</p> |
| 276 |
</div></div>'; |
| 277 |
|
| 278 |
} else { |
| 279 |
?> |
| 280 |
|
| 281 |
|
| 282 |
<ul class="taxopress-tab"> |
| 283 |
<li class="suggestterm_general_tab <?php echo $active_tab === 'suggestterm_general' ? 'active' : ''; ?>" |
| 284 |
data-content="suggestterm_general"> |
| 285 |
<a href="#suggestterm_general"><span><?php esc_html_e('General', |
| 286 |
'simple-tags'); ?></span></a> |
| 287 |
</li> |
| 288 |
|
| 289 |
<li class="suggestterm_external_tab <?php echo $active_tab === 'suggestterm_external' ? 'active' : ''; ?>" |
| 290 |
data-content="suggestterm_external"> |
| 291 |
<a href="#suggestterm_external"><span><?php esc_html_e('Automatic Term Suggestions', |
| 292 |
'simple-tags'); ?></span></a> |
| 293 |
</li> |
| 294 |
|
| 295 |
<li class="suggestterm_local_tab <?php echo $active_tab === 'suggestterm_local' ? 'active' : ''; ?>" |
| 296 |
data-content="suggestterm_local"> |
| 297 |
<a href="#suggestterm_local"><span><?php esc_html_e('Show Existing Terms', |
| 298 |
'simple-tags'); ?></span></a> |
| 299 |
</li> |
| 300 |
|
| 301 |
</ul> |
| 302 |
|
| 303 |
<div class="st-taxonomy-content taxopress-tab-content"> |
| 304 |
|
| 305 |
|
| 306 |
<table class="form-table taxopress-table suggestterm_general" |
| 307 |
style="<?php echo $active_tab === 'suggestterm_general' ? '' : 'display:none;'; ?>"> |
| 308 |
<?php |
| 309 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 310 |
echo $ui->get_tr_start(); |
| 311 |
|
| 312 |
|
| 313 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 314 |
echo $ui->get_th_start(); |
| 315 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 316 |
echo $ui->get_label('title', esc_html__('Title', 'simple-tags')) . $ui->get_required_span(); |
| 317 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 318 |
echo $ui->get_th_end() . $ui->get_td_start(); |
| 319 |
|
| 320 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 321 |
echo $ui->get_text_input([ |
| 322 |
'namearray' => 'taxopress_suggestterm', |
| 323 |
'name' => 'title', |
| 324 |
'textvalue' => isset($current['title']) ? esc_attr($current['title']) : '', |
| 325 |
'maxlength' => '32', |
| 326 |
'helptext' => '', |
| 327 |
'required' => true, |
| 328 |
'placeholder' => false, |
| 329 |
'wrap' => false, |
| 330 |
]); |
| 331 |
|
| 332 |
|
| 333 |
$options = []; |
| 334 |
foreach (get_all_taxopress_public_taxonomies() as $_taxonomy) { |
| 335 |
$_taxonomy = $_taxonomy->name; |
| 336 |
$tax = get_taxonomy($_taxonomy); |
| 337 |
if (empty($tax->labels->name)) { |
| 338 |
continue; |
| 339 |
} |
| 340 |
if ($tax->name === 'post_tag') { |
| 341 |
$options[] = [ |
| 342 |
'attr' => $tax->name, |
| 343 |
'text' => $tax->labels->name. ' ('.$tax->name.')', |
| 344 |
'default' => 'true', |
| 345 |
]; |
| 346 |
} else { |
| 347 |
$options[] = [ |
| 348 |
'attr' => $tax->name, |
| 349 |
'text' => $tax->labels->name. ' ('.$tax->name.')', |
| 350 |
]; |
| 351 |
} |
| 352 |
} |
| 353 |
|
| 354 |
$select = [ |
| 355 |
'options' => $options, |
| 356 |
]; |
| 357 |
$selected = isset($current) ? taxopress_disp_boolean($current['taxonomy']) : ''; |
| 358 |
$select['selected'] = !empty($selected) ? $current['taxonomy'] : ''; |
| 359 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 360 |
echo $ui->get_select_checkbox_input_main([ |
| 361 |
'namearray' => 'taxopress_suggestterm', |
| 362 |
'name' => 'taxonomy', |
| 363 |
'class' => 'st-post-taxonomy-select', |
| 364 |
'labeltext' => esc_html__('Default Taxonomy', 'simple-tags'), |
| 365 |
'required' => true, |
| 366 |
'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 367 |
]); |
| 368 |
|
| 369 |
|
| 370 |
/** |
| 371 |
* Filters the arguments for post types to list for taxonomy association. |
| 372 |
* |
| 373 |
* |
| 374 |
* @param array $value Array of default arguments. |
| 375 |
*/ |
| 376 |
$args = apply_filters('taxopress_attach_post_types_to_taxonomy', |
| 377 |
['public' => true]); |
| 378 |
|
| 379 |
// 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. |
| 380 |
if (!is_array($args)) { |
| 381 |
$args = ['public' => true]; |
| 382 |
} |
| 383 |
$output = 'objects'; // Or objects. |
| 384 |
|
| 385 |
/** |
| 386 |
* Filters the results returned to display for available post types for taxonomy. |
| 387 |
* |
| 388 |
* @param array $value Array of post type objects. |
| 389 |
* @param array $args Array of arguments for the post type query. |
| 390 |
* @param string $output The output type we want for the results. |
| 391 |
*/ |
| 392 |
$post_types = apply_filters('taxopress_get_post_types_for_taxonomies', |
| 393 |
get_post_types($args, $output), $args, $output); |
| 394 |
|
| 395 |
$term_auto_locations = []; |
| 396 |
foreach ($post_types as $post_type) { |
| 397 |
$term_auto_locations[$post_type->name] = $post_type->label; |
| 398 |
} |
| 399 |
|
| 400 |
echo '<tr valign="top"><th scope="row"><label>' . esc_html__('Post Types', |
| 401 |
'simple-tags') . '</label> </th><td> |
| 402 |
<table class="visbile-table">'; |
| 403 |
foreach ($term_auto_locations as $key => $value) { |
| 404 |
|
| 405 |
|
| 406 |
echo '<tr valign="top"><th scope="row"><label for="' . esc_attr($key) . '">' . esc_html($value) . '</label></th><td>'; |
| 407 |
|
| 408 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 409 |
echo $ui->get_check_input([ |
| 410 |
'checkvalue' => esc_attr($key), |
| 411 |
'checked' => (!empty($current['post_types']) && is_array($current['post_types']) && in_array($key, |
| 412 |
$current['post_types'], true)) ? 'true' : 'false', |
| 413 |
'name' => esc_attr($key), |
| 414 |
'namearray' => 'post_types', |
| 415 |
'textvalue' => esc_attr($key), |
| 416 |
'labeltext' => "", |
| 417 |
'wrap' => false, |
| 418 |
]); |
| 419 |
|
| 420 |
echo '</td></tr>'; |
| 421 |
|
| 422 |
|
| 423 |
} |
| 424 |
echo '</table></td></tr>'; |
| 425 |
|
| 426 |
|
| 427 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 428 |
echo $ui->get_td_end() . $ui->get_tr_end(); |
| 429 |
?> |
| 430 |
</table> |
| 431 |
|
| 432 |
|
| 433 |
<table class="form-table taxopress-table suggestterm_local" |
| 434 |
style="<?php echo $active_tab === 'suggestterm_local' ? '' : 'display:none;'; ?>"> |
| 435 |
|
| 436 |
<tr valign="top"><td style="padding-left: 0;" colspan="2"><?php echo esc_html__('This feature shows a metabox where you can browse all your existing terms.', 'simple-tags'); ?></td></tr> |
| 437 |
|
| 438 |
<?php |
| 439 |
|
| 440 |
$select = [ |
| 441 |
'options' => [ |
| 442 |
[ |
| 443 |
'attr' => '0', |
| 444 |
'text' => esc_attr__('False', 'simple-tags'), |
| 445 |
'default' => 'true', |
| 446 |
], |
| 447 |
[ |
| 448 |
'attr' => '1', |
| 449 |
'text' => esc_attr__('True', 'simple-tags'), |
| 450 |
], |
| 451 |
], |
| 452 |
]; |
| 453 |
$selected = (isset($current) && isset($current['enable_existing_terms'])) ? taxopress_disp_boolean($current['enable_existing_terms']) : ''; |
| 454 |
$select['selected'] = !empty($selected) ? $current['enable_existing_terms'] : ''; |
| 455 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 456 |
echo $ui->get_select_checkbox_input([ |
| 457 |
'namearray' => 'taxopress_suggestterm', |
| 458 |
'name' => 'enable_existing_terms', |
| 459 |
'labeltext' => esc_html__('Show existing terms', 'simple-tags'), |
| 460 |
'aftertext' => '', |
| 461 |
'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 462 |
]); |
| 463 |
|
| 464 |
if (!isset($current)) { |
| 465 |
$maximum_terms = 100; |
| 466 |
} else { |
| 467 |
$maximum_terms = isset($current['number']) ? esc_attr($current['number']) : '0'; |
| 468 |
} |
| 469 |
|
| 470 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 471 |
echo $ui->get_number_input([ |
| 472 |
'namearray' => 'taxopress_suggestterm', |
| 473 |
'name' => 'number', |
| 474 |
'textvalue' => (int)$maximum_terms, |
| 475 |
'labeltext' => esc_html__('Maximum terms', 'simple-tags'), |
| 476 |
'helptext' => esc_html__('Set (0) for no limit.', 'simple-tags'), |
| 477 |
'min' => '0', |
| 478 |
'required' => true, |
| 479 |
]); |
| 480 |
|
| 481 |
|
| 482 |
$select = [ |
| 483 |
'options' => [ |
| 484 |
[ |
| 485 |
'attr' => 'name', |
| 486 |
'text' => esc_attr__('Name', 'simple-tags') |
| 487 |
], |
| 488 |
[ |
| 489 |
'attr' => 'count', |
| 490 |
'text' => esc_attr__('Counter', 'simple-tags'), |
| 491 |
'default' => 'true' |
| 492 |
], |
| 493 |
[ |
| 494 |
'attr' => 'random', |
| 495 |
'text' => esc_attr__('Random', 'simple-tags') |
| 496 |
], |
| 497 |
], |
| 498 |
]; |
| 499 |
$selected = isset($current) ? taxopress_disp_boolean($current['orderby']) : ''; |
| 500 |
$select['selected'] = !empty($selected) ? $current['orderby'] : ''; |
| 501 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 502 |
echo $ui->get_select_checkbox_input_main([ |
| 503 |
'namearray' => 'taxopress_suggestterm', |
| 504 |
'name' => 'orderby', |
| 505 |
'labeltext' => esc_html__('Method for choosing terms', |
| 506 |
'simple-tags'), |
| 507 |
'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 508 |
]); |
| 509 |
|
| 510 |
|
| 511 |
$select = [ |
| 512 |
'options' => [ |
| 513 |
[ |
| 514 |
'attr' => 'asc', |
| 515 |
'text' => esc_attr__('Ascending', 'simple-tags') |
| 516 |
], |
| 517 |
[ |
| 518 |
'attr' => 'desc', |
| 519 |
'text' => esc_attr__('Descending', 'simple-tags'), |
| 520 |
'default' => 'true' |
| 521 |
], |
| 522 |
], |
| 523 |
]; |
| 524 |
$selected = isset($current) ? taxopress_disp_boolean($current['order']) : ''; |
| 525 |
$select['selected'] = !empty($selected) ? $current['order'] : ''; |
| 526 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 527 |
echo $ui->get_select_checkbox_input_main([ |
| 528 |
'namearray' => 'taxopress_suggestterm', |
| 529 |
'name' => 'order', |
| 530 |
'labeltext' => esc_html__('Ordering for choosing terms', |
| 531 |
'simple-tags'), |
| 532 |
'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 533 |
]); |
| 534 |
|
| 535 |
|
| 536 |
?> |
| 537 |
</table> |
| 538 |
|
| 539 |
|
| 540 |
<table class="form-table taxopress-table suggestterm_external" |
| 541 |
style="<?php echo $active_tab === 'suggestterm_external' ? '' : 'display:none;'; ?>"> |
| 542 |
|
| 543 |
|
| 544 |
<tr class="suggestterm_external_description" valign="top"><td style="padding-left: 0;" colspan="2"><?php echo esc_html__('This feature shows a metabox that can analyze your content and find ideas for terms.', 'simple-tags'); ?></td></tr> |
| 545 |
|
| 546 |
<?php |
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
if(!isset($current)){ |
| 551 |
$select = [ |
| 552 |
'options' => [ |
| 553 |
[ |
| 554 |
'attr' => '0', |
| 555 |
'text' => esc_attr__('False', 'simple-tags'), |
| 556 |
], |
| 557 |
[ |
| 558 |
'attr' => '1', |
| 559 |
'text' => esc_attr__('True', 'simple-tags'), |
| 560 |
'default' => 'true', |
| 561 |
], |
| 562 |
], |
| 563 |
]; |
| 564 |
}else{ |
| 565 |
$select = [ |
| 566 |
'options' => [ |
| 567 |
[ |
| 568 |
'attr' => '0', |
| 569 |
'text' => esc_attr__('False', 'simple-tags'), |
| 570 |
'default' => 'true', |
| 571 |
], |
| 572 |
[ |
| 573 |
'attr' => '1', |
| 574 |
'text' => esc_attr__('True', 'simple-tags'), |
| 575 |
], |
| 576 |
], |
| 577 |
]; |
| 578 |
|
| 579 |
} |
| 580 |
|
| 581 |
$selected = (isset($current) && isset($current['suggest_term_use_local'])) ? taxopress_disp_boolean($current['suggest_term_use_local']) : ''; |
| 582 |
$select['selected'] = !empty($selected) ? $current['suggest_term_use_local'] : ''; |
| 583 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 584 |
echo $ui->get_select_checkbox_input([ |
| 585 |
'namearray' => 'taxopress_suggestterm', |
| 586 |
'name' => 'suggest_term_use_local', |
| 587 |
'class' => 'suggest_term_use_local', |
| 588 |
'labeltext' => esc_html__('Suggest existing terms on your site', 'simple-tags'), |
| 589 |
'aftertext' => '', |
| 590 |
'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 591 |
]); |
| 592 |
|
| 593 |
|
| 594 |
$select = [ |
| 595 |
'options' => [ |
| 596 |
[ |
| 597 |
'attr' => '0', |
| 598 |
'text' => esc_attr__('False', 'simple-tags'), |
| 599 |
'default' => 'true', |
| 600 |
], |
| 601 |
[ |
| 602 |
'attr' => '1', |
| 603 |
'text' => esc_attr__('True', 'simple-tags'), |
| 604 |
], |
| 605 |
], |
| 606 |
]; |
| 607 |
$selected = (isset($current) && isset($current['suggest_term_use_dandelion'])) ? taxopress_disp_boolean($current['suggest_term_use_dandelion']) : ''; |
| 608 |
$select['selected'] = !empty($selected) ? $current['suggest_term_use_dandelion'] : ''; |
| 609 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 610 |
echo $ui->get_select_checkbox_input([ |
| 611 |
'namearray' => 'taxopress_suggestterm', |
| 612 |
'name' => 'suggest_term_use_dandelion', |
| 613 |
'class' => 'suggest_term_use_dandelion', |
| 614 |
'labeltext' => esc_html__('Suggest new terms from the Dandelion service', |
| 615 |
'simple-tags'), |
| 616 |
'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 617 |
]); |
| 618 |
|
| 619 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 620 |
echo $ui->get_text_input([ |
| 621 |
'namearray' => 'taxopress_suggestterm', |
| 622 |
'name' => 'terms_datatxt_access_token', |
| 623 |
'class' => 'terms_datatxt_access_token', |
| 624 |
'textvalue' => isset($current['terms_datatxt_access_token']) ? esc_attr($current['terms_datatxt_access_token']) : '', |
| 625 |
'labeltext' => esc_html__('Dandelion API token', 'simple-tags'), |
| 626 |
'helptext' => sprintf(esc_html__('You need an API key to use Dandelion to suggest terms. %1sClick here for documentation.%2s.', 'simple-tags'), '<a target="blank" href="https://taxopress.com/docs/dandelion-api/">', '</a>'), |
| 627 |
'required' => false, |
| 628 |
]); |
| 629 |
|
| 630 |
if (!isset($current)) { |
| 631 |
$terms_datatxt_min_confidence = '0.6'; |
| 632 |
} else { |
| 633 |
$terms_datatxt_min_confidence = isset($current['terms_datatxt_min_confidence']) ? esc_attr($current['terms_datatxt_min_confidence']) : '0'; |
| 634 |
} |
| 635 |
|
| 636 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 637 |
echo $ui->get_number_input([ |
| 638 |
'namearray' => 'taxopress_suggestterm', |
| 639 |
'name' => 'terms_datatxt_min_confidence', |
| 640 |
'class' => 'terms_datatxt_min_confidence', |
| 641 |
'textvalue' => esc_html($terms_datatxt_min_confidence), |
| 642 |
'labeltext' => esc_html__('Dandelion API confidence value', 'simple-tags'), |
| 643 |
'helptext' => esc_html__('Choose a value between 0 and 1. A high value such as 0.8 will provide a few, accurate suggestions. A low value such as 0.2 will produce more suggestions, but they may be less accurate.', |
| 644 |
'simple-tags'), |
| 645 |
'min' => '0', |
| 646 |
'max' => '1', |
| 647 |
'other_attr' => 'step=".1"', |
| 648 |
'required' => false, |
| 649 |
]); |
| 650 |
|
| 651 |
|
| 652 |
$select = [ |
| 653 |
'options' => [ |
| 654 |
[ |
| 655 |
'attr' => '0', |
| 656 |
'text' => esc_attr__('False', 'simple-tags'), |
| 657 |
'default' => 'true', |
| 658 |
], |
| 659 |
[ |
| 660 |
'attr' => '1', |
| 661 |
'text' => esc_attr__('True', 'simple-tags'), |
| 662 |
], |
| 663 |
], |
| 664 |
]; |
| 665 |
$selected = (isset($current) && isset($current['suggest_term_use_opencalais'])) ? taxopress_disp_boolean($current['suggest_term_use_opencalais']) : ''; |
| 666 |
$select['selected'] = !empty($selected) ? $current['suggest_term_use_opencalais'] : ''; |
| 667 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 668 |
echo $ui->get_select_checkbox_input([ |
| 669 |
'namearray' => 'taxopress_suggestterm', |
| 670 |
'name' => 'suggest_term_use_opencalais', |
| 671 |
'class' => 'suggest_term_use_opencalais', |
| 672 |
'labeltext' => esc_html__('Suggest new terms from the Open Calais service', |
| 673 |
'simple-tags'), |
| 674 |
'selections' => $select,// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 675 |
]); |
| 676 |
|
| 677 |
// phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 678 |
echo $ui->get_text_input([ |
| 679 |
'namearray' => 'taxopress_suggestterm', |
| 680 |
'name' => 'terms_opencalais_key', |
| 681 |
'class' => 'terms_opencalais_key', |
| 682 |
'textvalue' => isset($current['terms_opencalais_key']) ? esc_attr($current['terms_opencalais_key']) : '', |
| 683 |
'labeltext' => esc_html__('OpenCalais API Key', 'simple-tags'), |
| 684 |
'helptext' => sprintf(esc_html__('You need an API key to use OpenCalais to suggest terms. %1sClick here for documentation.%2s.', 'simple-tags'), '<a target="blank" href="https://taxopress.com/docs/opencalais/">', '</a>'), |
| 685 |
'required' => false, |
| 686 |
]); |
| 687 |
|
| 688 |
|
| 689 |
?> |
| 690 |
|
| 691 |
</table> |
| 692 |
|
| 693 |
|
| 694 |
</div> |
| 695 |
|
| 696 |
|
| 697 |
<?php }//end new fields |
| 698 |
?> |
| 699 |
|
| 700 |
|
| 701 |
<div class="clear"></div> |
| 702 |
|
| 703 |
|
| 704 |
</div> |
| 705 |
</div> |
| 706 |
</div> |
| 707 |
|
| 708 |
|
| 709 |
<?php if ($suggestterm_limit) { ?> |
| 710 |
|
| 711 |
<div class="pp-version-notice-bold-purple" style="margin-left:0px;"> |
| 712 |
<div class="pp-version-notice-bold-purple-message"><?php echo esc_html__('You\'re using TaxoPress Free. |
| 713 |
The Pro version has more features and support.', |
| 714 |
'simple-tags'); ?> |
| 715 |
</div> |
| 716 |
<div class="pp-version-notice-bold-purple-button"><a |
| 717 |
href="https://taxopress.com/pro" target="_blank"><?php echo esc_html__('Upgrade to Pro', |
| 718 |
'simple-tags'); ?></a> |
| 719 |
</div> |
| 720 |
</div> |
| 721 |
|
| 722 |
<?php } ?> |
| 723 |
<?php |
| 724 |
/** |
| 725 |
* Fires after the default fieldsets on the taxonomy screen. |
| 726 |
* |
| 727 |
* @param taxopress_admin_ui $ui Admin UI instance. |
| 728 |
*/ |
| 729 |
do_action('taxopress_taxonomy_after_fieldsets', $ui); |
| 730 |
?> |
| 731 |
|
| 732 |
</div> |
| 733 |
</div> |
| 734 |
|
| 735 |
|
| 736 |
</div> |
| 737 |
|
| 738 |
<div class="taxopress-right-sidebar"> |
| 739 |
<div class="taxopress-right-sidebar-wrapper" style="min-height: 205px;"> |
| 740 |
|
| 741 |
|
| 742 |
<?php |
| 743 |
if (!$suggestterm_limit) { ?> |
| 744 |
<p class="submit"> |
| 745 |
|
| 746 |
<?php |
| 747 |
wp_nonce_field('taxopress_addedit_suggestterm_nonce_action', |
| 748 |
'taxopress_addedit_suggestterm_nonce_field'); |
| 749 |
if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?> |
| 750 |
<input type="submit" |
| 751 |
class="button-primary taxopress-taxonomy-submit taxopress-suggestterm-submit" |
| 752 |
name="suggestterm_submit" |
| 753 |
value="<?php echo esc_attr(esc_attr__('Save Suggest Terms', |
| 754 |
'simple-tags')); ?>"/> |
| 755 |
<?php |
| 756 |
} else { ?> |
| 757 |
<input type="submit" |
| 758 |
class="button-primary taxopress-taxonomy-submit taxopress-suggestterm-submit" |
| 759 |
name="suggestterm_submit" |
| 760 |
value="<?php echo esc_attr(esc_attr__('Add Suggest Terms', |
| 761 |
'simple-tags')); ?>"/> |
| 762 |
<?php } ?> |
| 763 |
|
| 764 |
|
| 765 |
<input type="hidden" name="cpt_tax_status" id="cpt_tax_status" |
| 766 |
value="<?php echo esc_attr($tab); ?>"/> |
| 767 |
</p> |
| 768 |
|
| 769 |
<?php |
| 770 |
} |
| 771 |
?> |
| 772 |
|
| 773 |
</div> |
| 774 |
|
| 775 |
<?php do_action('taxopress_admin_after_sidebar'); ?> |
| 776 |
</div> |
| 777 |
|
| 778 |
<div class="clear"></div> |
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
</form> |
| 783 |
|
| 784 |
</div><!-- End .wrap --> |
| 785 |
|
| 786 |
<div class="clear"></div> |
| 787 |
|
| 788 |
<?php # Modal Windows; |
| 789 |
?> |
| 790 |
<div class="remodal" data-remodal-id="taxopress-modal-alert" |
| 791 |
data-remodal-options="hashTracking: false, closeOnOutsideClick: false"> |
| 792 |
<div class="" |
| 793 |
style="color:red;"><?php echo esc_html__('Please complete the following required fields to save your changes:', |
| 794 |
'simple-tags'); ?></div> |
| 795 |
<div id="taxopress-modal-alert-content"></div> |
| 796 |
<br> |
| 797 |
<button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('Okay', |
| 798 |
'simple-tags'); ?></button> |
| 799 |
</div> |
| 800 |
|
| 801 |
<div class="remodal" data-remodal-id="taxopress-modal-confirm" |
| 802 |
data-remodal-options="hashTracking: false, closeOnOutsideClick: false"> |
| 803 |
<div id="taxopress-modal-confirm-content"></div> |
| 804 |
<br> |
| 805 |
<button data-remodal-action="cancel" class="remodal-cancel"><?php echo esc_html__('No', 'simple-tags'); ?></button> |
| 806 |
<button data-remodal-action="confirm" |
| 807 |
class="remodal-confirm"><?php echo esc_html__('Yes', 'simple-tags'); ?></button> |
| 808 |
</div> |
| 809 |
|
| 810 |
<?php |
| 811 |
} |
| 812 |
|
| 813 |
} |
| 814 |
|