| 1 |
<?php |
| 2 |
|
| 3 |
class SimpleTags_Related_Post |
| 4 |
{ |
| 5 |
|
| 6 |
const MENU_SLUG = 'st_options'; |
| 7 |
|
| 8 |
// class instance |
| 9 |
static $instance; |
| 10 |
|
| 11 |
// WP_List_Table object |
| 12 |
public $terms_table; |
| 13 |
|
| 14 |
/** |
| 15 |
* Constructor |
| 16 |
* |
| 17 |
* @return void |
| 18 |
* @author Olatechpro |
| 19 |
*/ |
| 20 |
public function __construct() |
| 21 |
{ |
| 22 |
|
| 23 |
add_filter('set-screen-option', [__CLASS__, 'set_screen'], 10, 3); |
| 24 |
// Admin menu |
| 25 |
add_action('admin_menu', [$this, 'admin_menu']); |
| 26 |
|
| 27 |
// Javascript |
| 28 |
add_action('admin_enqueue_scripts', [__CLASS__, 'admin_enqueue_scripts'], 11); |
| 29 |
|
| 30 |
} |
| 31 |
|
| 32 |
/** |
| 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 |
if (isset($_GET['page']) && $_GET['page'] == 'st_related_posts') { |
| 43 |
wp_enqueue_style('st-taxonomies-css'); |
| 44 |
} |
| 45 |
} |
| 46 |
|
| 47 |
public static function set_screen($status, $option, $value) |
| 48 |
{ |
| 49 |
return $value; |
| 50 |
} |
| 51 |
|
| 52 |
/** Singleton instance */ |
| 53 |
public static function get_instance() |
| 54 |
{ |
| 55 |
if (!isset(self::$instance)) { |
| 56 |
self::$instance = new self(); |
| 57 |
} |
| 58 |
|
| 59 |
return self::$instance; |
| 60 |
} |
| 61 |
|
| 62 |
/** |
| 63 |
* Add WP admin menu for Tags |
| 64 |
* |
| 65 |
* @return void |
| 66 |
* @author Olatechpro |
| 67 |
*/ |
| 68 |
public function admin_menu() |
| 69 |
{ |
| 70 |
$hook = add_submenu_page( |
| 71 |
self::MENU_SLUG, |
| 72 |
__('Related Posts', 'simple-tags'), |
| 73 |
__('Related Posts', 'simple-tags'), |
| 74 |
'simple_tags', |
| 75 |
'st_related_posts', |
| 76 |
[ |
| 77 |
$this, |
| 78 |
'page_manage_relatedposts', |
| 79 |
] |
| 80 |
); |
| 81 |
|
| 82 |
if(taxopress_is_screen_main_page()){ |
| 83 |
add_action("load-$hook", [$this, 'screen_option']); |
| 84 |
} |
| 85 |
} |
| 86 |
|
| 87 |
/** |
| 88 |
* Screen options |
| 89 |
*/ |
| 90 |
public function screen_option() |
| 91 |
{ |
| 92 |
|
| 93 |
$option = 'per_page'; |
| 94 |
$args = [ |
| 95 |
'label' => __('Number of items per page', 'simple-tags'), |
| 96 |
'default' => 20, |
| 97 |
'option' => 'st_related_posts_per_page' |
| 98 |
]; |
| 99 |
|
| 100 |
add_screen_option($option, $args); |
| 101 |
|
| 102 |
$this->terms_table = new RelatedPosts_List(); |
| 103 |
} |
| 104 |
|
| 105 |
/** |
| 106 |
* Method for build the page HTML manage tags |
| 107 |
* |
| 108 |
* @return void |
| 109 |
* @author Olatechpro |
| 110 |
*/ |
| 111 |
public function page_manage_relatedposts() |
| 112 |
{ |
| 113 |
// Default order |
| 114 |
if (!isset($_GET['order'])) { |
| 115 |
$_GET['order'] = 'name-asc'; |
| 116 |
} |
| 117 |
|
| 118 |
settings_errors(__CLASS__); |
| 119 |
|
| 120 |
if (!isset($_GET['add'])) { |
| 121 |
//all tax |
| 122 |
?> |
| 123 |
<div class="wrap st_wrap st-manage-taxonomies-page"> |
| 124 |
|
| 125 |
<div id=""> |
| 126 |
<h1 class="wp-heading-inline"><?php _e('Related Posts', 'simple-tags'); ?></h1> |
| 127 |
<a href="<?php echo esc_url(admin_url('admin.php?page=st_related_posts&add=new_item')); ?>" |
| 128 |
class="page-title-action"><?php esc_html_e('Add New', 'simple-tags'); ?></a> |
| 129 |
|
| 130 |
<div class="taxopress-description">The Related Posts feature works by checking for shared taxonomy terms. If your post has the terms “WordPress” and “Website”, then Related Posts will display other posts that also have the terms “WordPress” and “Website”.</div> |
| 131 |
|
| 132 |
|
| 133 |
<?php |
| 134 |
if (isset($_REQUEST['s']) && $search = esc_attr(wp_unslash($_REQUEST['s']))) { |
| 135 |
/* translators: %s: search keywords */ |
| 136 |
printf(' <span class="subtitle">' . __('Search results for “%s”', |
| 137 |
'simple-tags') . '</span>', $search); |
| 138 |
} |
| 139 |
?> |
| 140 |
<?php |
| 141 |
|
| 142 |
//the terms table instance |
| 143 |
$this->terms_table->prepare_items(); |
| 144 |
?> |
| 145 |
|
| 146 |
|
| 147 |
<hr class="wp-header-end"> |
| 148 |
<div id="ajax-response"></div> |
| 149 |
<form class="search-form wp-clearfix st-taxonomies-search-form" method="get"> |
| 150 |
<?php $this->terms_table->search_box(__('Search Related Posts', 'simple-tags'), 'term'); ?> |
| 151 |
</form> |
| 152 |
<div class="clear"></div> |
| 153 |
|
| 154 |
<div id="col-container" class="wp-clearfix"> |
| 155 |
|
| 156 |
<div class="col-wrap"> |
| 157 |
<form action="<?php echo add_query_arg('', '') ?>" method="post"> |
| 158 |
<?php $this->terms_table->display(); //Display the table ?> |
| 159 |
</form> |
| 160 |
<div class="form-wrap edit-term-notes"> |
| 161 |
<p><?php __('Description here.', 'simple-tags') ?></p> |
| 162 |
</div> |
| 163 |
</div> |
| 164 |
|
| 165 |
|
| 166 |
</div> |
| 167 |
|
| 168 |
|
| 169 |
</div> |
| 170 |
<?php } else { |
| 171 |
if ($_GET['add'] == 'new_item') { |
| 172 |
//add/edit taxonomy |
| 173 |
$this->taxopress_manage_relatedposts(); |
| 174 |
echo '<div>'; |
| 175 |
} |
| 176 |
} ?> |
| 177 |
|
| 178 |
|
| 179 |
<?php SimpleTags_Admin::printAdminFooter(); ?> |
| 180 |
</div> |
| 181 |
<?php |
| 182 |
} |
| 183 |
|
| 184 |
|
| 185 |
/** |
| 186 |
* Create our settings page output. |
| 187 |
* |
| 188 |
* @internal |
| 189 |
*/ |
| 190 |
public function taxopress_manage_relatedposts() |
| 191 |
{ |
| 192 |
|
| 193 |
$tab = (!empty($_GET) && !empty($_GET['action']) && 'edit' == $_GET['action']) ? 'edit' : 'new'; |
| 194 |
$tab_class = 'taxopress-' . $tab; |
| 195 |
$current = null; |
| 196 |
|
| 197 |
?> |
| 198 |
|
| 199 |
<div class="wrap <?php echo esc_attr($tab_class); ?>"> |
| 200 |
|
| 201 |
<?php |
| 202 |
|
| 203 |
$relatedposts = taxopress_get_relatedpost_data(); |
| 204 |
$related_post_edit = false; |
| 205 |
$related_post_limit = false; |
| 206 |
|
| 207 |
if ('edit' === $tab) { |
| 208 |
|
| 209 |
|
| 210 |
$selected_relatedpost = taxopress_get_current_relatedpost(); |
| 211 |
|
| 212 |
if ($selected_relatedpost && array_key_exists($selected_relatedpost, $relatedposts)) { |
| 213 |
$current = $relatedposts[$selected_relatedpost]; |
| 214 |
$related_post_edit = true; |
| 215 |
} |
| 216 |
|
| 217 |
} |
| 218 |
|
| 219 |
|
| 220 |
if (!isset($current['title']) && count($relatedposts) > 0 && apply_filters('taxopress_related_posts_create_limit', true)) { |
| 221 |
$related_post_limit = true; |
| 222 |
} |
| 223 |
|
| 224 |
|
| 225 |
$ui = new taxopress_admin_ui(); |
| 226 |
?> |
| 227 |
|
| 228 |
|
| 229 |
<div class="wrap <?php echo esc_attr($tab_class); ?>"> |
| 230 |
<h1><?php echo __('Manage Related Posts', 'simple-tags'); ?></h1> |
| 231 |
<div class="wp-clearfix"></div> |
| 232 |
|
| 233 |
<form method="post" action=""> |
| 234 |
|
| 235 |
|
| 236 |
<div class="tagcloudui"> |
| 237 |
|
| 238 |
|
| 239 |
<div class="relatedposts-postbox-container"> |
| 240 |
<div id="poststuff"> |
| 241 |
<div class="taxopress-section postbox"> |
| 242 |
<div class="postbox-header"> |
| 243 |
<h2 class="hndle ui-sortable-handle"> |
| 244 |
<?php |
| 245 |
if ($related_post_edit) { |
| 246 |
echo esc_html__('Edit Related Posts', 'simple-tags'); |
| 247 |
echo '<input type="hidden" name="edited_relatedpost" value="' . $current['ID'] . '" />'; |
| 248 |
echo '<input type="hidden" name="taxopress_related_post[ID]" value="' . $current['ID'] . '" />'; |
| 249 |
} else { |
| 250 |
echo esc_html__('Add new Related Posts', 'simple-tags'); |
| 251 |
} |
| 252 |
?> |
| 253 |
</h2> |
| 254 |
</div> |
| 255 |
<div class="inside"> |
| 256 |
<div class="main"> |
| 257 |
|
| 258 |
|
| 259 |
<div class="st-taxonomy-content"> |
| 260 |
|
| 261 |
<?php if ($related_post_limit) { |
| 262 |
echo '<div class="taxopress-warning upgrade-pro"> |
| 263 |
<p> |
| 264 |
|
| 265 |
<h2 style="margin-bottom: 5px;">' . __('To create more Related Posts, please upgrade to TaxoPress Pro.', |
| 266 |
'simple-tags') . '</h2> |
| 267 |
' . __('With TaxoPress Pro, you can create unlimited Related Posts. You can create Related Posts for any taxonomy and then display those Related Posts anywhere on your site.', |
| 268 |
'simple-tags') . ' |
| 269 |
|
| 270 |
</p> |
| 271 |
</div>'; |
| 272 |
|
| 273 |
} else { |
| 274 |
?> |
| 275 |
<table class="form-table taxopress-table"> |
| 276 |
<?php |
| 277 |
echo $ui->get_tr_start(); |
| 278 |
|
| 279 |
echo $ui->get_th_start(); |
| 280 |
echo $ui->get_label('name', esc_html__('Title', |
| 281 |
'simple-tags')) . $ui->get_required_span(); |
| 282 |
echo $ui->get_th_end() . $ui->get_td_start(); |
| 283 |
|
| 284 |
echo $ui->get_text_input([ |
| 285 |
'namearray' => 'taxopress_related_post', |
| 286 |
'name' => 'title', |
| 287 |
'textvalue' => isset($current['title']) ? esc_attr($current['title']) : '', |
| 288 |
'maxlength' => '32', |
| 289 |
'helptext' => '', |
| 290 |
'required' => true, |
| 291 |
'placeholder' => false, |
| 292 |
'wrap' => false, |
| 293 |
]); |
| 294 |
|
| 295 |
|
| 296 |
$select = [ |
| 297 |
'options' => [ |
| 298 |
[ |
| 299 |
'attr' => '', |
| 300 |
'text' => esc_attr__('None', 'simple-tags') |
| 301 |
], |
| 302 |
[ |
| 303 |
'attr' => 'h1', |
| 304 |
'text' => esc_attr__('H1', 'simple-tags') |
| 305 |
], |
| 306 |
[ |
| 307 |
'attr' => 'h2', |
| 308 |
'text' => esc_attr__('H2', 'simple-tags') |
| 309 |
], |
| 310 |
[ |
| 311 |
'attr' => 'h3', |
| 312 |
'text' => esc_attr__('H3', 'simple-tags') |
| 313 |
], |
| 314 |
[ |
| 315 |
'attr' => 'h4', |
| 316 |
'text' => esc_attr__('H4', 'simple-tags'), |
| 317 |
'default' => 'true' |
| 318 |
], |
| 319 |
[ |
| 320 |
'attr' => 'h5', |
| 321 |
'text' => esc_attr__('H5', 'simple-tags') |
| 322 |
], |
| 323 |
[ |
| 324 |
'attr' => 'h6', |
| 325 |
'text' => esc_attr__('H6', 'simple-tags') |
| 326 |
], |
| 327 |
], |
| 328 |
]; |
| 329 |
$selected = isset($current) ? taxopress_disp_boolean($current['title_header']) : ''; |
| 330 |
|
| 331 |
$select['selected'] = !empty($selected) ? $current['title_header'] : ''; |
| 332 |
if(isset($current['title_header']) && empty($current['title_header'])){ |
| 333 |
$select['selected'] = 'none'; |
| 334 |
} |
| 335 |
echo $ui->get_select_checkbox_input_main([ |
| 336 |
'namearray' => 'taxopress_related_post', |
| 337 |
'name' => 'title_header', |
| 338 |
'labeltext' => esc_html__('Title header', 'simple-tags'), |
| 339 |
'selections' => $select, |
| 340 |
]); |
| 341 |
|
| 342 |
|
| 343 |
$select = [ |
| 344 |
'options' => [ |
| 345 |
[ |
| 346 |
'attr' => '0', |
| 347 |
'text' => esc_attr__('False', 'simple-tags'), |
| 348 |
'default' => 'true', |
| 349 |
], |
| 350 |
[ |
| 351 |
'attr' => '1', |
| 352 |
'text' => esc_attr__('True', 'simple-tags'), |
| 353 |
], |
| 354 |
], |
| 355 |
]; |
| 356 |
$selected = (isset($current) && isset($current['hide_title'])) ? taxopress_disp_boolean($current['hide_title']) : ''; |
| 357 |
$select['selected'] = !empty($selected) ? $current['hide_title'] : ''; |
| 358 |
echo $ui->get_select_checkbox_input([ |
| 359 |
'namearray' => 'taxopress_related_post', |
| 360 |
'name' => 'hide_title', |
| 361 |
'labeltext' => esc_html__('Hide title in output ?', |
| 362 |
'simple-tags'), |
| 363 |
'selections' => $select, |
| 364 |
]); |
| 365 |
|
| 366 |
$options[] = [ |
| 367 |
'attr' => 'st_all_posttype', |
| 368 |
'text' => __('All post types', 'simple-tags') |
| 369 |
]; |
| 370 |
$options[] = [ |
| 371 |
'attr' => 'st_current_posttype', |
| 372 |
'text' => __('Current post type', 'simple-tags'), |
| 373 |
'default' => 'true' |
| 374 |
]; |
| 375 |
foreach (get_post_types(['public' => true], |
| 376 |
'objects') as $post_type) { |
| 377 |
$options[] = [ |
| 378 |
'attr' => $post_type->name, |
| 379 |
'text' => $post_type->label |
| 380 |
]; |
| 381 |
} |
| 382 |
|
| 383 |
$select = [ |
| 384 |
'options' => $options, |
| 385 |
]; |
| 386 |
$selected = (isset($current) && isset($current['post_type'])) ? taxopress_disp_boolean($current['post_type']) : ''; |
| 387 |
$select['selected'] = !empty($selected) ? $current['post_type'] : ''; |
| 388 |
echo $ui->get_select_checkbox_input_main([ |
| 389 |
'namearray' => 'taxopress_related_post', |
| 390 |
'name' => 'post_type', |
| 391 |
'class' => 'st-post-type-select', |
| 392 |
'labeltext' => esc_html__('Post Type', 'simple-tags'), |
| 393 |
'selections' => $select, |
| 394 |
]); |
| 395 |
|
| 396 |
$options = []; |
| 397 |
foreach (get_all_taxopress_taxonomies() as $_taxonomy) { |
| 398 |
$_taxonomy = $_taxonomy->name; |
| 399 |
$tax = get_taxonomy($_taxonomy); |
| 400 |
if (empty($tax->labels->name)) { |
| 401 |
continue; |
| 402 |
} |
| 403 |
if ($tax->name === 'post_tag') { |
| 404 |
$options[] = [ |
| 405 |
'attr' => $tax->name, |
| 406 |
'text' => $tax->labels->name. ' ('.$tax->name.')', |
| 407 |
'default' => 'true', |
| 408 |
'post_type' => join(',', $tax->object_type), |
| 409 |
]; |
| 410 |
} else { |
| 411 |
$options[] = [ |
| 412 |
'attr' => $tax->name, |
| 413 |
'text' => $tax->labels->name. ' ('.$tax->name.')', |
| 414 |
'post_type' => join(',', $tax->object_type), |
| 415 |
]; |
| 416 |
} |
| 417 |
} |
| 418 |
|
| 419 |
$select = [ |
| 420 |
'options' => $options, |
| 421 |
]; |
| 422 |
$selected = isset($current) ? taxopress_disp_boolean($current['taxonomy']) : ''; |
| 423 |
$select['selected'] = !empty($selected) ? $current['taxonomy'] : ''; |
| 424 |
echo $ui->get_select_checkbox_input_main([ |
| 425 |
'namearray' => 'taxopress_related_post', |
| 426 |
'name' => 'taxonomy', |
| 427 |
'class' => 'st-post-taxonomy-select', |
| 428 |
'labeltext' => esc_html__('Taxonomy', 'simple-tags'), |
| 429 |
'required' => true, |
| 430 |
'selections' => $select, |
| 431 |
]); |
| 432 |
|
| 433 |
|
| 434 |
/** |
| 435 |
* Filters the arguments for post types to list for taxonomy association. |
| 436 |
* |
| 437 |
* |
| 438 |
* @param array $value Array of default arguments. |
| 439 |
*/ |
| 440 |
$args = apply_filters('taxopress_attach_post_types_to_taxonomy', |
| 441 |
['public' => true]); |
| 442 |
|
| 443 |
// 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. |
| 444 |
if (!is_array($args)) { |
| 445 |
$args = ['public' => true]; |
| 446 |
} |
| 447 |
$output = 'objects'; // Or objects. |
| 448 |
|
| 449 |
/** |
| 450 |
* Filters the results returned to display for available post types for taxonomy. |
| 451 |
* |
| 452 |
* @param array $value Array of post type objects. |
| 453 |
* @param array $args Array of arguments for the post type query. |
| 454 |
* @param string $output The output type we want for the results. |
| 455 |
*/ |
| 456 |
$post_types = apply_filters('taxopress_get_post_types_for_taxonomies', |
| 457 |
get_post_types($args, $output), $args, $output); |
| 458 |
|
| 459 |
$term_auto_locations = [ |
| 460 |
'homeonly' => esc_attr__('Homepage', 'simple-tags'), |
| 461 |
'blogonly' => esc_attr__('Blog display', 'simple-tags'), |
| 462 |
]; |
| 463 |
foreach ($post_types as $post_type) { |
| 464 |
$term_auto_locations[$post_type->name] = $post_type->label; |
| 465 |
} |
| 466 |
|
| 467 |
echo '<tr valign="top"><th scope="row"><label>' . esc_html__('Attempt to automatically display related posts', |
| 468 |
'simple-tags') . '</label><br /><small style=" color: #646970;">' . esc_html__('TaxoPress will attempt to automatically display related posts in this content. It may not be successful for all post types and layouts.', |
| 469 |
'simple-tags') . '</small></th><td> |
| 470 |
<table>'; |
| 471 |
foreach ($term_auto_locations as $key => $value) { |
| 472 |
|
| 473 |
|
| 474 |
echo '<tr valign="top"><th scope="row"><label for="' . $key . '">' . $value . '</label></th><td>'; |
| 475 |
|
| 476 |
echo $ui->get_check_input([ |
| 477 |
'checkvalue' => $key, |
| 478 |
'checked' => (!empty($current['embedded']) && is_array($current['embedded']) && in_array($key, |
| 479 |
$current['embedded'], true)) ? 'true' : 'false', |
| 480 |
'name' => $key, |
| 481 |
'namearray' => 'embedded', |
| 482 |
'textvalue' => $key, |
| 483 |
'labeltext' => "", |
| 484 |
'wrap' => false, |
| 485 |
]); |
| 486 |
|
| 487 |
echo '</td></tr>'; |
| 488 |
|
| 489 |
if ($key === 'blogonly') { |
| 490 |
echo '<tr valign="top"><th style="padding: 0;" scope="row"><hr /></th><td style="padding: 0;"><hr /></td></tr>'; |
| 491 |
} |
| 492 |
|
| 493 |
|
| 494 |
} |
| 495 |
echo '</table></td></tr>'; |
| 496 |
|
| 497 |
|
| 498 |
echo $ui->get_number_input([ |
| 499 |
'namearray' => 'taxopress_related_post', |
| 500 |
'name' => 'number', |
| 501 |
'textvalue' => isset($current['number']) ? esc_attr($current['number']) : '5', |
| 502 |
'labeltext' => esc_html__('Maximum related posts to display', |
| 503 |
'simple-tags'), |
| 504 |
'helptext' => '', |
| 505 |
'required' => true, |
| 506 |
]); |
| 507 |
|
| 508 |
$select = [ |
| 509 |
'options' => [ |
| 510 |
[ |
| 511 |
'attr' => '1', |
| 512 |
'text' => esc_attr__('24 hours', 'simple-tags') |
| 513 |
], |
| 514 |
[ |
| 515 |
'attr' => '7', |
| 516 |
'text' => esc_attr__('7 days', 'simple-tags') |
| 517 |
], |
| 518 |
[ |
| 519 |
'attr' => '14', |
| 520 |
'text' => esc_attr__('2 weeks', 'simple-tags') |
| 521 |
], |
| 522 |
[ |
| 523 |
'attr' => '30', |
| 524 |
'text' => esc_attr__('1 month', 'simple-tags') |
| 525 |
], |
| 526 |
[ |
| 527 |
'attr' => '180', |
| 528 |
'text' => esc_attr__('6 months', 'simple-tags') |
| 529 |
], |
| 530 |
[ |
| 531 |
'attr' => '365', |
| 532 |
'text' => esc_attr__('1 year', 'simple-tags') |
| 533 |
], |
| 534 |
[ |
| 535 |
'attr' => '0', |
| 536 |
'text' => esc_attr__('No limit', 'simple-tags'), |
| 537 |
'default' => 'true' |
| 538 |
], |
| 539 |
], |
| 540 |
]; |
| 541 |
$selected = isset($current) ? taxopress_disp_boolean($current['limit_days']) : ''; |
| 542 |
$select['selected'] = !empty($selected) ? $current['limit_days'] : ''; |
| 543 |
echo $ui->get_select_number_select([ |
| 544 |
'namearray' => 'taxopress_related_post', |
| 545 |
'name' => 'limit_days', |
| 546 |
'labeltext' => esc_html__('Limit related posts based on timeframe', |
| 547 |
'simple-tags'), |
| 548 |
'selections' => $select, |
| 549 |
]); |
| 550 |
|
| 551 |
|
| 552 |
$select = [ |
| 553 |
'options' => [ |
| 554 |
[ |
| 555 |
'attr' => 'count-asc', |
| 556 |
'text' => esc_attr__('Least common tags between posts', |
| 557 |
'simple-tags') |
| 558 |
], |
| 559 |
[ |
| 560 |
'attr' => 'count-desc', |
| 561 |
'text' => esc_attr__('Most common tags between posts', |
| 562 |
'simple-tags'), |
| 563 |
'default' => 'true' |
| 564 |
], |
| 565 |
[ |
| 566 |
'attr' => 'date-asc', |
| 567 |
'text' => esc_attr__('Older Entries', 'simple-tags') |
| 568 |
], |
| 569 |
[ |
| 570 |
'attr' => 'date-desc', |
| 571 |
'text' => esc_attr__('Newer Entries', 'simple-tags') |
| 572 |
], |
| 573 |
[ |
| 574 |
'attr' => 'name-asc', |
| 575 |
'text' => esc_attr__('Alphabetical', 'simple-tags') |
| 576 |
], |
| 577 |
[ |
| 578 |
'attr' => 'name-desc', |
| 579 |
'text' => esc_attr__('Inverse Alphabetical', |
| 580 |
'simple-tags') |
| 581 |
], |
| 582 |
[ |
| 583 |
'attr' => 'random', |
| 584 |
'text' => esc_attr__('Random', 'simple-tags') |
| 585 |
], |
| 586 |
], |
| 587 |
]; |
| 588 |
$selected = isset($current) ? taxopress_disp_boolean($current['order']) : ''; |
| 589 |
$select['selected'] = !empty($selected) ? $current['order'] : ''; |
| 590 |
echo $ui->get_select_checkbox_input_main([ |
| 591 |
'namearray' => 'taxopress_related_post', |
| 592 |
'name' => 'order', |
| 593 |
'labeltext' => esc_html__('Related Posts Order', |
| 594 |
'simple-tags'), |
| 595 |
'selections' => $select, |
| 596 |
]); |
| 597 |
|
| 598 |
|
| 599 |
echo $ui->get_text_input([ |
| 600 |
'namearray' => 'taxopress_related_post', |
| 601 |
'name' => 'nopoststext', |
| 602 |
'textvalue' => isset($current['nopoststext']) ? esc_attr($current['nopoststext']) : 'No related posts.', |
| 603 |
'labeltext' => esc_html__('Text to show when there is no related post', |
| 604 |
'simple-tags'), |
| 605 |
'helptext' => '', |
| 606 |
'required' => false, |
| 607 |
]); |
| 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['hide_output'])) ? taxopress_disp_boolean($current['hide_output']) : ''; |
| 624 |
$select['selected'] = !empty($selected) ? $current['hide_output'] : ''; |
| 625 |
echo $ui->get_select_checkbox_input([ |
| 626 |
'namearray' => 'taxopress_related_post', |
| 627 |
'name' => 'hide_output', |
| 628 |
'labeltext' => esc_html__('Hide output if no related post is found ?', |
| 629 |
'simple-tags'), |
| 630 |
'selections' => $select, |
| 631 |
]); |
| 632 |
|
| 633 |
echo $ui->get_text_input([ |
| 634 |
'namearray' => 'taxopress_related_post', |
| 635 |
'name' => 'wrap_class', |
| 636 |
'class' => '', |
| 637 |
'textvalue' => isset($current['wrap_class']) ? esc_attr($current['wrap_class']) : '', |
| 638 |
'labeltext' => esc_html__('Related Posts div class', 'simple-tags'), |
| 639 |
'helptext' => '', |
| 640 |
'required' => false, |
| 641 |
]); |
| 642 |
|
| 643 |
echo $ui->get_text_input([ |
| 644 |
'namearray' => 'taxopress_related_post', |
| 645 |
'name' => 'link_class', |
| 646 |
'class' => '', |
| 647 |
'textvalue' => isset($current['link_class']) ? esc_attr($current['link_class']) : '', |
| 648 |
'labeltext' => esc_html__('Term link class', 'simple-tags'), |
| 649 |
'helptext' => '', |
| 650 |
'required' => false, |
| 651 |
]); |
| 652 |
|
| 653 |
|
| 654 |
echo $ui->get_text_input([ |
| 655 |
'namearray' => 'taxopress_related_post', |
| 656 |
'name' => 'xformat', |
| 657 |
'class' => 'st-full-width', |
| 658 |
'textvalue' => isset($current['xformat']) ? esc_attr($current['xformat']) : esc_attr('<a href="%post_permalink%" title="%post_title% (%post_date%)">%post_title%</a>'), |
| 659 |
'labeltext' => esc_html__('Term link format', 'simple-tags'), |
| 660 |
'helptext' => __('You can find markers and explanations <a target="blank" href="https://taxopress.com/docs/format-related-posts/">in the online documentation.</a>', |
| 661 |
'simple-tags'), |
| 662 |
'required' => false, |
| 663 |
]); |
| 664 |
|
| 665 |
echo $ui->get_td_end() . $ui->get_tr_end(); |
| 666 |
?> |
| 667 |
</table> |
| 668 |
|
| 669 |
<?php }//end new fields |
| 670 |
?> |
| 671 |
|
| 672 |
|
| 673 |
</div> |
| 674 |
<div class="clear"></div> |
| 675 |
|
| 676 |
|
| 677 |
</div> |
| 678 |
</div> |
| 679 |
</div> |
| 680 |
|
| 681 |
|
| 682 |
<?php if ($related_post_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 (!$related_post_limit){ ?> |
| 715 |
<p class="submit"> |
| 716 |
|
| 717 |
<?php |
| 718 |
wp_nonce_field('taxopress_addedit_relatedpost_nonce_action', |
| 719 |
'taxopress_addedit_relatedpost_nonce_field'); |
| 720 |
if (!empty($_GET) && !empty($_GET['action']) && 'edit' === $_GET['action']) { ?> |
| 721 |
<input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-relatedposts-submit" |
| 722 |
name="relatedpost_submit" |
| 723 |
value="<?php echo esc_attr(esc_attr__('Save Related Posts', |
| 724 |
'simple-tags')); ?>"/> |
| 725 |
<?php |
| 726 |
} else { ?> |
| 727 |
<input type="submit" class="button-primary taxopress-taxonomy-submit taxopress-relatedposts-submit" |
| 728 |
name="relatedpost_submit" |
| 729 |
value="<?php echo esc_attr(esc_attr__('Add Related Posts', |
| 730 |
'simple-tags')); ?>"/> |
| 731 |
<?php } ?> |
| 732 |
|
| 733 |
<input type="hidden" name="cpt_tax_status" id="cpt_tax_status" |
| 734 |
value="<?php echo esc_attr($tab); ?>"/> |
| 735 |
</p> |
| 736 |
|
| 737 |
<?php if (!empty($current)) { |
| 738 |
?> |
| 739 |
<p> |
| 740 |
<?php echo '<div class="taxopress-warning" style="">' . __('Shortcode: ', |
| 741 |
'simple-tags'); ?> |
| 742 |
<textarea |
| 743 |
style="resize: none;padding: 5px;">[taxopress_relatedposts id="<?php echo $current['ID']; ?>"]</textarea> |
| 744 |
</div> |
| 745 |
</p> |
| 746 |
<?php } ?> |
| 747 |
|
| 748 |
<?php |
| 749 |
} |
| 750 |
?> |
| 751 |
|
| 752 |
</div> |
| 753 |
|
| 754 |
<?php do_action('taxopress_admin_after_sidebar'); ?> |
| 755 |
</div> |
| 756 |
|
| 757 |
<div class="clear"></div> |
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
</form> |
| 762 |
|
| 763 |
</div><!-- End .wrap --> |
| 764 |
|
| 765 |
<div class="clear"></div> |
| 766 |
|
| 767 |
<?php # Modal Windows; ?> |
| 768 |
<div class="remodal" data-remodal-id="taxopress-modal-alert" |
| 769 |
data-remodal-options="hashTracking: false, closeOnOutsideClick: false"> |
| 770 |
<div class="" style="color:red;"><?php echo __('Please complete the following required fields to save your changes:', 'simple-tags'); ?></div> |
| 771 |
<div id="taxopress-modal-alert-content"></div> |
| 772 |
<br> |
| 773 |
<button data-remodal-action="cancel" class="remodal-cancel"><?php echo __('Okay', 'simple-tags'); ?></button> |
| 774 |
</div> |
| 775 |
|
| 776 |
<div class="remodal" data-remodal-id="taxopress-modal-confirm" |
| 777 |
data-remodal-options="hashTracking: false, closeOnOutsideClick: false"> |
| 778 |
<div id="taxopress-modal-confirm-content"></div> |
| 779 |
<br> |
| 780 |
<button data-remodal-action="cancel" class="remodal-cancel"><?php echo __('No', 'simple-tags'); ?></button> |
| 781 |
<button data-remodal-action="confirm" |
| 782 |
class="remodal-confirm"><?php echo __('Yes', 'simple-tags'); ?></button> |
| 783 |
</div> |
| 784 |
<?php |
| 785 |
} |
| 786 |
|
| 787 |
} |
| 788 |
|