| 1 |
<?php |
| 2 |
|
| 3 |
class SimpleTags_Autoterms |
| 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_autoterms') { |
| 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 |
__('Auto Terms', 'simple-tags'), |
| 72 |
__('Auto Terms', 'simple-tags'), |
| 73 |
'simple_tags', |
| 74 |
'st_autoterms', |
| 75 |
[ |
| 76 |
$this, |
| 77 |
'page_manage_autoterms', |
| 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' => __('Number of items per page', 'simple-tags'), |
| 95 |
'default' => 20, |
| 96 |
'option' => 'st_autoterms_per_page' |
| 97 |
]; |
| 98 |
|
| 99 |
add_screen_option($option, $args); |
| 100 |
|
| 101 |
$this->terms_table = new Autoterms_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_autoterms() |
| 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 _e('Auto Terms', 'simple-tags'); ?></h1> |
| 126 |
<a href="<?php echo esc_url(admin_url('admin.php?page=st_autoterms&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('Auto Terms can scan your content and automatically assign terms. For example, you have a term called "WordPress". Auto Terms can analyze your posts and when it finds the word "WordPress", it can add that term to your post.', 'simple-tags'); ?> |
| 131 |
</div> |
| 132 |
|
| 133 |
|
| 134 |
<?php |
| 135 |
if (isset($_REQUEST['s']) && $search = esc_attr(wp_unslash($_REQUEST['s']))) { |
| 136 |
/* translators: %s: search keywords */ |
| 137 |
printf(' <span class="subtitle">' . __('Search results for “%s”', |
| 138 |
'simple-tags') . '</span>', $search); |
| 139 |
} |
| 140 |
?> |
| 141 |
<?php |
| 142 |
|
| 143 |
//the terms table instance |
| 144 |
$this->terms_table->prepare_items(); |
| 145 |
?> |
| 146 |
|
| 147 |
|
| 148 |
<hr class="wp-header-end"> |
| 149 |
<div id="ajax-response"></div> |
| 150 |
<form class="search-form wp-clearfix st-taxonomies-search-form" method="get"> |
| 151 |
<?php $this->terms_table->search_box(__('Search Auto Terms', 'simple-tags'), 'term'); ?> |
| 152 |
</form> |
| 153 |
<div class="clear"></div> |
| 154 |
|
| 155 |
<div id="col-container" class="wp-clearfix"> |
| 156 |
|
| 157 |
<div class="col-wrap"> |
| 158 |
<form action="<?php echo add_query_arg('', '') ?>" method="post"> |
| 159 |
<?php $this->terms_table->display(); //Display the table ?> |
| 160 |
</form> |
| 161 |
<div class="form-wrap edit-term-notes"> |
| 162 |
<p><?php __('Description here.', 'simple-tags') ?></p> |
| 163 |
</div> |
| 164 |
</div> |
| 165 |
|
| 166 |
|
| 167 |
</div> |
| 168 |
|
| 169 |
|
| 170 |
</div> |
| 171 |
<?php } else { |
| 172 |
if ($_GET['add'] == 'new_item') { |
| 173 |
//add/edit taxonomy |
| 174 |
$this->taxopress_manage_autoterms(); |
| 175 |
echo '<div>'; |
| 176 |
} |
| 177 |
} ?> |
| 178 |
|
| 179 |
|
| 180 |
<?php SimpleTags_Admin::printAdminFooter(); ?> |
| 181 |
</div> |
| 182 |
<?php |
| 183 |
} |
| 184 |
|
| 185 |
|
| 186 |
/** |
| 187 |
* Create our settings page output. |
| 188 |
* |
| 189 |
* @internal |
| 190 |
*/ |
| 191 |
public function taxopress_manage_autoterms() |
| 192 |
{ |
| 193 |
|
| 194 |
$tab = (!empty($_GET) && !empty($_GET['action']) && 'edit' == $_GET['action']) ? 'edit' : 'new'; |
| 195 |
$tab_class = 'taxopress-' . $tab; |
| 196 |
$current = null; |
| 197 |
|
| 198 |
?> |
| 199 |
|
| 200 |
<div class="wrap <?php echo esc_attr($tab_class); ?>"> |
| 201 |
|
| 202 |
<?php |
| 203 |
|
| 204 |
$autoterms = taxopress_get_autoterm_data(); |
| 205 |
$autoterm_edit = false; |
| 206 |
$autoterm_limit = false; |
| 207 |
|
| 208 |
if ('edit' === $tab) { |
| 209 |
|
| 210 |
|
| 211 |
$selected_autoterm = taxopress_get_current_autoterm(); |
| 212 |
|
| 213 |
if ($selected_autoterm && array_key_exists($selected_autoterm, $autoterms)) { |
| 214 |
$current = $autoterms[$selected_autoterm]; |
| 215 |
$autoterm_edit = true; |
| 216 |
} |
| 217 |
|
| 218 |
} |
| 219 |
|
| 220 |
|
| 221 |
if (!isset($current['title']) && count($autoterms) > 0 && apply_filters('taxopress_autoterms_create_limit', true)) { |
| 222 |
$autoterm_limit = true; |
| 223 |
} |
| 224 |
|
| 225 |
|
| 226 |
$ui = new taxopress_admin_ui(); |
| 227 |
?> |
| 228 |
|
| 229 |
|
| 230 |
<div class="wrap <?php echo esc_attr($tab_class); ?>"> |
| 231 |
<h1><?php echo __('Manage Auto Terms', 'simple-tags'); ?></h1> |
| 232 |
<div class="wp-clearfix"></div> |
| 233 |
|
| 234 |
<form method="post" action=""> |
| 235 |
|
| 236 |
|
| 237 |
<div class="tagcloudui st-tabbed"> |
| 238 |
|
| 239 |
|
| 240 |
<div class="autoterms-postbox-container"> |
| 241 |
<div id="poststuff"> |
| 242 |
<div class="taxopress-section postbox"> |
| 243 |
<div class="postbox-header"> |
| 244 |
<h2 class="hndle ui-sortable-handle"> |
| 245 |
<?php |
| 246 |
if ($autoterm_edit) { |
| 247 |
$active_tab = ( isset($current['active_tab']) && !empty(trim($current['active_tab'])) ) ? $current['active_tab'] : 'autoterm_general'; |
| 248 |
echo esc_html__('Edit Auto Terms', 'simple-tags'); |
| 249 |
echo '<input type="hidden" name="edited_autoterm" value="' . $current['ID'] . '" />'; |
| 250 |
echo '<input type="hidden" name="taxopress_autoterm[ID]" value="' . $current['ID'] . '" />'; |
| 251 |
echo '<input type="hidden" name="taxopress_autoterm[active_tab]" class="taxopress-active-subtab" value="'.$active_tab.'" />'; |
| 252 |
} else { |
| 253 |
$active_tab = 'autoterm_general'; |
| 254 |
echo '<input type="hidden" name="taxopress_autoterm[active_tab]" class="taxopress-active-subtab" value="" />'; |
| 255 |
echo esc_html__('Add new Auto Terms', 'simple-tags'); |
| 256 |
} |
| 257 |
?> |
| 258 |
</h2> |
| 259 |
</div> |
| 260 |
<div class="inside"> |
| 261 |
<div class="main"> |
| 262 |
|
| 263 |
|
| 264 |
<?php if ($autoterm_limit) { |
| 265 |
echo '<div class="st-taxonomy-content"><div class="taxopress-warning upgrade-pro"> |
| 266 |
<p> |
| 267 |
|
| 268 |
<h2 style="margin-bottom: 5px;">' . __('To create more Auto Terms, please upgrade to TaxoPress Pro.', |
| 269 |
'simple-tags') . '</h2> |
| 270 |
' . __('With TaxoPress Pro, you can create unlimited Auto Terms. You can create Auto Terms for any taxonomy.', |
| 271 |
'simple-tags') . ' |
| 272 |
|
| 273 |
</p> |
| 274 |
</div></div>'; |
| 275 |
|
| 276 |
} else { |
| 277 |
?> |
| 278 |
|
| 279 |
|
| 280 |
<ul class="taxopress-tab"> |
| 281 |
<li class="autoterm_general_tab <?php echo $active_tab === 'autoterm_general' ? 'active' : ''; ?>" data-content="autoterm_general"> |
| 282 |
<a href="#autoterm_general"><span><?php esc_html_e('General', |
| 283 |
'simple-tags'); ?></span></a> |
| 284 |
</li> |
| 285 |
|
| 286 |
<li class="autoterm_terms_tab <?php echo $active_tab === 'autoterm_terms' ? 'active' : ''; ?>" data-content="autoterm_terms"> |
| 287 |
<a href="#autoterm_terms"><span><?php esc_html_e('Terms to Use', |
| 288 |
'simple-tags'); ?></span></a> |
| 289 |
</li> |
| 290 |
|
| 291 |
<li class="autoterm_options_tab <?php echo $active_tab === 'autoterm_options' ? 'active' : ''; ?>" data-content="autoterm_options"> |
| 292 |
<a href="#autoterm_options"><span><?php esc_html_e('Options', |
| 293 |
'simple-tags'); ?></span></a> |
| 294 |
</li> |
| 295 |
|
| 296 |
<li class="autoterm_oldcontent_tab <?php echo $active_tab === 'autoterm_oldcontent' ? 'active' : ''; ?>" data-content="autoterm_oldcontent"> |
| 297 |
<a href="#autoterm_oldcontent"><span><?php esc_html_e('Existing Content', |
| 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 autoterm_general" |
| 307 |
style="<?php echo $active_tab === 'autoterm_general' ? '' : 'display:none;'; ?>"> |
| 308 |
<?php |
| 309 |
echo $ui->get_tr_start(); |
| 310 |
|
| 311 |
|
| 312 |
echo $ui->get_th_start(); |
| 313 |
echo $ui->get_label('title', esc_html__('Title', |
| 314 |
'simple-tags')) . $ui->get_required_span(); |
| 315 |
echo $ui->get_th_end() . $ui->get_td_start(); |
| 316 |
|
| 317 |
echo $ui->get_text_input([ |
| 318 |
'namearray' => 'taxopress_autoterm', |
| 319 |
'name' => 'title', |
| 320 |
'textvalue' => isset($current['title']) ? esc_attr($current['title']) : '', |
| 321 |
'maxlength' => '32', |
| 322 |
'helptext' => '', |
| 323 |
'required' => true, |
| 324 |
'placeholder' => false, |
| 325 |
'wrap' => false, |
| 326 |
]); |
| 327 |
|
| 328 |
|
| 329 |
$options = []; |
| 330 |
foreach (get_all_taxopress_public_taxonomies() as $_taxonomy) { |
| 331 |
$_taxonomy = $_taxonomy->name; |
| 332 |
$tax = get_taxonomy($_taxonomy); |
| 333 |
if (empty($tax->labels->name)) { |
| 334 |
continue; |
| 335 |
} |
| 336 |
if ($tax->name === 'post_tag') { |
| 337 |
$options[] = [ |
| 338 |
'attr' => $tax->name, |
| 339 |
'text' => $tax->labels->name, |
| 340 |
'default' => 'true', |
| 341 |
]; |
| 342 |
} else { |
| 343 |
$options[] = [ |
| 344 |
'attr' => $tax->name, |
| 345 |
'text' => $tax->labels->name, |
| 346 |
]; |
| 347 |
} |
| 348 |
} |
| 349 |
|
| 350 |
$select = [ |
| 351 |
'options' => $options, |
| 352 |
]; |
| 353 |
$selected = isset($current) ? taxopress_disp_boolean($current['taxonomy']) : ''; |
| 354 |
$select['selected'] = !empty($selected) ? $current['taxonomy'] : ''; |
| 355 |
echo $ui->get_select_checkbox_input_main([ |
| 356 |
'namearray' => 'taxopress_autoterm', |
| 357 |
'name' => 'taxonomy', |
| 358 |
'class' => 'st-post-taxonomy-select', |
| 359 |
'labeltext' => esc_html__('Taxonomy', 'simple-tags'), |
| 360 |
'required' => true, |
| 361 |
'selections' => $select, |
| 362 |
]); |
| 363 |
|
| 364 |
|
| 365 |
$select = [ |
| 366 |
'options' => [ |
| 367 |
[ |
| 368 |
'attr' => 'post_content', |
| 369 |
'text' => esc_attr__('Post Content', 'simple-tags') |
| 370 |
], |
| 371 |
[ |
| 372 |
'attr' => 'post_title', |
| 373 |
'text' => esc_attr__('Post Title', 'simple-tags') |
| 374 |
], |
| 375 |
[ |
| 376 |
'attr' => 'posts', |
| 377 |
'text' => esc_attr__('Post Content and Title', |
| 378 |
'simple-tags'), |
| 379 |
'default' => 'true' |
| 380 |
] |
| 381 |
], |
| 382 |
]; |
| 383 |
$selected = (isset($current) && isset($current['autoterm_from'])) ? taxopress_disp_boolean($current['autoterm_from']) : ''; |
| 384 |
$select['selected'] = !empty($selected) ? $current['autoterm_from'] : ''; |
| 385 |
echo $ui->get_select_checkbox_input_main([ |
| 386 |
'namearray' => 'taxopress_autoterm', |
| 387 |
'name' => 'autoterm_from', |
| 388 |
'labeltext' => esc_html__('Find term in:', |
| 389 |
'simple-tags'), |
| 390 |
'selections' => $select, |
| 391 |
]); |
| 392 |
|
| 393 |
|
| 394 |
/** |
| 395 |
* Filters the arguments for post types to list for taxonomy association. |
| 396 |
* |
| 397 |
* |
| 398 |
* @param array $value Array of default arguments. |
| 399 |
*/ |
| 400 |
$args = apply_filters('taxopress_attach_post_types_to_taxonomy', |
| 401 |
['public' => true]); |
| 402 |
|
| 403 |
// 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. |
| 404 |
if (!is_array($args)) { |
| 405 |
$args = ['public' => true]; |
| 406 |
} |
| 407 |
$output = 'objects'; // Or objects. |
| 408 |
|
| 409 |
/** |
| 410 |
* Filters the results returned to display for available post types for taxonomy. |
| 411 |
* |
| 412 |
* @param array $value Array of post type objects. |
| 413 |
* @param array $args Array of arguments for the post type query. |
| 414 |
* @param string $output The output type we want for the results. |
| 415 |
*/ |
| 416 |
$post_types = apply_filters('taxopress_get_post_types_for_taxonomies', |
| 417 |
get_post_types($args, $output), $args, $output); |
| 418 |
|
| 419 |
$term_auto_locations = []; |
| 420 |
foreach ($post_types as $post_type) { |
| 421 |
$term_auto_locations[$post_type->name] = $post_type->label; |
| 422 |
} |
| 423 |
|
| 424 |
echo '<tr valign="top"><th scope="row"><label>' . esc_html__('Post Types', |
| 425 |
'simple-tags') . '</label> </th><td> |
| 426 |
<table class="visbile-table">'; |
| 427 |
foreach ($term_auto_locations as $key => $value) { |
| 428 |
|
| 429 |
|
| 430 |
echo '<tr valign="top"><th scope="row"><label for="' . $key . '">' . $value . '</label></th><td>'; |
| 431 |
|
| 432 |
echo $ui->get_check_input([ |
| 433 |
'checkvalue' => $key, |
| 434 |
'checked' => (!empty($current['post_types']) && is_array($current['post_types']) && in_array($key, |
| 435 |
$current['post_types'], true)) ? 'true' : 'false', |
| 436 |
'name' => $key, |
| 437 |
'namearray' => 'post_types', |
| 438 |
'textvalue' => $key, |
| 439 |
'labeltext' => "", |
| 440 |
'wrap' => false, |
| 441 |
]); |
| 442 |
|
| 443 |
echo '</td></tr>'; |
| 444 |
|
| 445 |
|
| 446 |
} |
| 447 |
echo '</table></td></tr>'; |
| 448 |
|
| 449 |
|
| 450 |
echo $ui->get_td_end() . $ui->get_tr_end(); |
| 451 |
?> |
| 452 |
</table> |
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
<table class="form-table taxopress-table autoterm_terms" |
| 458 |
style="<?php echo $active_tab === 'autoterm_terms' ? '' : 'display:none;'; ?>"> |
| 459 |
<?php |
| 460 |
|
| 461 |
$select = [ |
| 462 |
'options' => [ |
| 463 |
[ |
| 464 |
'attr' => '0', |
| 465 |
'text' => esc_attr__('False', 'simple-tags'), |
| 466 |
'default' => 'true', |
| 467 |
], |
| 468 |
[ |
| 469 |
'attr' => '1', |
| 470 |
'text' => esc_attr__('True', 'simple-tags'), |
| 471 |
], |
| 472 |
], |
| 473 |
]; |
| 474 |
$selected = (isset($current) && isset($current['autoterm_useall'])) ? taxopress_disp_boolean($current['autoterm_useall']) : ''; |
| 475 |
$select['selected'] = !empty($selected) ? $current['autoterm_useall'] : ''; |
| 476 |
echo $ui->get_select_checkbox_input([ |
| 477 |
'namearray' => 'taxopress_autoterm', |
| 478 |
'name' => 'autoterm_useall', |
| 479 |
'class' => 'autoterm_useall', |
| 480 |
'labeltext' => esc_html__('Which terms to use?', 'simple-tags'), |
| 481 |
'aftertext' => __('Use all the terms in the selected taxonomy. Please test this option carefully as it can use significant server resources if you have many terms.', 'simple-tags'), |
| 482 |
'selections' => $select, |
| 483 |
]); |
| 484 |
|
| 485 |
|
| 486 |
$select = [ |
| 487 |
'options' => [ |
| 488 |
[ |
| 489 |
'attr' => '0', |
| 490 |
'text' => esc_attr__('False', 'simple-tags'), |
| 491 |
'default' => 'true', |
| 492 |
], |
| 493 |
[ |
| 494 |
'attr' => '1', |
| 495 |
'text' => esc_attr__('True', 'simple-tags'), |
| 496 |
], |
| 497 |
], |
| 498 |
]; |
| 499 |
$selected = (isset($current) && isset($current['autoterm_useonly'])) ? taxopress_disp_boolean($current['autoterm_useonly']) : ''; |
| 500 |
$select['selected'] = !empty($selected) ? $current['autoterm_useonly'] : ''; |
| 501 |
echo $ui->get_select_checkbox_input([ |
| 502 |
'namearray' => 'taxopress_autoterm', |
| 503 |
'name' => 'autoterm_useonly', |
| 504 |
'class' => 'autoterm_useonly', |
| 505 |
'labeltext' => ' ', |
| 506 |
'aftertext' => __('Use only some terms in the selected taxonomy.', 'simple-tags'), |
| 507 |
'selections' => $select, |
| 508 |
]); |
| 509 |
|
| 510 |
$specific_terms = ( isset($current) && isset($current['specific_terms'])) ? taxopress_change_to_strings($current['specific_terms']) : ''; |
| 511 |
echo '<tr class="autoterm_useonly_options '. ($selected === 'false' ? 'st-hide-content' : '') .'" valign="top"><th scope="row"><label for=""></label></th><td>'; |
| 512 |
echo '<div class="auto-terms-to-use-error" style="display:none;"> '.__('Please choose an option for "Terms to use"', 'simple-tags').' </div>'; |
| 513 |
|
| 514 |
echo '<div class="st-autoterms-single-specific-term"> |
| 515 |
<input autocomplete="off" type="text" class="st-full-width specific_terms_input" name="specific_terms" maxlength="32" placeholder="'. esc_attr(__('Choose the terms to use.', 'simple-tags')) .'" value="'. esc_attr($specific_terms) .'"> |
| 516 |
</div>'; |
| 517 |
|
| 518 |
echo '</td></tr>'; |
| 519 |
|
| 520 |
echo $ui->get_tr_start(); |
| 521 |
|
| 522 |
|
| 523 |
echo $ui->get_th_start(); |
| 524 |
echo $ui->get_label('autoterm_exclude', esc_html__('Stop words', 'simple-tags')) . $ui->get_required_span(); |
| 525 |
echo $ui->get_th_end() . $ui->get_td_start(); |
| 526 |
|
| 527 |
echo $ui->get_text_input([ |
| 528 |
'labeltext' => esc_html__('Stop words', 'simple-tags'), |
| 529 |
'namearray' => 'taxopress_autoterm', |
| 530 |
'name' => 'autoterm_exclude', |
| 531 |
'textvalue' => isset($current['autoterm_exclude']) ? esc_attr($current['autoterm_exclude']) : '', |
| 532 |
'maxlength' => '', |
| 533 |
'helptext' => __('Choose terms to be excluded from auto terms', 'simple-tags'), |
| 534 |
'class' => 'st-full-width auto-terms-stopwords', |
| 535 |
'aftertext' => '', |
| 536 |
'required' => false, |
| 537 |
'placeholder' => false, |
| 538 |
'wrap' => false, |
| 539 |
]); |
| 540 |
|
| 541 |
|
| 542 |
?> |
| 543 |
</table> |
| 544 |
|
| 545 |
|
| 546 |
<table class="form-table taxopress-table autoterm_options" |
| 547 |
style="<?php echo $active_tab === 'autoterm_options' ? '' : 'display:none;'; ?>"> |
| 548 |
<?php |
| 549 |
|
| 550 |
echo $ui->get_number_input([ |
| 551 |
'namearray' => 'taxopress_autoterm', |
| 552 |
'name' => 'terms_limit', |
| 553 |
'textvalue' => isset($current['terms_limit']) ? esc_attr($current['terms_limit']) : '', |
| 554 |
'labeltext' => esc_html__('Auto Terms Limit', |
| 555 |
'simple-tags'), |
| 556 |
'helptext' => __('Limit the number of generated Auto Terms. \'0\' for unlimited terms', 'simple-tags'), |
| 557 |
'min' => '0', |
| 558 |
'required' => false, |
| 559 |
]); |
| 560 |
|
| 561 |
|
| 562 |
$select = [ |
| 563 |
'options' => [ |
| 564 |
[ |
| 565 |
'attr' => '0', |
| 566 |
'text' => esc_attr__('False', 'simple-tags'), |
| 567 |
'default' => 'true', |
| 568 |
], |
| 569 |
[ |
| 570 |
'attr' => '1', |
| 571 |
'text' => esc_attr__('True', 'simple-tags'), |
| 572 |
], |
| 573 |
], |
| 574 |
]; |
| 575 |
$selected = (isset($current) && isset($current['autoterm_target'])) ? taxopress_disp_boolean($current['autoterm_target']) : ''; |
| 576 |
$select['selected'] = !empty($selected) ? $current['autoterm_target'] : ''; |
| 577 |
echo $ui->get_select_checkbox_input([ |
| 578 |
'namearray' => 'taxopress_autoterm', |
| 579 |
'name' => 'autoterm_target', |
| 580 |
'class' => '', |
| 581 |
'labeltext' => esc_html__('Target content', 'simple-tags'), |
| 582 |
'aftertext' => __('Only use Auto Terms on posts with no added terms.', 'simple-tags'), |
| 583 |
'selections' => $select, |
| 584 |
]); |
| 585 |
|
| 586 |
$select = [ |
| 587 |
'options' => [ |
| 588 |
[ |
| 589 |
'attr' => '0', |
| 590 |
'text' => esc_attr__('False', 'simple-tags'), |
| 591 |
'default' => 'true', |
| 592 |
], |
| 593 |
[ |
| 594 |
'attr' => '1', |
| 595 |
'text' => esc_attr__('True', 'simple-tags'), |
| 596 |
], |
| 597 |
], |
| 598 |
]; |
| 599 |
$selected = (isset($current) && isset($current['autoterm_word'])) ? taxopress_disp_boolean($current['autoterm_word']) : ''; |
| 600 |
$select['selected'] = !empty($selected) ? $current['autoterm_word'] : ''; |
| 601 |
echo $ui->get_select_checkbox_input([ |
| 602 |
'namearray' => 'taxopress_autoterm', |
| 603 |
'name' => 'autoterm_word', |
| 604 |
'class' => '', |
| 605 |
'labeltext' => esc_html__('Whole words', 'simple-tags'), |
| 606 |
'aftertext' => __('Only add terms when the word is an exact match. Do not make matches for partial words.', 'simple-tags'), |
| 607 |
'selections' => $select, |
| 608 |
]); |
| 609 |
|
| 610 |
$select = [ |
| 611 |
'options' => [ |
| 612 |
[ |
| 613 |
'attr' => '0', |
| 614 |
'text' => esc_attr__('False', 'simple-tags'), |
| 615 |
'default' => 'true', |
| 616 |
], |
| 617 |
[ |
| 618 |
'attr' => '1', |
| 619 |
'text' => esc_attr__('True', 'simple-tags'), |
| 620 |
], |
| 621 |
], |
| 622 |
]; |
| 623 |
$selected = (isset($current) && isset($current['autoterm_hash'])) ? taxopress_disp_boolean($current['autoterm_hash']) : ''; |
| 624 |
$select['selected'] = !empty($selected) ? $current['autoterm_hash'] : ''; |
| 625 |
echo $ui->get_select_checkbox_input([ |
| 626 |
'namearray' => 'taxopress_autoterm', |
| 627 |
'name' => 'autoterm_hash', |
| 628 |
'class' => '', |
| 629 |
'labeltext' => esc_html__('Hashtags', 'simple-tags'), |
| 630 |
'aftertext' => __('Support hashtags symbols # in Auto Terms', 'simple-tags'), |
| 631 |
'selections' => $select, |
| 632 |
]); |
| 633 |
|
| 634 |
|
| 635 |
?> |
| 636 |
|
| 637 |
</table> |
| 638 |
|
| 639 |
|
| 640 |
<table class="form-table taxopress-table autoterm_oldcontent" |
| 641 |
style="<?php echo $active_tab === 'autoterm_oldcontent' ? '' : 'display:none;'; ?>"> |
| 642 |
|
| 643 |
<tr valign="top"><th scope="row"><label><?php echo __('Previous content', 'simple-tags'); ?></label></th> |
| 644 |
<td> |
| 645 |
<input type="submit" class="button taxopress-autoterm-all-content" value="<?php echo esc_attr(__('Add Auto Terms to all existing content', 'simple-tags')); ?>"> |
| 646 |
<span class="spinner taxopress-spinner"></span> |
| 647 |
|
| 648 |
<p class="taxopress-field-description description"> |
| 649 |
<?php echo __('TaxoPress can add Auto Terms to existing content.', 'simple-tags'); ?> |
| 650 |
|
| 651 |
<br /> <strong style="color:red;"><?php echo __('Please save all changes to your Auto Terms before using this feature.', 'simple-tags'); ?></strong> |
| 652 |
</p> |
| 653 |
|
| 654 |
<div class="auto-term-content-result-title"></div> |
| 655 |
|
| 656 |
</div> |
| 657 |
|
| 658 |
<ul class="auto-term-content-result"></ul> |
| 659 |
</td></tr> |
| 660 |
<?php |
| 661 |
|
| 662 |
?> |
| 663 |
|
| 664 |
</table> |
| 665 |
|
| 666 |
|
| 667 |
</div> |
| 668 |
|
| 669 |
|
| 670 |
<?php }//end new fields |
| 671 |
?> |
| 672 |
|
| 673 |
|
| 674 |
<div class="clear"></div> |
| 675 |
|
| 676 |
|
| 677 |
</div> |
| 678 |
</div> |
| 679 |
</div> |
| 680 |
|
| 681 |
|
| 682 |
<?php if ($autoterm_limit) { ?> |
| 683 |
|
| 684 |
<div class="pp-version-notice-bold-purple" style="margin-left:0px;"> |
| 685 |
<div class="pp-version-notice-bold-purple-message">You're using TaxoPress Free. |
| 686 |
The Pro version has more features and support. |
| 687 |
</div> |
| 688 |
<div class="pp-version-notice-bold-purple-button"><a |
| 689 |
href="https://taxopress.com/pro" target="_blank">Upgrade to Pro</a> |
| 690 |
</div> |
| 691 |
</div> |
| 692 |
|
| 693 |
<?php } ?> |
| 694 |
<?php |
| 695 |
/** |
| 696 |
* Fires after the default fieldsets on the taxonomy screen. |
| 697 |
* |
| 698 |
* @param taxopress_admin_ui $ui Admin UI instance. |
| 699 |
*/ |
| 700 |
do_action('taxopress_taxonomy_after_fieldsets', $ui); |
| 701 |
?> |
| 702 |
|
| 703 |
</div> |
| 704 |
</div> |
| 705 |
|
| 706 |
|
| 707 |
</div> |
| 708 |
|
| 709 |
<div class="taxopress-right-sidebar"> |
| 710 |
<div class="taxopress-right-sidebar-wrapper" style="min-height: 205px;"> |
| 711 |
|
| 712 |
|
| 713 |
<?php |
| 714 |
if (!$autoterm_limit) { ?> |
| 715 |
<p class="submit"> |
| 716 |
|
| 717 |
<?php |
| 718 |
wp_nonce_field('taxopress_addedit_autoterm_nonce_action', |
| 719 |
'taxopress_addedit_autoterm_nonce_field'); |
| 720 |
if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?> |
| 721 |
<input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-autoterm-submit" |
| 722 |
name="autoterm_submit" |
| 723 |
value="<?php echo esc_attr(esc_attr__('Save Auto Terms', |
| 724 |
'simple-tags')); ?>"/> |
| 725 |
<?php |
| 726 |
} else { ?> |
| 727 |
<input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-autoterm-submit" |
| 728 |
name="autoterm_submit" |
| 729 |
value="<?php echo esc_attr(esc_attr__('Add Auto Terms', |
| 730 |
'simple-tags')); ?>"/> |
| 731 |
<?php } ?> |
| 732 |
|
| 733 |
|
| 734 |
<input type="hidden" name="cpt_tax_status" id="cpt_tax_status" |
| 735 |
value="<?php echo esc_attr($tab); ?>"/> |
| 736 |
</p> |
| 737 |
|
| 738 |
<?php |
| 739 |
} |
| 740 |
?> |
| 741 |
|
| 742 |
</div> |
| 743 |
|
| 744 |
</div> |
| 745 |
|
| 746 |
<div class="clear"></div> |
| 747 |
|
| 748 |
|
| 749 |
</form> |
| 750 |
|
| 751 |
</div><!-- End .wrap --> |
| 752 |
|
| 753 |
<div class="clear"></div> |
| 754 |
|
| 755 |
<?php # Modal Windows; ?> |
| 756 |
<div class="remodal" data-remodal-id="taxopress-modal-alert" |
| 757 |
data-remodal-options="hashTracking: false, closeOnOutsideClick: false"> |
| 758 |
<div class="" style="color:red;"><?php echo __('Please complete the following required fields to save your changes:', 'simple-tags'); ?></div> |
| 759 |
<div id="taxopress-modal-alert-content"></div> |
| 760 |
<br> |
| 761 |
<button data-remodal-action="cancel" class="remodal-cancel"><?php echo __('Okay', 'simple-tags'); ?></button> |
| 762 |
</div> |
| 763 |
|
| 764 |
<div class="remodal" data-remodal-id="taxopress-modal-confirm" |
| 765 |
data-remodal-options="hashTracking: false, closeOnOutsideClick: false"> |
| 766 |
<div id="taxopress-modal-confirm-content"></div> |
| 767 |
<br> |
| 768 |
<button data-remodal-action="cancel" class="remodal-cancel"><?php echo __('No', 'simple-tags'); ?></button> |
| 769 |
<button data-remodal-action="confirm" |
| 770 |
class="remodal-confirm"><?php echo __('Yes', 'simple-tags'); ?></button> |
| 771 |
</div> |
| 772 |
|
| 773 |
<?php |
| 774 |
} |
| 775 |
|
| 776 |
} |
| 777 |
|