/class.bcn_network_admin.php

  1. <?php 
  2. /** Copyright 2007-2016 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_network_admin extends mtekk_adminKit 
  36. const version = '5.5.2'; 
  37. protected $full_name = 'Breadcrumb NavXT Network Settings'; 
  38. protected $short_name = 'Breadcrumb NavXT'; 
  39. protected $access_level = 'manage_network_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. * @param bcn_breadcrumb_trail $breadcrumb_trail a breadcrumb trail object 
  48. * @param string $basename The basename of the plugin 
  49. */ 
  50. function __construct(bcn_breadcrumb_trail $breadcrumb_trail, $basename) 
  51. $this->breadcrumb_trail = $breadcrumb_trail; 
  52. $this->plugin_basename = $basename; 
  53. $this->full_name = __('Breadcrumb NavXT Network Settings', 'breadcrumb-navxt'); 
  54. //Grab defaults from the breadcrumb_trail object 
  55. $this->opt = $this->breadcrumb_trail->opt; 
  56. add_action('network_admin_menu', array($this, 'add_page')); 
  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. * Return the URL of the settings page for the plugin 
  75. */ 
  76. function admin_url() 
  77. return admin_url('network/settings.php?page=' . $this->identifier); 
  78. /** 
  79. * Adds the adminpage the menu and the nice little settings link 
  80. */ 
  81. function add_page() 
  82. //Add the submenu page to "settings" menu 
  83. $hookname = add_submenu_page('settings.php', $this->full_name, $this->short_name, $this->access_level, $this->identifier, array($this, 'net_admin_page')); 
  84. // check capability of user to manage options (access control) 
  85. if(current_user_can($this->access_level)) 
  86. //Register admin_head-$hookname callback 
  87. add_action('admin_head-' . $hookname, array($this, 'admin_head')); 
  88. //Register admin_print_styles-$hookname callback 
  89. add_action('admin_print_styles-' . $hookname, array($this, 'admin_styles')); 
  90. //Register admin_print_scripts-$hookname callback 
  91. add_action('admin_print_scripts-' . $hookname, array($this, 'admin_scripts')); 
  92. //Register Help Output 
  93. add_action('load-' . $hookname, array($this, 'help')); 
  94. /** 
  95. * Have to hook into get_option and replace with network wide alternate 
  96. *  
  97. * @param string $option The name of the option to retrieve 
  98. * @return mixed The value of the option 
  99. */ 
  100. function get_option($option) 
  101. return get_site_option($option); 
  102. /** 
  103. * Have to hook into update_option and replace with network wide alternate 
  104. *  
  105. * @param string $option The name of the option to update 
  106. * @param mixed $newvalue The new value to set the option to 
  107. *  
  108. */ 
  109. function update_option($option, $newvalue) 
  110. return update_site_option($option, $newvalue); 
  111. /** 
  112. * Have to hook into add_option and replace with network wide alternate 
  113. *  
  114. * @param string $option The name of the option to update 
  115. * @param mixed $value The new value to set the option to 
  116. * @param null $deprecated Deprecated parameter 
  117. * @param string $autoload Whether or not to autoload the option, it's a string because WP is special 
  118. *  
  119. */ 
  120. function add_option($option, $value = '', $deprecated = '', $autoload = 'yes') 
  121. return add_site_option($option, $value); 
  122. /** 
  123. * Have to hook into delete_option and replace with network wide alternate 
  124. *  
  125. * @param string $option The name of the option to delete 
  126. */ 
  127. function delete_option($option) 
  128. return delete_site_option($option); 
  129. /** 
  130. * Upgrades input options array, sets to $this->opt 
  131. *  
  132. * @param array $opts 
  133. * @param string $version the version of the passed in options 
  134. */ 
  135. function opts_upgrade($opts, $version) 
  136. global $wp_post_types, $wp_taxonomies; 
  137. //If our version is not the same as in the db, time to update 
  138. if(version_compare($version, $this::version, '<')) 
  139. //Upgrading to 3.8.1 
  140. if(version_compare($version, '3.8.1', '<')) 
  141. $opts['post_page_root'] = get_option('page_on_front'); 
  142. $opts['post_post_root'] = get_option('page_for_posts'); 
  143. //Upgrading to 4.0 
  144. if(version_compare($version, '4.0.0', '<')) 
  145. //Only migrate if we haven't migrated yet 
  146. if(isset($opts['current_item_linked'])) 
  147. //Loop through the old options, migrate some of them 
  148. foreach($opts as $option => $value) 
  149. //Handle all of our boolean options first, they're real easy, just add a 'b' 
  150. if(strpos($option, 'display') > 0 || $option == 'current_item_linked') 
  151. $this->breadcrumb_trail->opt['b' . $option] = $value; 
  152. //Handle migration of anchor templates to the templates 
  153. else if(strpos($option, 'anchor') > 0) 
  154. $parts = explode('_', $option); 
  155. //Do excess slash removal sanitation 
  156. $this->breadcrumb_trail->opt['H' . $parts[0] . '_template'] = $value . '%htitle%</a>'; 
  157. //Handle our abs integers 
  158. else if($option == 'max_title_length' || $option == 'post_post_root' || $option == 'post_page_root') 
  159. $this->breadcrumb_trail->opt['a' . $option] = $value; 
  160. //Now everything else, minus prefix and suffix 
  161. else if(strpos($option, 'prefix') === false && strpos($option, 'suffix') === false) 
  162. $this->breadcrumb_trail->opt['S' . $option] = $value; 
  163. //Add in the new settings for CPTs introduced in 4.0 
  164. foreach($wp_post_types as $post_type) 
  165. //We only want custom post types 
  166. if(!$post_type->_builtin) 
  167. //Add in the archive_display option 
  168. $this->breadcrumb_trail->opt['bpost_' . $post_type->name . '_archive_display'] = $post_type->has_archive; 
  169. $opts = $this->breadcrumb_trail->opt; 
  170. if(version_compare($version, '4.0.1', '<')) 
  171. if(isset($opts['Hcurrent_item_template_no_anchor'])) 
  172. unset($opts['Hcurrent_item_template_no_anchor']); 
  173. if(isset($opts['Hcurrent_item_template'])) 
  174. unset($opts['Hcurrent_item_template']); 
  175. //Upgrading to 4.3.0 
  176. if(version_compare($version, '4.3.0', '<')) 
  177. //Removed home_title 
  178. if(isset($opts['Shome_title'])) 
  179. unset($opts['Shome_title']); 
  180. //Removed mainsite_title 
  181. if(isset($opts['Smainsite_title'])) 
  182. unset($opts['Smainsite_title']); 
  183. //Upgrading to 5.1.0 
  184. if(version_compare($version, '5.1.0', '<')) 
  185. foreach($wp_taxonomies as $taxonomy) 
  186. //If we have the old options style for it, update 
  187. if($taxonomy->name !== 'post_format' && isset($opts['H' . $taxonomy->name . '_template'])) 
  188. //Migrate to the new setting name 
  189. $opts['Htax_' . $taxonomy->name . '_template'] = $opts['H' . $taxonomy->name . '_template']; 
  190. $opts['Htax_' . $taxonomy->name . '_template_no_anchor'] = $opts['H' . $taxonomy->name . '_template_no_anchor']; 
  191. //Clean up old settings 
  192. unset($opts['H' . $taxonomy->name . '_template']); 
  193. unset($opts['H' . $taxonomy->name . '_template_no_anchor']); 
  194. //Upgrading to 5.4.0 
  195. if(version_compare($version, '5.4.0', '<')) 
  196. //Migrate users to schema.org breadcrumbs for author and search if still on the defaults for posts 
  197. if($opts['Hpost_post_template'] === bcn_breadcrumb::get_default_template() && $opts['Hpost_post_template_no_anchor'] === bcn_breadcrumb::default_template_no_anchor) 
  198. if($opts['Hpaged_template'] === 'Page %htitle%') 
  199. $opts['Hpaged_template'] = $this->opt['Hpaged_template']; 
  200. 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>'') 
  201. $opts['Hsearch_template'] = $this->opt['Hsearch_template']; 
  202. if($opts['Hsearch_template_no_anchor'] === 'Search results for '%htitle%'' || $opts['Hsearch_template_no_anchor'] === 'Search results for '%htitle%'') 
  203. $opts['Hsearch_template_no_anchor'] = $this->opt['Hsearch_template_no_anchor']; 
  204. if($opts['Hauthor_template'] === 'Articles by: <a title="Go to the first page of posts by %title%." href="%link%" class="%type%">%htitle%</a>') 
  205. $opts['Hauthor_template'] = $this->opt['Hauthor_template']; 
  206. if($opts['Hauthor_template_no_anchor'] === 'Articles by: %htitle%') 
  207. $opts['Hauthor_template_no_anchor'] = $this->opt['Hauthor_template_no_anchor']; 
  208. //Upgrading to 5.5.0 
  209. if(version_compare($version, '5.5.0', '<')) 
  210. //Translate the old 'page' taxonomy type to BCN_POST_PARENT 
  211. if($this->opt['Spost_post_taxonomy_type'] === 'page') 
  212. $this->opt['Spost_post_taxonomy_type'] = 'BCN_POST_PARENT'; 
  213. if(!isset($this->opt['Spost_post_taxonomy_referer'])) 
  214. $this->opt['bpost_post_taxonomy_referer'] = false; 
  215. //Loop through all of the post types in the array 
  216. foreach($wp_post_types as $post_type) 
  217. //Check for non-public CPTs 
  218. if(!apply_filters('bcn_show_cpt_private', $post_type->public, $post_type->name)) 
  219. continue; 
  220. //We only want custom post types 
  221. if(!$post_type->_builtin) 
  222. //Translate the old 'page' taxonomy type to BCN_POST_PARENT 
  223. if($this->opt['Spost_' . $post_type->name . '_taxonomy_type'] === 'page') 
  224. $this->opt['Spost_' . $post_type->name . '_taxonomy_type'] = 'BCN_POST_PARENT'; 
  225. //Translate the old 'date' taxonomy type to BCN_DATE 
  226. if($this->opt['Spost_' . $post_type->name . '_taxonomy_type'] === 'date') 
  227. $this->opt['Spost_' . $post_type->name . '_taxonomy_type'] = 'BCN_DATE'; 
  228. if(!isset($this->opt['Spost_' . $post_type->name . '_taxonomy_referer'])) 
  229. $this->opt['bpost_' . $post_type->name . '_taxonomy_referer'] = false; 
  230. //S 
  231. //Set the max title length to 20 if we are not limiting the title and the length was 0 
  232. if(!$opts['blimit_title'] && $opts['amax_title_length'] == 0) 
  233. $opts['amax_title_length'] = 20; 
  234. //Save the passed in opts to the object's option array 
  235. $this->opt = $opts; 
  236. //End with resetting up the options 
  237. breadcrumb_navxt::setup_options($this->opt); 
  238. function opts_update_prebk(&$opts) 
  239. //Add any new custom post types, or taxonomies 
  240. breadcrumb_navxt::setup_options($opts); 
  241. $opts = apply_filters('bcn_opts_update_prebk', $opts); 
  242. /** 
  243. * help action hook function 
  244. *  
  245. * @return string 
  246. *  
  247. */ 
  248. function help() 
  249. $screen = get_current_screen(); 
  250. //Exit early if the add_help_tab function doesn't exist 
  251. if(!method_exists($screen, 'add_help_tab')) 
  252. return; 
  253. //Add contextual help on current screen 
  254. if($screen->id == 'settings_page_' . $this->identifier) 
  255. $general_tab = '<p>' . __('Tips for the settings are located below select options.', 'breadcrumb-navxt') . 
  256. '</p><h5>' . __('Resources', 'breadcrumb-navxt') . '</h5><ul><li>' . 
  257. 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>' . 
  258. 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>' . 
  259. 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>' .  
  260. '<h5>' . __('Giving Back', 'breadcrumb-navxt') . '</h5><ul><li>' . 
  261. 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>' . 
  262. 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>'; 
  263.  
  264. $screen->add_help_tab( 
  265. array( 
  266. 'id' => $this->identifier . '-base',  
  267. 'title' => __('General', 'breadcrumb-navxt'),  
  268. 'content' => $general_tab 
  269. )); 
  270. $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') . 
  271. '</p><h5>' . __('Breadcrumb trail with separators', 'breadcrumb-navxt') . '</h5><pre><code><div class="breadcrumbs" typeof="BreadcrumbList" vocab="http://schema.org/">' . " 
  272. <?php if(function_exists('bcn_display')) 
  273. bcn_display(); 
  274. }?> 
  275. </div></code></pre>" . 
  276. '<h5>' . __('Breadcrumb trail in list form', 'breadcrumb-navxt').'</h5><pre><code><ol class="breadcrumbs" typeof="BreadcrumbList" vocab="http://schema.org/">'." 
  277. <?php if(function_exists('bcn_display_list')) 
  278. bcn_display_list(); 
  279. }?> 
  280. </ol></code></pre>"; 
  281. $screen->add_help_tab( 
  282. array( 
  283. 'id' => $this->identifier . '-quick-start',  
  284. 'title' => __('Quick Start', 'breadcrumb-navxt'),  
  285. 'content' => $quickstart_tab 
  286. )); 
  287. $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>' . 
  288. '<pre><code>.breadcrumbs 
  289. font-size: 1.1em; 
  290. color: #fff; 
  291. margin: 30px 0 0 10px; 
  292. position: relative; 
  293. float: left; 
  294. }</code></pre>'; 
  295. $screen->add_help_tab( 
  296. array( 
  297. 'id' => $this->identifier . '-styling',  
  298. 'title' => __('Styling', 'breadcrumb-navxt'),  
  299. 'content' => $styling_tab 
  300. )); 
  301. $screen->add_help_tab( 
  302. array( 
  303. 'id' => $this->identifier . '-import-export-reset',  
  304. 'title' => __('Import/Export/Reset', 'breadcrumb-navxt'),  
  305. 'content' => $this->import_form() 
  306. )); 
  307. /** 
  308. * enqueue's the tab style sheet on the settings page 
  309. */ 
  310. function admin_styles() 
  311. wp_enqueue_style('mtekk_adminkit_tabs'); 
  312. /** 
  313. * enqueue's the tab js and translation js on the settings page 
  314. */ 
  315. function admin_scripts() 
  316. //Enqueue ui-tabs 
  317. wp_enqueue_script('jquery-ui-tabs'); 
  318. //Enqueue the admin tabs javascript 
  319. wp_enqueue_script('mtekk_adminkit_tabs'); 
  320. //Load the translations for the tabs 
  321. wp_localize_script('mtekk_adminkit_tabs', 'objectL10n', array( 
  322. 'mtad_uid' => 'bcn_admin',  
  323. 'mtad_import' => __('Import', 'breadcrumb-navxt'),  
  324. 'mtad_export' => __('Export', 'breadcrumb-navxt'),  
  325. 'mtad_reset' => __('Reset', 'breadcrumb-navxt'),  
  326. )); 
  327. //Enqueue the admin enable/disable groups javascript 
  328. wp_enqueue_script('mtekk_adminkit_engroups'); 
  329. /** 
  330. * A message function that checks for the BCN_SETTINGS_* define statement 
  331. */ 
  332. function multisite_settings_warn() 
  333. if(is_multisite()) 
  334. if(defined('BCN_SETTINGS_USE_LOCAL') && BCN_SETTINGS_USE_LOCAL) 
  335. $this->message['updated fade'][] = __('Warning: Individual site settings will override any settings set in this page.', 'breadcrumb-navxt'); 
  336. else if(defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK) 
  337.  
  338. else if(defined('BCN_SETTINGS_FAVOR_LOCAL') && BCN_SETTINGS_FAVOR_LOCAL) 
  339. $this->message['updated fade'][] = __('Warning: Individual site settings may override any settings set in this page.', 'breadcrumb-navxt'); 
  340. else if(defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK) 
  341. $this->message['updated fade'][] = __('Warning: Individual site settings may override any settings set in this page.', 'breadcrumb-navxt'); 
  342. //Fall through if no settings mode was set 
  343. else 
  344. $this->message['updated fade'][] = __('Warning: No BCN_SETTINGS_* define statement found, defaulting to BCN_SETTINGS_USE_LOCAL.', 'breadcrumb-navxt'); 
  345. $this->message['updated fade'][] = __('Warning: Individual site settings will override any settings set in this page.', 'breadcrumb-navxt'); 
  346. /** 
  347. * A message function that checks for deprecated settings that are set and warns the user 
  348. */ 
  349. function deprecated_settings_warn() 
  350. //We're deprecating the limit title length setting, let the user know the new method of accomplishing this 
  351. if(isset($this->opt['blimit_title']) && $this->opt['blimit_title']) 
  352. $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>'); 
  353. /** 
  354. * The administrative page for Breadcrumb NavXT 
  355. */ 
  356. function net_admin_page() 
  357. global $wp_taxonomies, $wp_post_types; 
  358. $this->security(); 
  359. //Do a check on deprecated settings 
  360. $this->deprecated_settings_warn(); 
  361. //Do a check for multisite settings mode 
  362. $this->multisite_settings_warn(); 
  363. do_action($this->unique_prefix . '_network_settings_pre_messages', $this->opt); 
  364. //Display our messages 
  365. $this->messages(); 
  366. ?> 
  367. <div class="wrap"><h2><?php echo $this->full_name; ?></h2> 
  368. <?php 
  369. //We exit after the version check if there is an action the user needs to take before saving settings 
  370. if(!$this->version_check(get_site_option($this->unique_prefix . '_version'))) 
  371. return; 
  372. ?> 
  373. <form action="<?php echo $this->admin_url(); ?>" method="post" id="bcn_admin-options"> 
  374. <?php settings_fields('bcn_options');?> 
  375. <div id="hasadmintabs"> 
  376. <fieldset id="general" class="bcn_options"> 
  377. <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> 
  378. <h3><?php _e('General', 'breadcrumb-navxt'); ?></h3> 
  379. <table class="form-table"> 
  380. <?php 
  381. $this->input_text(__('Breadcrumb Separator', 'breadcrumb-navxt'), 'hseparator', 'regular-text', false, __('Placed in between each breadcrumb.', 'breadcrumb-navxt')); 
  382. do_action($this->unique_prefix . '_network_settings_general', $this->opt); 
  383. ?> 
  384. </table> 
  385. <h3><?php _e('Current Item', 'breadcrumb-navxt'); ?></h3> 
  386. <table class="form-table"> 
  387. <?php 
  388. $this->input_check(__('Link Current Item', 'breadcrumb-navxt'), 'bcurrent_item_linked', __('Yes', 'breadcrumb-navxt')); 
  389. $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')); 
  390. $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')); 
  391. do_action($this->unique_prefix . '_network_settings_current_item', $this->opt); 
  392. ?> 
  393. </table> 
  394. <h3><?php _e('Home Breadcrumb', 'breadcrumb-navxt'); ?></h3> 
  395. <table class="form-table adminkit-engroup"> 
  396. <?php  
  397. $this->input_check(__('Home Breadcrumb', 'breadcrumb-navxt'), 'bhome_display', __('Place the home breadcrumb in the trail.', 'breadcrumb-navxt')); 
  398. $this->input_text(__('Home Template', 'breadcrumb-navxt'), 'Hhome_template', 'large-text', false, __('The template for the home breadcrumb.', 'breadcrumb-navxt')); 
  399. $this->input_text(__('Home Template (Unlinked)', 'breadcrumb-navxt'), 'Hhome_template_no_anchor', 'large-text', false, __('The template for the home breadcrumb, used when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  400. do_action($this->unique_prefix . '_network_settings_home', $this->opt); 
  401. ?> 
  402. </table> 
  403. <h3><?php _e('Blog Breadcrumb', 'breadcrumb-navxt'); ?></h3> 
  404. <table class="form-table adminkit-engroup"> 
  405. <?php 
  406. $this->input_check(__('Blog Breadcrumb', 'breadcrumb-navxt'), 'bblog_display', __('Place the blog breadcrumb in the trail.', 'breadcrumb-navxt')); 
  407. $this->input_text(__('Blog Template', 'breadcrumb-navxt'), 'Hblog_template', 'large-text', false, __('The template for the blog breadcrumb, used only in static front page environments.', 'breadcrumb-navxt')); 
  408. $this->input_text(__('Blog Template (Unlinked)', 'breadcrumb-navxt'), 'Hblog_template_no_anchor', 'large-text', false , __('The template for the blog breadcrumb, used only in static front page environments and when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  409. do_action($this->unique_prefix . '_network_settings_blog', $this->opt); 
  410. ?> 
  411. </table> 
  412. <h3><?php _e('Mainsite Breadcrumb', 'breadcrumb-navxt'); ?></h3> 
  413. <table class="form-table adminkit-engroup"> 
  414. <?php 
  415. $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()); 
  416. $this->input_text(__('Main Site Home Template', 'breadcrumb-navxt'), 'Hmainsite_template', 'large-text', false, __('The template for the main site home breadcrumb, used only in multisite environments.', 'breadcrumb-navxt')); 
  417. $this->input_text(__('Main Site Home Template (Unlinked)', 'breadcrumb-navxt'), 'Hmainsite_template_no_anchor', 'large-text', false, __('The template for the main site home breadcrumb, used only in multisite environments and when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  418. do_action($this->unique_prefix . '_network_settings_mainsite', $this->opt); 
  419. ?> 
  420. </table> 
  421. <?php do_action($this->unique_prefix . '_after_network_settings_tab_general', $this->opt); ?> 
  422. </fieldset> 
  423. <fieldset id="post" class="bcn_options"> 
  424. <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> 
  425. <h3><?php _e('Posts', 'breadcrumb-navxt'); ?></h3> 
  426. <table class="form-table adminkit-enset-top"> 
  427. <?php 
  428. $this->input_text(__('Post Template', 'breadcrumb-navxt'), 'Hpost_post_template', 'large-text', false, __('The template for post breadcrumbs.', 'breadcrumb-navxt')); 
  429. $this->input_text(__('Post Template (Unlinked)', 'breadcrumb-navxt'), 'Hpost_post_template_no_anchor', 'large-text', false, __('The template for post breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  430. $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'); 
  431. $this->input_check(__('Post Hierarchy Referer Influence', 'breadcrumb-navxt'), 'bpost_post_taxonomy_referer', __('Allow the refereing page to influence the taxonomy selected for the hierarchy.', 'breadcrumb-navxt'), false, '', 'adminkit-enset'); 
  432. ?> 
  433. <tr valign="top"> 
  434. <th scope="row"> 
  435. <?php _e('Post Hierarchy', 'breadcrumb-navxt'); ?> 
  436. </th> 
  437. <td> 
  438. <?php 
  439. $this->input_radio('Spost_post_taxonomy_type', 'category', __('Categories'), false, 'adminkit-enset'); 
  440. $this->input_radio('Spost_post_taxonomy_type', 'BCN_DATE', __('Dates', 'breadcrumb-navxt'), false, 'adminkit-enset'); 
  441. $this->input_radio('Spost_post_taxonomy_type', 'post_tag', __('Tags'), false, 'adminkit-enset'); 
  442. //We use the value 'page' but really, this will follow the parent post hierarchy 
  443. $this->input_radio('Spost_post_taxonomy_type', 'BCN_POST_PARENT', __('Post Parent', 'breadcrumb-navxt'), false, 'adminkit-enset'); 
  444. //Loop through all of the taxonomies in the array 
  445. foreach($wp_taxonomies as $taxonomy) 
  446. //Check for non-public taxonomies 
  447. if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name)) 
  448. continue; 
  449. //We only want custom taxonomies 
  450. if(($taxonomy->object_type == 'post' || is_array($taxonomy->object_type) && in_array('post', $taxonomy->object_type)) && !$taxonomy->_builtin) 
  451. $this->input_radio('Spost_post_taxonomy_type', $taxonomy->name, mb_convert_case($taxonomy->label, MB_CASE_TITLE, 'UTF-8'), false, 'adminkit-enset'); 
  452. ?> 
  453. <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> 
  454. </td> 
  455. </tr> 
  456. </table> 
  457. <h3><?php _e('Pages', 'breadcrumb-navxt'); ?></h3> 
  458. <table class="form-table"> 
  459. <?php 
  460. $this->input_text(__('Page Template', 'breadcrumb-navxt'), 'Hpost_page_template', 'large-text', false, __('The template for page breadcrumbs.', 'breadcrumb-navxt')); 
  461. $this->input_text(__('Page Template (Unlinked)', 'breadcrumb-navxt'), 'Hpost_page_template_no_anchor', 'large-text', false, __('The template for page breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  462. ?> 
  463. </table> 
  464. <h3><?php _e('Attachments', 'breadcrumb-navxt'); ?></h3> 
  465. <table class="form-table"> 
  466. <?php 
  467. $this->input_text(__('Attachment Template', 'breadcrumb-navxt'), 'Hpost_attachment_template', 'large-text', false, __('The template for attachment breadcrumbs.', 'breadcrumb-navxt')); 
  468. $this->input_text(__('Attachment Template (Unlinked)', 'breadcrumb-navxt'), 'Hpost_attachment_template_no_anchor', 'large-text', false, __('The template for attachment breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  469. ?> 
  470. </table> 
  471. <?php 
  472. //Loop through all of the post types in the array 
  473. foreach($wp_post_types as $post_type) 
  474. //Check for non-public CPTs 
  475. if(!apply_filters('bcn_show_cpt_private', $post_type->public, $post_type->name)) 
  476. continue; 
  477. //We only want custom post types 
  478. if(!$post_type->_builtin) 
  479. $singular_name_lc = mb_strtolower($post_type->labels->singular_name, 'UTF-8'); 
  480. ?> 
  481. <h3><?php echo $post_type->labels->singular_name; ?></h3> 
  482. <table class="form-table adminkit-enset-top"> 
  483. <?php 
  484. $this->input_text(sprintf(__('%s Template', 'breadcrumb-navxt'), $post_type->labels->singular_name), 'Hpost_' . $post_type->name . '_template', 'large-text', false, sprintf(__('The template for %s breadcrumbs.', 'breadcrumb-navxt'), $singular_name_lc)); 
  485. $this->input_text(sprintf(__('%s Template (Unlinked)', 'breadcrumb-navxt'), $post_type->labels->singular_name), 'Hpost_' . $post_type->name . '_template_no_anchor', 'large-text', false, sprintf(__('The template for %s breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt'), $singular_name_lc)); 
  486. $optid = $this->get_valid_id('apost_' . $post_type->name . '_root'); 
  487. ?> 
  488. <tr valign="top"> 
  489. <th scope="row"> 
  490. <label for="<?php echo $optid;?>"><?php printf(__('%s Root Page', 'breadcrumb-navxt'), $post_type->labels->singular_name);?></label> 
  491. </th> 
  492. <td> 
  493. <?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']));?> 
  494. </td> 
  495. </tr> 
  496. <?php 
  497. $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); 
  498. $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'); 
  499. $this->input_check(sprintf(__('%s Hierarchy Referer Influence', 'breadcrumb-navxt'), $post_type->labels->singular_name), 'bpost_' . $post_type->name . '_taxonomy_referer', __('Allow the refereing page to influence the taxonomy selected for the hierarchy.', 'breadcrumb-navxt'), false, '', 'adminkit-enset'); 
  500. ?> 
  501. <tr valign="top"> 
  502. <th scope="row"> 
  503. <?php printf(__('%s Hierarchy', 'breadcrumb-navxt'), $post_type->labels->singular_name); ?> 
  504. </th> 
  505. <td> 
  506. <?php 
  507. //We use the value 'page' but really, this will follow the parent post hierarchy 
  508. $this->input_radio('Spost_' . $post_type->name . '_taxonomy_type', 'BCN_POST_PARENT', __('Post Parent', 'breadcrumb-navxt'), false, 'adminkit-enset'); 
  509. $this->input_radio('Spost_' . $post_type->name . '_taxonomy_type', 'BCN_DATE', __('Dates', 'breadcrumb-navxt'), false, 'adminkit-enset'); 
  510. //Loop through all of the taxonomies in the array 
  511. foreach($wp_taxonomies as $taxonomy) 
  512. //Check for non-public taxonomies 
  513. if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name)) 
  514. continue; 
  515. //We only want custom taxonomies 
  516. if($taxonomy->object_type == $post_type->name || in_array($post_type->name, $taxonomy->object_type)) 
  517. $this->input_radio('Spost_' . $post_type->name . '_taxonomy_type', $taxonomy->name, $taxonomy->labels->singular_name, false, 'adminkit-enset'); 
  518. ?> 
  519. <p class="description"> 
  520. <?php 
  521. if($post_type->hierarchical) 
  522. _e('The hierarchy which the breadcrumb trail will show.', 'breadcrumb-navxt');  
  523. else 
  524. _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'); 
  525. ?> 
  526. </p> 
  527. </td> 
  528. </tr> 
  529. </table> 
  530. <?php 
  531. do_action($this->unique_prefix . '_after_network_settings_tab_post', $this->opt); 
  532. ?> 
  533. </fieldset> 
  534. <fieldset id="tax" class="bcn_options alttab"> 
  535. <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> 
  536. <h3><?php _e('Categories', 'breadcrumb-navxt'); ?></h3> 
  537. <table class="form-table"> 
  538. <?php 
  539. $this->input_text(__('Category Template', 'breadcrumb-navxt'), 'Htax_category_template', 'large-text', false, __('The template for category breadcrumbs.', 'breadcrumb-navxt')); 
  540. $this->input_text(__('Category Template (Unlinked)', 'breadcrumb-navxt'), 'Htax_category_template_no_anchor', 'large-text', false, __('The template for category breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  541. ?> 
  542. </table> 
  543. <h3><?php _e('Tags', 'breadcrumb-navxt'); ?></h3> 
  544. <table class="form-table"> 
  545. <?php 
  546. $this->input_text(__('Tag Template', 'breadcrumb-navxt'), 'Htax_post_tag_template', 'large-text', false, __('The template for tag breadcrumbs.', 'breadcrumb-navxt')); 
  547. $this->input_text(__('Tag Template (Unlinked)', 'breadcrumb-navxt'), 'Htax_post_tag_template_no_anchor', 'large-text', false, __('The template for tag breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  548. ?> 
  549. </table> 
  550. <h3><?php _e('Post Formats', 'breadcrumb-navxt'); ?></h3> 
  551. <table class="form-table"> 
  552. <?php 
  553. $this->input_text(__('Post Format Template', 'breadcrumb-navxt'), 'Htax_post_format_template', 'large-text', false, __('The template for post format breadcrumbs.', 'breadcrumb-navxt')); 
  554. $this->input_text(__('Post Format Template (Unlinked)', 'breadcrumb-navxt'), 'Htax_post_format_template_no_anchor', 'large-text', false, __('The template for post_format breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  555. ?> 
  556. </table> 
  557. <?php 
  558. //Loop through all of the taxonomies in the array 
  559. foreach($wp_taxonomies as $taxonomy) 
  560. //Check for non-public taxonomies 
  561. if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name)) 
  562. continue; 
  563. //We only want custom taxonomies 
  564. if(!$taxonomy->_builtin) 
  565. $label_lc = mb_strtolower($taxonomy->label, 'UTF-8'); 
  566. ?> 
  567. <h3><?php echo mb_convert_case($taxonomy->label, MB_CASE_TITLE, 'UTF-8'); ?></h3> 
  568. <table class="form-table"> 
  569. <?php 
  570. $this->input_text(sprintf(__('%s Template', 'breadcrumb-navxt'), $taxonomy->labels->singular_name), 'Htax_' . $taxonomy->name . '_template', 'large-text', false, sprintf(__('The template for %s breadcrumbs.', 'breadcrumb-navxt'), $label_lc)); 
  571. $this->input_text(sprintf(__('%s Template (Unlinked)', 'breadcrumb-navxt'), $taxonomy->labels->singular_name), 'Htax_' . $taxonomy->name . '_template_no_anchor', 'large-text', false, sprintf(__('The template for %s breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt'), $label_lc)); 
  572. ?> 
  573. </table> 
  574. <?php 
  575. do_action($this->unique_prefix . '_after_network_settings_tab_taxonomy', $this->opt); ?> 
  576. </fieldset> 
  577. <fieldset id="miscellaneous" class="bcn_options"> 
  578. <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> 
  579. <h3><?php _e('Author Archives', 'breadcrumb-navxt'); ?></h3> 
  580. <table class="form-table"> 
  581. <?php 
  582. $this->input_text(__('Author Template', 'breadcrumb-navxt'), 'Hauthor_template', 'large-text', false, __('The template for author breadcrumbs.', 'breadcrumb-navxt')); 
  583. $this->input_text(__('Author Template (Unlinked)', 'breadcrumb-navxt'), 'Hauthor_template_no_anchor', 'large-text', false, __('The template for author breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  584. $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')); 
  585. ?> 
  586. </table> 
  587. <h3><?php _e('Miscellaneous', 'breadcrumb-navxt'); ?></h3> 
  588. <table class="form-table"> 
  589. <?php 
  590. $this->input_text(__('Date Template', 'breadcrumb-navxt'), 'Hdate_template', 'large-text', false, __('The template for date breadcrumbs.', 'breadcrumb-navxt')); 
  591. $this->input_text(__('Date Template (Unlinked)', 'breadcrumb-navxt'), 'Hdate_template_no_anchor', 'large-text', false, __('The template for date breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  592. $this->input_text(__('Search Template', 'breadcrumb-navxt'), 'Hsearch_template', 'large-text', false, __('The anchor template for search breadcrumbs, used only when the search results span several pages.', 'breadcrumb-navxt')); 
  593. $this->input_text(__('Search Template (Unlinked)', 'breadcrumb-navxt'), 'Hsearch_template_no_anchor', 'large-text', false, __('The anchor template for search breadcrumbs, used only when the search results span several pages and the breadcrumb is not linked.', 'breadcrumb-navxt')); 
  594. $this->input_text(__('404 Title', 'breadcrumb-navxt'), 'S404_title', 'regular-text'); 
  595. $this->input_text(__('404 Template', 'breadcrumb-navxt'), 'H404_template', 'large-text', false, __('The template for 404 breadcrumbs.', 'breadcrumb-navxt')); 
  596. ?> 
  597. </table> 
  598. <h3><?php _e('Deprecated', 'breadcrumb-navxt'); ?></h3> 
  599. <table class="form-table"> 
  600. <tr valign="top"> 
  601. <th scope="row"> 
  602. <?php _e('Title Length', 'breadcrumb-navxt'); ?>  
  603. </th> 
  604. <td> 
  605. <label> 
  606. <input name="bcn_options[blimit_title]" type="checkbox" id="blimit_title" value="true" <?php checked(true, $this->opt['blimit_title']); ?> /> 
  607. <?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>');?> 
  608. </label><br /> 
  609. <ul> 
  610. <li> 
  611. <label for="amax_title_length"> 
  612. <?php _e('Max Title Length: ', 'breadcrumb-navxt');?> 
  613. <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" /> 
  614. </label> 
  615. </li> 
  616. </ul> 
  617. </td> 
  618. </tr> 
  619. </table> 
  620. <?php do_action($this->unique_prefix . '_after_network_settings_tab_miscellaneous', $this->opt); ?> 
  621. </fieldset> 
  622. <?php do_action($this->unique_prefix . '_after_network_settings_tabs', $this->opt); ?> 
  623. </div> 
  624. <p class="submit"><input type="submit" class="button-primary" name="bcn_admin_options" value="<?php esc_attr_e('Save Changes') ?>" /></p> 
  625. </form> 
  626. </div> 
  627. <?php 
.