/class.bcn_admin.php

  1. <?php 
  2. /** Copyright 2007-2017 John Havlik (email : john.havlik@mtekk.us) 
  3.   
  4. This program is free software; you can redistribute it and/or modify 
  5. it under the terms of the GNU General Public License as published by 
  6. the Free Software Foundation; either version 2 of the License, or 
  7. (at your option) any later version. 
  8.   
  9. This program is distributed in the hope that it will be useful,  
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of 
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 
  12. GNU General Public License for more details. 
  13.   
  14. You should have received a copy of the GNU General Public License 
  15. along with this program; if not, write to the Free Software 
  16. Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 
  17. */ 
  18. require_once(dirname(__FILE__) . '/includes/block_direct_access.php'); 
  19. //Do a PHP version check, require 5.3 or newer 
  20. if(version_compare(phpversion(), '5.3.0', '<')) 
  21. //Only purpose of this function is to echo out the PHP version error 
  22. function bcn_phpold() 
  23. printf('<div class="error"><p>' . __('Your PHP version is too old, please upgrade to a newer version. Your version is %1$s, Breadcrumb NavXT requires %2$s', 'breadcrumb-navxt') . '</p></div>', phpversion(), '5.3.0'); 
  24. //If we are in the admin, let's print a warning then return 
  25. if(is_admin()) 
  26. add_action('admin_notices', 'bcn_phpold'); 
  27. return; 
  28. //Include admin base class 
  29. if(!class_exists('mtekk_adminKit')) 
  30. require_once(dirname(__FILE__) . '/includes/class.mtekk_adminkit.php'); 
  31. /** 
  32. * The administrative interface class  
  33. *  
  34. */ 
  35. class bcn_admin extends mtekk_adminKit 
  36. const version = '5.7.0'; 
  37. protected $full_name = 'Breadcrumb NavXT Settings'; 
  38. protected $short_name = 'Breadcrumb NavXT'; 
  39. protected $access_level = 'manage_options'; 
  40. protected $identifier = 'breadcrumb-navxt'; 
  41. protected $unique_prefix = 'bcn'; 
  42. protected $plugin_basename = null; 
  43. protected $support_url = 'http://mtekk.us/archives/wordpress/plugins-wordpress/breadcrumb-navxt-'; 
  44. protected $breadcrumb_trail = null; 
  45. /** 
  46. * Administrative interface class default constructor 
  47. *  
  48. * @param bcn_breadcrumb_trail $breadcrumb_trail a breadcrumb trail object 
  49. * @param string $basename The basename of the plugin 
  50. */ 
  51. function __construct(bcn_breadcrumb_trail &$breadcrumb_trail, $basename) 
  52. $this->breadcrumb_trail =& $breadcrumb_trail; 
  53. $this->plugin_basename = $basename; 
  54. $this->full_name = __('Breadcrumb NavXT Settings', 'breadcrumb-navxt'); 
  55. //Grab defaults from the breadcrumb_trail object 
  56. $this->opt =& $this->breadcrumb_trail->opt; 
  57. //We're going to make sure we load the parent's constructor 
  58. parent::__construct(); 
  59. /** 
  60. * admin initialization callback function 
  61. *  
  62. * is bound to wordpress action 'admin_init' on instantiation 
  63. *  
  64. * @since 3.2.0 
  65. * @return void 
  66. */ 
  67. function init() 
  68. //We're going to make sure we run the parent's version of this function as well 
  69. parent::init(); 
  70. function wp_loaded() 
  71. parent::wp_loaded(); 
  72. breadcrumb_navxt::setup_options($this->opt); 
  73. /** 
  74. * Upgrades input options array, sets to $this->opt 
  75. *  
  76. * @param array $opts 
  77. * @param string $version the version of the passed in options 
  78. */ 
  79. function opts_upgrade($opts, $version) 
  80. global $wp_post_types, $wp_taxonomies; 
  81. //If our version is not the same as in the db, time to update 
  82. if(version_compare($version, $this::version, '<')) 
  83. //Upgrading to 3.8.1 
  84. if(version_compare($version, '3.8.1', '<')) 
  85. $opts['post_page_root'] = get_option('page_on_front'); 
  86. $opts['post_post_root'] = get_option('page_for_posts'); 
  87. //Upgrading to 4.0 
  88. if(version_compare($version, '4.0.0', '<')) 
  89. //Only migrate if we haven't migrated yet 
  90. if(isset($opts['current_item_linked'])) 
  91. //Loop through the old options, migrate some of them 
  92. foreach($opts as $option => $value) 
  93. //Handle all of our boolean options first, they're real easy, just add a 'b' 
  94. if(strpos($option, 'display') > 0 || $option == 'current_item_linked') 
  95. $this->breadcrumb_trail->opt['b' . $option] = $value; 
  96. //Handle migration of anchor templates to the templates 
  97. else if(strpos($option, 'anchor') > 0) 
  98. $parts = explode('_', $option); 
  99. //Do excess slash removal sanitation 
  100. $this->breadcrumb_trail->opt['H' . $parts[0] . '_template'] = $value . '%htitle%</a>'; 
  101. //Handle our abs integers 
  102. else if($option == 'max_title_length' || $option == 'post_post_root' || $option == 'post_page_root') 
  103. $this->breadcrumb_trail->opt['a' . $option] = $value; 
  104. //Now everything else, minus prefix and suffix 
  105. else if(strpos($option, 'prefix') === false && strpos($option, 'suffix') === false) 
  106. $this->breadcrumb_trail->opt['S' . $option] = $value; 
  107. //Add in the new settings for CPTs introduced in 4.0 
  108. foreach($wp_post_types as $post_type) 
  109. //We only want custom post types 
  110. if(!$post_type->_builtin) 
  111. //Add in the archive_display option 
  112. $this->breadcrumb_trail->opt['bpost_' . $post_type->name . '_archive_display'] = $post_type->has_archive; 
  113. $opts = $this->breadcrumb_trail->opt; 
  114. if(version_compare($version, '4.0.1', '<')) 
  115. if(isset($opts['Hcurrent_item_template_no_anchor'])) 
  116. unset($opts['Hcurrent_item_template_no_anchor']); 
  117. if(isset($opts['Hcurrent_item_template'])) 
  118. unset($opts['Hcurrent_item_template']); 
  119. //Upgrading to 4.3.0 
  120. if(version_compare($version, '4.3.0', '<')) 
  121. //Removed home_title 
  122. if(isset($opts['Shome_title'])) 
  123. unset($opts['Shome_title']); 
  124. //Removed mainsite_title 
  125. if(isset($opts['Smainsite_title'])) 
  126. unset($opts['Smainsite_title']); 
  127. //Upgrading to 5.1.0 
  128. if(version_compare($version, '5.1.0', '<')) 
  129. foreach($wp_taxonomies as $taxonomy) 
  130. //If we have the old options style for it, update 
  131. if($taxonomy->name !== 'post_format' && isset($opts['H' . $taxonomy->name . '_template'])) 
  132. //Migrate to the new setting name 
  133. $opts['Htax_' . $taxonomy->name . '_template'] = $opts['H' . $taxonomy->name . '_template']; 
  134. $opts['Htax_' . $taxonomy->name . '_template_no_anchor'] = $opts['H' . $taxonomy->name . '_template_no_anchor']; 
  135. //Clean up old settings 
  136. unset($opts['H' . $taxonomy->name . '_template']); 
  137. unset($opts['H' . $taxonomy->name . '_template_no_anchor']); 
  138. //Upgrading to 5.4.0 
  139. if(version_compare($version, '5.4.0', '<')) 
  140. //Migrate users to schema.org breadcrumbs for author and search if still on the defaults for posts 
  141. if($opts['Hpost_post_template'] === bcn_breadcrumb::get_default_template() && $opts['Hpost_post_template_no_anchor'] === bcn_breadcrumb::default_template_no_anchor) 
  142. if($opts['Hpaged_template'] === 'Page %htitle%') 
  143. $opts['Hpaged_template'] = $this->opt['Hpaged_template']; 
  144. 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>'') 
  145. $opts['Hsearch_template'] = $this->opt['Hsearch_template']; 
  146. if($opts['Hsearch_template_no_anchor'] === 'Search results for '%htitle%'' || $opts['Hsearch_template_no_anchor'] === 'Search results for '%htitle%'') 
  147. $opts['Hsearch_template_no_anchor'] = $this->opt['Hsearch_template_no_anchor']; 
  148. if($opts['Hauthor_template'] === 'Articles by: <a title="Go to the first page of posts by %title%." href="%link%" class="%type%">%htitle%</a>') 
  149. $opts['Hauthor_template'] = $this->opt['Hauthor_template']; 
  150. if($opts['Hauthor_template_no_anchor'] === 'Articles by: %htitle%') 
  151. $opts['Hauthor_template_no_anchor'] = $this->opt['Hauthor_template_no_anchor']; 
  152. //Upgrading to 5.5.0 
  153. if(version_compare($version, '5.5.0', '<')) 
  154. //Translate the old 'page' taxonomy type to BCN_POST_PARENT 
  155. if($this->opt['Spost_post_taxonomy_type'] === 'page') 
  156. $this->opt['Spost_post_taxonomy_type'] = 'BCN_POST_PARENT'; 
  157. if(!isset($this->opt['Spost_post_taxonomy_referer'])) 
  158. $this->opt['bpost_post_taxonomy_referer'] = false; 
  159. //Loop through all of the post types in the array 
  160. foreach($wp_post_types as $post_type) 
  161. //Check for non-public CPTs 
  162. if(!apply_filters('bcn_show_cpt_private', $post_type->public, $post_type->name)) 
  163. continue; 
  164. //We only want custom post types 
  165. if(!$post_type->_builtin) 
  166. //Translate the old 'page' taxonomy type to BCN_POST_PARENT 
  167. if($this->opt['Spost_' . $post_type->name . '_taxonomy_type'] === 'page') 
  168. $this->opt['Spost_' . $post_type->name . '_taxonomy_type'] = 'BCN_POST_PARENT'; 
  169. //Translate the old 'date' taxonomy type to BCN_DATE 
  170. if($this->opt['Spost_' . $post_type->name . '_taxonomy_type'] === 'date') 
  171. $this->opt['Spost_' . $post_type->name . '_taxonomy_type'] = 'BCN_DATE'; 
  172. if(!isset($this->opt['Spost_' . $post_type->name . '_taxonomy_referer'])) 
  173. $this->opt['bpost_' . $post_type->name . '_taxonomy_referer'] = false; 
  174. //Set the max title length to 20 if we are not limiting the title and the length was 0 
  175. if(!$opts['blimit_title'] && $opts['amax_title_length'] == 0) 
  176. $opts['amax_title_length'] = 20; 
  177. //Save the passed in opts to the object's option array 
  178. $this->opt = $opts; 
  179. //End with resetting up the options 
  180. breadcrumb_navxt::setup_options($this->opt); 
  181. function opts_update_prebk(&$opts) 
  182. //This may no longer be needed 
  183. breadcrumb_navxt::setup_options($opts); 
  184. $opts = apply_filters('bcn_opts_update_prebk', $opts); 
  185. /** 
  186. * help action hook function 
  187. *  
  188. * @return string 
  189. *  
  190. */ 
  191. function help() 
  192. $screen = get_current_screen(); 
  193. //Exit early if the add_help_tab function doesn't exist 
  194. if(!method_exists($screen, 'add_help_tab')) 
  195. return; 
  196. //Add contextual help on current screen 
  197. if($screen->id == 'settings_page_' . $this->identifier) 
  198. $general_tab = '<p>' . __('Tips for the settings are located below select options.', 'breadcrumb-navxt') . 
  199. '</p><h5>' . __('Resources', 'breadcrumb-navxt') . '</h5><ul><li>' . 
  200. sprintf(__("%sTutorials and How Tos%s: There are several guides, tutorials, and how tos available on the author's website.", 'breadcrumb-navxt'), '<a title="' . __('Go to the Breadcrumb NavXT tag archive.', 'breadcrumb-navxt') . '" href="https://mtekk.us/archives/tag/breadcrumb-navxt">', '</a>') . '</li><li>' . 
  201. sprintf(__('%sOnline Documentation%s: Check out the documentation for more indepth technical information.', 'breadcrumb-navxt'), '<a title="' . __('Go to the Breadcrumb NavXT online documentation', 'breadcrumb-navxt') . '" href="https://mtekk.us/code/breadcrumb-navxt/breadcrumb-navxt-doc/">', '</a>') . '</li><li>' . 
  202. sprintf(__('%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.', 'breadcrumb-navxt'), '<a title="' . __('Go to the Breadcrumb NavXT support post for your version.', 'breadcrumb-navxt') . '" href="https://mtekk.us/archives/wordpress/plugins-wordpress/breadcrumb-navxt-' . $this::version . '/#respond">', '</a>') . '</li></ul>' .  
  203. '<h5>' . __('Giving Back', 'breadcrumb-navxt') . '</h5><ul><li>' . 
  204. sprintf(__('%sDonate%s: Love Breadcrumb NavXT and want to help development? Consider buying the author a beer.', 'breadcrumb-navxt'), '<a title="' . __('Go to PayPal to give a donation to Breadcrumb NavXT.', 'breadcrumb-navxt') . '" 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>' . 
  205. sprintf(__('%sTranslate%s: Is your language not available? Visit the Breadcrumb NavXT translation project on WordPress.org to start translating.', 'breadcrumb-navxt'), '<a title="' . __('Go to the Breadcrumb NavXT translation project.', 'breadcrumb-navxt') . '" href="https://translate.wordpress.org/projects/wp-plugins/breadcrumb-navxt">', '</a>') . '</li></ul>'; 
  206.  
  207. $screen->add_help_tab( 
  208. array( 
  209. 'id' => $this->identifier . '-base',  
  210. 'title' => __('General', 'breadcrumb-navxt'),  
  211. 'content' => $general_tab 
  212. )); 
  213. $quickstart_tab = '<p>' . __('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.', 'breadcrumb-navxt') . 
  214. '</p><h5>' . __('Breadcrumb trail with separators', 'breadcrumb-navxt') . '</h5><pre><code><div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">' . " 
  215. <?php if(function_exists('bcn_display')) 
  216. bcn_display(); 
  217. }?> 
  218. </div></code></pre>" . 
  219. '<h5>' . __('Breadcrumb trail in list form', 'breadcrumb-navxt').'</h5><pre><code><ol class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">'." 
  220. <?php if(function_exists('bcn_display_list')) 
  221. bcn_display_list(); 
  222. }?> 
  223. </ol></code></pre>"; 
  224. $screen->add_help_tab( 
  225. array( 
  226. 'id' => $this->identifier . '-quick-start',  
  227. 'title' => __('Quick Start', 'breadcrumb-navxt'),  
  228. 'content' => $quickstart_tab 
  229. )); 
  230. $styling_tab = '<p>' . __('Using the code from the Quick Start section above, the following CSS can be used as base for styling your breadcrumb trail.', 'breadcrumb-navxt') . '</p>' . 
  231. '<pre><code>.breadcrumbs 
  232. font-size: 1.1em; 
  233. color: #fff; 
  234. margin: 30px 0 0 10px; 
  235. position: relative; 
  236. float: left; 
  237. }</code></pre>'; 
  238. $screen->add_help_tab( 
  239. array( 
  240. 'id' => $this->identifier . '-styling',  
  241. 'title' => __('Styling', 'breadcrumb-navxt'),  
  242. 'content' => $styling_tab 
  243. )); 
  244. $screen->add_help_tab( 
  245. array( 
  246. 'id' => $this->identifier . '-import-export-reset',  
  247. 'title' => __('Import/Export/Reset', 'breadcrumb-navxt'),  
  248. 'content' => $this->import_form() 
  249. )); 
  250. /** 
  251. * enqueue's the tab style sheet on the settings page 
  252. */ 
  253. function admin_styles() 
  254. wp_enqueue_style('mtekk_adminkit_tabs'); 
  255. /** 
  256. * enqueue's the tab js and translation js on the settings page 
  257. */ 
  258. function admin_scripts() 
  259. //Enqueue ui-tabs 
  260. wp_enqueue_script('jquery-ui-tabs'); 
  261. //Enqueue the admin tabs javascript 
  262. wp_enqueue_script('mtekk_adminkit_tabs'); 
  263. //Load the translations for the tabs 
  264. wp_localize_script('mtekk_adminkit_tabs', 'objectL10n', array( 
  265. 'mtad_uid' => 'bcn_admin',  
  266. 'mtad_import' => __('Import', 'breadcrumb-navxt'),  
  267. 'mtad_export' => __('Export', 'breadcrumb-navxt'),  
  268. 'mtad_reset' => __('Reset', 'breadcrumb-navxt'),  
  269. )); 
  270. //Enqueue the admin enable/disable groups javascript 
  271. wp_enqueue_script('mtekk_adminkit_engroups'); 
  272. /** 
  273. * A message function that checks for the BCN_SETTINGS_* define statement 
  274. */ 
  275. function multisite_settings_warn() 
  276. if(is_multisite()) 
  277. if(defined('BCN_SETTINGS_USE_LOCAL') && BCN_SETTINGS_USE_LOCAL) 
  278.  
  279. else if(defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK) 
  280. $this->message['updated fade'][] = __('Warning: Your network settings will override any settings set in this page.', 'breadcrumb-navxt'); 
  281. else if(defined('BCN_SETTINGS_FAVOR_LOCAL') && BCN_SETTINGS_FAVOR_LOCAL) 
  282. $this->message['updated fade'][] = __('Warning: Your network settings may override any settings set in this page.', 'breadcrumb-navxt'); 
  283. else if(defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK) 
  284. $this->message['updated fade'][] = __('Warning: Your network settings may override any settings set in this page.', 'breadcrumb-navxt'); 
  285. //Fall through if no settings mode was set 
  286. else 
  287. $this->message['updated fade'][] = __('Warning: No BCN_SETTINGS_* define statement found, defaulting to BCN_SETTINGS_USE_LOCAL.', 'breadcrumb-navxt'); 
  288. /** 
  289. * A message function that checks for deprecated settings that are set and warns the user 
  290. */ 
  291. function deprecated_settings_warn() 
  292. //We're deprecating the limit title length setting, let the user know the new method of accomplishing this 
  293. if(isset($this->opt['blimit_title']) && $this->opt['blimit_title']) 
  294. $this->message['updated fade'][] = sprintf(__('Warning: Your are using a deprecated setting "Title Length" (see Miscellaneous > Deprecated), please %1$suse CSS instead%2$s.', 'breadcrumb-navxt'), '<a title="' . __('Go to the guide on trimming breadcrumb title lengths with CSS', 'breadcrumb-navxt') . '" href="https://mtekk.us/archives/guides/trimming-breadcrumb-title-lengths-with-css/">', '</a>'); 
  295. /** 
  296. * The administrative page for Breadcrumb NavXT 
  297. */ 
  298. function admin_page() 
  299. global $wp_taxonomies, $wp_post_types; 
  300. $this->security(); 
  301. //Do a check on deprecated settings 
  302. $this->deprecated_settings_warn(); 
  303. //Do a check for multisite settings mode 
  304. $this->multisite_settings_warn(); 
  305. do_action($this->unique_prefix . '_settings_pre_messages', $this->opt); 
  306. //Display our messages 
  307. $this->messages(); 
  308. ?> 
  309. <div class="wrap"><h2><?php echo $this->full_name; ?></h2> 
  310. <?php 
  311. //We exit after the version check if there is an action the user needs to take before saving settings 
  312. if(!$this->version_check(get_option($this->unique_prefix . '_version'))) 
  313. return; 
  314. ?> 
  315. <form action="<?php echo $this->admin_url(); ?>" method="post" id="bcn_admin-options"> 
  316. <?php settings_fields('bcn_options');?> 
  317. <div id="hasadmintabs"> 
  318. <fieldset id="general" class="bcn_options"> 
  319. <h3 class="tab-title" title="<?php _e('A collection of settings most likely to be modified are located under this tab.', 'breadcrumb-navxt');?>"><?php _e('General', 'breadcrumb-navxt'); ?></h3> 
  320. <h3><?php _e('General', 'breadcrumb-navxt'); ?></h3> 
  321. <table class="form-table"> 
  322. <?php 
  323. $this->input_text(__('Breadcrumb Separator', 'breadcrumb-navxt'), 'hseparator', 'regular-text', false, __('Placed in between each breadcrumb.', 'breadcrumb-navxt')); 
  324. do_action($this->unique_prefix . '_settings_general', $this->opt); 
  325. ?> 
  326. </table> 
  327. <h3><?php _e('Current Item', 'breadcrumb-navxt'); ?></h3> 
  328. <table class="form-table"> 
  329. <?php 
  330. $this->input_check(__('Link Current Item', 'breadcrumb-navxt'), 'bcurrent_item_linked', __('Yes', 'breadcrumb-navxt')); 
  331. $this->input_check(_x('Paged Breadcrumb', 'Paged as in when on an archive or post that is split into multiple pages', 'breadcrumb-navxt'), 'bpaged_display', __('Place the page number breadcrumb in the trail.', 'breadcrumb-navxt'), false, __('Indicates that the user is on a page other than the first of a paginated archive or post.', 'breadcrumb-navxt')); 
  332. $this->input_text(_x('Paged Template', 'Paged as in when on an archive or post that is split into multiple pages', 'breadcrumb-navxt'), 'Hpaged_template', 'large-text', false, __('The template for paged breadcrumbs.', 'breadcrumb-navxt')); 
  333. do_action($this->unique_prefix . '_settings_current_item', $this->opt); 
  334. ?> 
  335. </table> 
  336. <h3><?php _e('Home Breadcrumb', 'breadcrumb-navxt'); ?></h3> 
  337. <table class="form-table adminkit-engroup"> 
  338. <?php  
  339. $this->input_check(__('Home Breadcrumb', 'breadcrumb-navxt'), 'bhome_display', __('Place the home breadcrumb in the trail.', 'breadcrumb-navxt')); 
  340. $this->textbox(__('Home Template', 'breadcrumb-navxt'), 'Hhome_template', '6', false, __('The template for the home breadcrumb.', 'breadcrumb-navxt')); 
  341. $this->textbox(__('Home Template (Unlinked)', 'breadcrumb-navxt'), 'Hhome_template_no_anchor', '4', false, __('The template for the home breadcrumb, used when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  342. do_action($this->unique_prefix . '_settings_home', $this->opt); 
  343. ?> 
  344. </table> 
  345. <h3><?php _e('Blog Breadcrumb', 'breadcrumb-navxt'); ?></h3> 
  346. <table class="form-table adminkit-engroup"> 
  347. <?php 
  348. $this->input_check(__('Blog Breadcrumb', 'breadcrumb-navxt'), 'bblog_display', __('Place the blog breadcrumb in the trail.', 'breadcrumb-navxt'), (get_option('show_on_front') !== 'page' || get_option('page_for_posts') < 1)); 
  349. $this->textbox(__('Blog Template', 'breadcrumb-navxt'), 'Hblog_template', '6', (get_option('show_on_front') !== 'page' || get_option('page_for_posts') < 1), __('The template for the blog breadcrumb, used only in static front page environments.', 'breadcrumb-navxt')); 
  350. $this->textbox(__('Blog Template (Unlinked)', 'breadcrumb-navxt'), 'Hblog_template_no_anchor', '4', (get_option('show_on_front') !== 'page' || get_option('page_for_posts') < 1), __('The template for the blog breadcrumb, used only in static front page environments and when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  351. do_action($this->unique_prefix . '_settings_blog', $this->opt); 
  352. ?> 
  353. </table> 
  354. <h3><?php _e('Mainsite Breadcrumb', 'breadcrumb-navxt'); ?></h3> 
  355. <table class="form-table adminkit-engroup"> 
  356. <?php 
  357. $this->input_check(__('Main Site Breadcrumb', 'breadcrumb-navxt'), 'bmainsite_display', __('Place the main site home breadcrumb in the trail in an multisite setup.', 'breadcrumb-navxt'), !is_multisite()); 
  358. $this->textbox(__('Main Site Home Template', 'breadcrumb-navxt'), 'Hmainsite_template', '6', !is_multisite(), __('The template for the main site home breadcrumb, used only in multisite environments.', 'breadcrumb-navxt')); 
  359. $this->textbox(__('Main Site Home Template (Unlinked)', 'breadcrumb-navxt'), 'Hmainsite_template_no_anchor', '4', !is_multisite(), __('The template for the main site home breadcrumb, used only in multisite environments and when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  360. do_action($this->unique_prefix . '_settings_mainsite', $this->opt); 
  361. ?> 
  362. </table> 
  363. <?php do_action($this->unique_prefix . '_after_settings_tab_general', $this->opt); ?> 
  364. </fieldset> 
  365. <fieldset id="post" class="bcn_options"> 
  366. <h3 class="tab-title" title="<?php _e('The settings for all post types (Posts, Pages, and Custom Post Types) are located under this tab.', 'breadcrumb-navxt');?>"><?php _e('Post Types', 'breadcrumb-navxt'); ?></h3> 
  367. <h3><?php _e('Posts', 'breadcrumb-navxt'); ?></h3> 
  368. <table class="form-table adminkit-enset-top"> 
  369. <?php 
  370. $this->textbox(__('Post Template', 'breadcrumb-navxt'), 'Hpost_post_template', '6', false, __('The template for post breadcrumbs.', 'breadcrumb-navxt')); 
  371. $this->textbox(__('Post Template (Unlinked)', 'breadcrumb-navxt'), 'Hpost_post_template_no_anchor', '4', false, __('The template for post breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  372. $this->input_check(__('Post Hierarchy Display', 'breadcrumb-navxt'), 'bpost_post_taxonomy_display', __('Show the hierarchy (specified below) leading to a post in the breadcrumb trail.', 'breadcrumb-navxt'), false, '', 'adminkit-enset-ctrl adminkit-enset'); 
  373. $this->input_check(__('Post Hierarchy Referer Influence', 'breadcrumb-navxt'), 'bpost_post_taxonomy_referer', __('Allow the referring page to influence the taxonomy selected for the hierarchy.', 'breadcrumb-navxt'), false, '', 'adminkit-enset'); 
  374. ?> 
  375. <tr valign="top"> 
  376. <th scope="row"> 
  377. <?php _e('Post Hierarchy', 'breadcrumb-navxt'); ?> 
  378. </th> 
  379. <td> 
  380. <?php 
  381. $this->input_radio('Spost_post_taxonomy_type', 'category', __('Categories'), false, 'adminkit-enset'); 
  382. $this->input_radio('Spost_post_taxonomy_type', 'BCN_DATE', __('Dates', 'breadcrumb-navxt'), false, 'adminkit-enset'); 
  383. $this->input_radio('Spost_post_taxonomy_type', 'post_tag', __('Tags'), false, 'adminkit-enset'); 
  384. //We use the value 'page' but really, this will follow the parent post hierarchy 
  385. $this->input_radio('Spost_post_taxonomy_type', 'BCN_POST_PARENT', __('Post Parent', 'breadcrumb-navxt'), false, 'adminkit-enset'); 
  386. //Loop through all of the taxonomies in the array 
  387. foreach($wp_taxonomies as $taxonomy) 
  388. //Check for non-public taxonomies 
  389. if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name)) 
  390. continue; 
  391. //We only want custom taxonomies 
  392. if(($taxonomy->object_type == 'post' || is_array($taxonomy->object_type) && in_array('post', $taxonomy->object_type)) && !$taxonomy->_builtin) 
  393. $this->input_radio('Spost_post_taxonomy_type', $taxonomy->name, mb_convert_case($taxonomy->label, MB_CASE_TITLE, 'UTF-8'), false, 'adminkit-enset'); 
  394. ?> 
  395. <p class="description"><?php _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.', 'breadcrumb-navxt'); ?></p> 
  396. </td> 
  397. </tr> 
  398. </table> 
  399. <h3><?php _e('Pages', 'breadcrumb-navxt'); ?></h3> 
  400. <table class="form-table"> 
  401. <?php 
  402. $this->textbox(__('Page Template', 'breadcrumb-navxt'), 'Hpost_page_template', '6', false, __('The template for page breadcrumbs.', 'breadcrumb-navxt')); 
  403. $this->textbox(__('Page Template (Unlinked)', 'breadcrumb-navxt'), 'Hpost_page_template_no_anchor', '4', false, __('The template for page breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  404. ?> 
  405. </table> 
  406. <h3><?php _e('Attachments', 'breadcrumb-navxt'); ?></h3> 
  407. <table class="form-table"> 
  408. <?php 
  409. $this->textbox(__('Attachment Template', 'breadcrumb-navxt'), 'Hpost_attachment_template', '6', false, __('The template for attachment breadcrumbs.', 'breadcrumb-navxt')); 
  410. $this->textbox(__('Attachment Template (Unlinked)', 'breadcrumb-navxt'), 'Hpost_attachment_template_no_anchor', '4', false, __('The template for attachment breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  411. ?> 
  412. </table> 
  413. <?php 
  414. //Loop through all of the post types in the array 
  415. foreach($wp_post_types as $post_type) 
  416. //Check for non-public CPTs 
  417. if(!apply_filters('bcn_show_cpt_private', $post_type->public, $post_type->name)) 
  418. continue; 
  419. //We only want custom post types 
  420. if(!$post_type->_builtin) 
  421. $singular_name_lc = mb_strtolower($post_type->labels->singular_name, 'UTF-8'); 
  422. ?> 
  423. <h3><?php echo $post_type->labels->singular_name; ?></h3> 
  424. <table class="form-table adminkit-enset-top"> 
  425. <?php 
  426. $this->textbox(sprintf(__('%s Template', 'breadcrumb-navxt'), $post_type->labels->singular_name), 'Hpost_' . $post_type->name . '_template', '6', false, sprintf(__('The template for %s breadcrumbs.', 'breadcrumb-navxt'), $singular_name_lc)); 
  427. $this->textbox(sprintf(__('%s Template (Unlinked)', 'breadcrumb-navxt'), $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.', 'breadcrumb-navxt'), $singular_name_lc)); 
  428. $optid = $this->get_valid_id('apost_' . $post_type->name . '_root'); 
  429. ?> 
  430. <tr valign="top"> 
  431. <th scope="row"> 
  432. <label for="<?php echo $optid;?>"><?php printf(__('%s Root Page', 'breadcrumb-navxt'), $post_type->labels->singular_name);?></label> 
  433. </th> 
  434. <td> 
  435. <?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']));?> 
  436. </td> 
  437. </tr> 
  438. <?php 
  439. $this->input_check(sprintf(__('%s Archive Display', 'breadcrumb-navxt'), $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.', 'breadcrumb-navxt'), $singular_name_lc), !$post_type->has_archive); 
  440. $this->input_check(sprintf(__('%s Hierarchy Display', 'breadcrumb-navxt'), $post_type->labels->singular_name), 'bpost_' . $post_type->name . '_taxonomy_display', sprintf(__('Show the hierarchy (specified below) leading to a %s in the breadcrumb trail.', 'breadcrumb-navxt'), $singular_name_lc), false, '', 'adminkit-enset-ctrl adminkit-enset'); 
  441. $this->input_check(sprintf(__('%s Hierarchy Referer Influence', 'breadcrumb-navxt'), $post_type->labels->singular_name), 'bpost_' . $post_type->name . '_taxonomy_referer', __('Allow the referring page to influence the taxonomy selected for the hierarchy.', 'breadcrumb-navxt'), false, '', 'adminkit-enset'); 
  442. ?> 
  443. <tr valign="top"> 
  444. <th scope="row"> 
  445. <?php printf(__('%s Hierarchy', 'breadcrumb-navxt'), $post_type->labels->singular_name); ?> 
  446. </th> 
  447. <td> 
  448. <?php 
  449. //We use the value 'page' but really, this will follow the parent post hierarchy 
  450. $this->input_radio('Spost_' . $post_type->name . '_taxonomy_type', 'BCN_POST_PARENT', __('Post Parent', 'breadcrumb-navxt'), false, 'adminkit-enset'); 
  451. $this->input_radio('Spost_' . $post_type->name . '_taxonomy_type', 'BCN_DATE', __('Dates', 'breadcrumb-navxt'), false, 'adminkit-enset'); 
  452. //Loop through all of the taxonomies in the array 
  453. foreach($wp_taxonomies as $taxonomy) 
  454. //Check for non-public taxonomies 
  455. if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name)) 
  456. continue; 
  457. //We only want custom taxonomies 
  458. if($taxonomy->object_type == $post_type->name || in_array($post_type->name, $taxonomy->object_type)) 
  459. $this->input_radio('Spost_' . $post_type->name . '_taxonomy_type', $taxonomy->name, $taxonomy->labels->singular_name, false, 'adminkit-enset'); 
  460. ?> 
  461. <p class="description"> 
  462. <?php 
  463. if($post_type->hierarchical) 
  464. _e('The hierarchy which the breadcrumb trail will show.', 'breadcrumb-navxt');  
  465. else 
  466. _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.', 'breadcrumb-navxt'); 
  467. ?> 
  468. </p> 
  469. </td> 
  470. </tr> 
  471. </table> 
  472. <?php 
  473. do_action($this->unique_prefix . '_after_settings_tab_post', $this->opt); 
  474. ?> 
  475. </fieldset> 
  476. <fieldset id="tax" class="bcn_options alttab"> 
  477. <h3 class="tab-title" title="<?php _e('The settings for all taxonomies (including Categories, Tags, and custom taxonomies) are located under this tab.', 'breadcrumb-navxt');?>"><?php _e('Taxonomies', 'breadcrumb-navxt'); ?></h3> 
  478. <h3><?php _e('Categories', 'breadcrumb-navxt'); ?></h3> 
  479. <table class="form-table"> 
  480. <?php 
  481. $this->textbox(__('Category Template', 'breadcrumb-navxt'), 'Htax_category_template', '6', false, __('The template for category breadcrumbs.', 'breadcrumb-navxt')); 
  482. $this->textbox(__('Category Template (Unlinked)', 'breadcrumb-navxt'), 'Htax_category_template_no_anchor', '4', false, __('The template for category breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  483. ?> 
  484. </table> 
  485. <h3><?php _e('Tags', 'breadcrumb-navxt'); ?></h3> 
  486. <table class="form-table"> 
  487. <?php 
  488. $this->textbox(__('Tag Template', 'breadcrumb-navxt'), 'Htax_post_tag_template', '6', false, __('The template for tag breadcrumbs.', 'breadcrumb-navxt')); 
  489. $this->textbox(__('Tag Template (Unlinked)', 'breadcrumb-navxt'), 'Htax_post_tag_template_no_anchor', '4', false, __('The template for tag breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  490. ?> 
  491. </table> 
  492. <h3><?php _e('Post Formats', 'breadcrumb-navxt'); ?></h3> 
  493. <table class="form-table"> 
  494. <?php 
  495. $this->textbox(__('Post Format Template', 'breadcrumb-navxt'), 'Htax_post_format_template', '6', false, __('The template for post format breadcrumbs.', 'breadcrumb-navxt')); 
  496. $this->textbox(__('Post Format Template (Unlinked)', 'breadcrumb-navxt'), 'Htax_post_format_template_no_anchor', '4', false, __('The template for post_format breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  497. ?> 
  498. </table> 
  499. <?php 
  500. //Loop through all of the taxonomies in the array 
  501. foreach($wp_taxonomies as $taxonomy) 
  502. //Check for non-public taxonomies 
  503. if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name)) 
  504. continue; 
  505. //We only want custom taxonomies 
  506. if(!$taxonomy->_builtin) 
  507. $label_lc = mb_strtolower($taxonomy->label, 'UTF-8'); 
  508. ?> 
  509. <h3><?php echo mb_convert_case($taxonomy->label, MB_CASE_TITLE, 'UTF-8'); ?></h3> 
  510. <table class="form-table"> 
  511. <?php 
  512. $this->textbox(sprintf(__('%s Template', 'breadcrumb-navxt'), $taxonomy->labels->singular_name), 'Htax_' . $taxonomy->name . '_template', '6', false, sprintf(__('The template for %s breadcrumbs.', 'breadcrumb-navxt'), $label_lc)); 
  513. $this->textbox(sprintf(__('%s Template (Unlinked)', 'breadcrumb-navxt'), $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.', 'breadcrumb-navxt'), $label_lc)); 
  514. ?> 
  515. </table> 
  516. <?php 
  517. do_action($this->unique_prefix . '_after_settings_tab_taxonomy', $this->opt); ?> 
  518. </fieldset> 
  519. <fieldset id="miscellaneous" class="bcn_options"> 
  520. <h3 class="tab-title" title="<?php _e('The settings for author and date archives, searches, and 404 pages are located under this tab.', 'breadcrumb-navxt');?>"><?php _e('Miscellaneous', 'breadcrumb-navxt'); ?></h3> 
  521. <h3><?php _e('Author Archives', 'breadcrumb-navxt'); ?></h3> 
  522. <table class="form-table"> 
  523. <?php 
  524. $this->textbox(__('Author Template', 'breadcrumb-navxt'), 'Hauthor_template', '6', false, __('The template for author breadcrumbs.', 'breadcrumb-navxt')); 
  525. $this->textbox(__('Author Template (Unlinked)', 'breadcrumb-navxt'), 'Hauthor_template_no_anchor', '4', false, __('The template for author breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  526. $this->input_select(__('Author Display Format', 'breadcrumb-navxt'), '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.', 'breadcrumb-navxt')); 
  527. ?> 
  528. </table> 
  529. <h3><?php _e('Miscellaneous', 'breadcrumb-navxt'); ?></h3> 
  530. <table class="form-table"> 
  531. <?php 
  532. $this->textbox(__('Date Template', 'breadcrumb-navxt'), 'Hdate_template', '6', false, __('The template for date breadcrumbs.', 'breadcrumb-navxt')); 
  533. $this->textbox(__('Date Template (Unlinked)', 'breadcrumb-navxt'), 'Hdate_template_no_anchor', '4', false, __('The template for date breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  534. $this->textbox(__('Search Template', 'breadcrumb-navxt'), 'Hsearch_template', '6', false, __('The anchor template for search breadcrumbs, used only when the search results span several pages.', 'breadcrumb-navxt')); 
  535. $this->textbox(__('Search Template (Unlinked)', 'breadcrumb-navxt'), '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.', 'breadcrumb-navxt')); 
  536. $this->input_text(__('404 Title', 'breadcrumb-navxt'), 'S404_title', 'regular-text'); 
  537. $this->textbox(__('404 Template', 'breadcrumb-navxt'), 'H404_template', '4', false, __('The template for 404 breadcrumbs.', 'breadcrumb-navxt')); 
  538. ?> 
  539. </table> 
  540. <h3><?php _e('Deprecated', 'breadcrumb-navxt'); ?></h3> 
  541. <table class="form-table"> 
  542. <tr valign="top"> 
  543. <th scope="row"> 
  544. <?php _e('Title Length', 'breadcrumb-navxt'); ?>  
  545. </th> 
  546. <td> 
  547. <label> 
  548. <input name="bcn_options[blimit_title]" type="checkbox" id="blimit_title" value="true" <?php checked(true, $this->opt['blimit_title']); ?> /> 
  549. <?php printf(__('Limit the length of the breadcrumb title. (Deprecated, %suse CSS instead%s)', 'breadcrumb-navxt'), '<a title="' . __('Go to the guide on trimming breadcrumb title lengths with CSS', 'breadcrumb-navxt') . '" href="https://mtekk.us/archives/guides/trimming-breadcrumb-title-lengths-with-css/">', '</a>');?> 
  550. </label><br /> 
  551. <ul> 
  552. <li> 
  553. <label for="amax_title_length"> 
  554. <?php _e('Max Title Length: ', 'breadcrumb-navxt');?> 
  555. <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" /> 
  556. </label> 
  557. </li> 
  558. </ul> 
  559. </td> 
  560. </tr> 
  561. </table> 
  562. <?php do_action($this->unique_prefix . '_after_settings_tab_miscellaneous', $this->opt); ?> 
  563. </fieldset> 
  564. <?php do_action($this->unique_prefix . '_after_settings_tabs', $this->opt); ?> 
  565. </div> 
  566. <p class="submit"><input type="submit" class="button-primary" name="bcn_admin_options" value="<?php esc_attr_e('Save Changes') ?>" /></p> 
  567. </form> 
  568. </div> 
  569. <?php 
.