' . __('Your PHP version is too old, please upgrade to a newer version. Your version is %1$s, Breadcrumb NavXT requires %2$s', 'breadcrumb-navxt') . '

', phpversion(), '5.6.0'); } //If we are in the admin, let's print a warning then return if(is_admin()) { add_action('admin_notices', 'bcn_phpold'); } return; } //Include admin base class if(!class_exists('\mtekk\adminKit\adminKit')) { require_once(dirname(__FILE__) . '/includes/adminKit/class-mtekk_adminkit.php'); } use mtekk\adminKit\{adminKit, form, message, setting}; /** * The administrative interface class * */ class bcn_admin extends adminKit { const version = '7.1.0'; protected $full_name = 'Breadcrumb NavXT Settings'; protected $short_name = 'Breadcrumb NavXT'; protected $access_level = 'bcn_manage_options'; protected $identifier = 'breadcrumb-navxt'; protected $unique_prefix = 'bcn'; protected $plugin_basename = null; protected $support_url = 'https://wordpress.org/support/plugin/breadcrumb-navxt/'; /** * Administrative interface class default constructor * * @param array $opts The breadcrumb trail object's settings array * @param string $basename The basename of the plugin * @param array $settings The array of settings objects */ function __construct(array &$opts, $basename, array &$settings) { $this->plugin_basename = $basename; $this->full_name = esc_html__('Breadcrumb NavXT Settings', 'breadcrumb-navxt'); $this->settings =& $settings; $this->opt =& $opts; //We're going to make sure we load the parent's constructor parent::__construct(); } /** * Loads opts array values into the local settings array * * @param array $opts The opts array */ function setting_merge($opts) { $unknown = array(); foreach($opts as $key => $value) { if(isset($this->settings[$key]) && $this->settings[$key] instanceof setting\setting) { $this->settings[$key]->set_value($this->settings[$key]->validate($value)); } else if(isset($this->settings[$key]) && is_array($this->settings[$key]) && is_array($value)) { foreach($value as $subkey => $subvalue) { if(isset($this->settings[$key][$subkey]) && $this->settings[$key][$subkey]instanceof setting\setting) { $this->settings[$key][$subkey]->set_value($this->settings[$key][$subkey]->validate($subvalue)); } } } else { $unknown[] = $key; } } //Add a message if we found some unknown settings while merging if(count($unknown) > 0) { $this->messages[] = new message( sprintf(__('Found %u unknown legacy settings: %s','breadcrumb-navxt'), count($unknown), implode(', ', $unknown)), 'warning', true, 'bcn_unkonwn_legacy_settings'); } } /** * admin initialization callback function * * is bound to wordpress action 'admin_init' on instantiation * * @since 3.2.0 * @return void */ function init() { //We're going to make sure we run the parent's version of this function as well parent::init(); $this->setting_merge($this->opt); } /** * Upgrades input options array, sets to $this->opt * * @param array $opts * @param string $version the version of the passed in options */ function opts_upgrade($opts, $version) { //If our version is not the same as in the db, time to update if(version_compare($version, $this::version, '<')) { require_once(dirname(__FILE__) . '/options_upgrade.php'); bcn_options_upgrade_handler($opts, $version, $this->opt); } //Merge in the defaults $this->opt = adminKit::parse_args($opts, adminKit::settings_to_opts($this->settings)); } /** * help action hook function * * @return string * */ function help() { $screen = get_current_screen(); //Exit early if the add_help_tab function doesn't exist if(!method_exists($screen, 'add_help_tab')) { return; } //Add contextual help on current screen if($screen->id == 'settings_page_' . $this->identifier) { $general_tab = '

' . esc_html__('Tips for the settings are located below select options.', 'breadcrumb-navxt') . '

' . esc_html__('Resources', 'breadcrumb-navxt') . '
' . '
' . esc_html__('Giving Back', 'breadcrumb-navxt') . '
'; $screen->add_help_tab( array( 'id' => $this->identifier . '-base', 'title' => __('General', 'breadcrumb-navxt'), 'content' => $general_tab )); $quickstart_tab = '

' . 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.', 'breadcrumb-navxt') . '

' . esc_html__('Breadcrumb trail with separators', 'breadcrumb-navxt') . '
<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">' . "
	<?php if(function_exists('bcn_display'))
	{
		bcn_display();
	}?>
</div>
" . '
' . esc_html__('Breadcrumb trail in list form', 'breadcrumb-navxt').'
<ol class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">'."
	<?php if(function_exists('bcn_display_list'))
	{
		bcn_display_list();
	}?>
</ol>
"; $screen->add_help_tab( array( 'id' => $this->identifier . '-quick-start', 'title' => __('Quick Start', 'breadcrumb-navxt'), 'content' => $quickstart_tab )); $styling_tab = '

' . esc_html__('Using the code from the Quick Start section above, the following CSS can be used as base for styling your breadcrumb trail.', 'breadcrumb-navxt') . '

' . '
.breadcrumbs
{
	font-size: 1.1em;
	color: #fff;
	margin: 30px 0 0 10px;
	position: relative;
	float: left;
}
'; $screen->add_help_tab( array( 'id' => $this->identifier . '-styling', 'title' => __('Styling', 'breadcrumb-navxt'), 'content' => $styling_tab )); $screen->add_help_tab( array( 'id' => $this->identifier . '-import-export-reset', 'title' => __('Import/Export/Reset', 'breadcrumb-navxt'), 'content' => $this->import_form() )); } } /** * enqueue's the tab style sheet on the settings page */ function admin_styles() { wp_enqueue_style('mtekk_adminkit_tabs'); } /** * enqueue's the tab js and translation js on the settings page */ function admin_scripts() { //Enqueue ui-tabs wp_enqueue_script('jquery-ui-tabs'); //Enqueue the admin tabs javascript wp_enqueue_script('mtekk_adminkit_tabs'); //Load the translations for the tabs wp_localize_script('mtekk_adminkit_tabs', 'objectL10n', array( 'mtad_uid' => 'bcn_admin', 'mtad_import' => __('Import', 'breadcrumb-navxt'), 'mtad_export' => __('Export', 'breadcrumb-navxt'), 'mtad_reset' => __('Reset', 'breadcrumb-navxt'), )); //Enqueue the admin enable/disable groups javascript wp_enqueue_script('mtekk_adminkit_engroups'); } /** * A message function that checks for the BCN_SETTINGS_* define statement */ function multisite_settings_warn() { if(is_multisite()) { if(defined('BCN_SETTINGS_USE_LOCAL') && BCN_SETTINGS_USE_LOCAL) { } else if(defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK) { $this->messages[] = new message(esc_html__('Warning: Your network settings will override any settings set in this page.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_is_nsiteoveride'); } else if(defined('BCN_SETTINGS_FAVOR_LOCAL') && BCN_SETTINGS_FAVOR_LOCAL) { $this->messages[] = new message(esc_html__('Warning: Your network settings may override any settings set in this page.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_is_isitemayoveride'); } else if(defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK) { $this->messages[] = new message(esc_html__('Warning: Your network settings may override any settings set in this page.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_is_nsitemayoveride'); } //Fall through if no settings mode was set else { $this->messages[] = new message(esc_html__('Warning: No BCN_SETTINGS_* define statement found, defaulting to BCN_SETTINGS_USE_LOCAL.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_is_nosetting'); } } } /** * A message function that checks for deprecated settings that are set and warns the user */ function deprecated_settings_warn() { //We're deprecating the limit title length setting, let the user know the new method of accomplishing this if(isset($this->settings['blimit_title']) && $this->settings['blimit_title']->get_value()) { $this->messages[] = new message( sprintf( esc_html__('Error: The deprecated setting "Title Length" (see Miscellaneous > Deprecated) has no effect in this version Breadcrumb NavXT. Please %1$suse CSS instead%2$s.', 'breadcrumb-navxt'), '', ''), 'error'); } foreach($this->settings as $key => $setting) { if($key[0] == "H" && substr_count($key, '_template') >= 1) { $deprecated_tags = array(); $replacement_tags = array(); //Deprecated ftitle check if(substr_count($setting->get_value(), '%ftitle%') >= 1) { $deprecated_tags[] = '%ftitle%'; $replacement_tags[] = '%title%'; } //Deprecated fhtitle check if(substr_count($setting->get_value(), '%fhtitle%') >= 1) { $deprecated_tags[] = '%fhtitle%'; $replacement_tags[] = '%htitle%'; } if(count($deprecated_tags) > 0) { $setting_link = sprintf('%2$s', $key, $setting->get_title()); $this->messages[] = new message( sprintf( esc_html__('Error: The deprecated template tag %1$s found in setting %3$s. Please use %2$s instead.', 'breadcrumb-navxt'), implode(' and ', $deprecated_tags), implode(' and ', $replacement_tags), $setting_link), 'error'); } } } } /** * A message function that checks for post types added after the settings defaults were established */ function unknown_custom_types_warn() { foreach($GLOBALS['wp_post_types'] as $post_type) { //If we haven't seen this post type before, warn the user if(!isset($this->settings['Hpost_' . $post_type->name . '_template'])) { $this->messages[] = new message( sprintf( esc_html__('Warning: The post type %1$s (%2$s) was registered after the Breadcrumb NavXT default settings. It will not show up in the settings.', 'breadcrumb-navxt'), $post_type->labels->singular_name, $post_type->name), 'warning', true, $post_type->name); } } foreach($GLOBALS['wp_taxonomies'] as $taxonomy) { if(!isset($this->settings['Htax_' . $taxonomy->name . '_template'])) { //If we haven't seen this taxonomy before, warn the user $this->messages[] = new message( sprintf( esc_html__('Warning: The taxonomy %1$s (%2$s) was registered after the Breadcrumb NavXT default settings. It will not show up in the settings.', 'breadcrumb-navxt'), $taxonomy->label, $taxonomy->name), 'warning', true, $taxonomy->name); } } } /** * Function checks the current site to see if the blog options should be disabled * * @return boool Whether or not the blog options should be disabled */ function maybe_disable_blog_options() { return (get_option('show_on_front') !== 'page' || get_option('page_for_posts') < 1); } /** * Function checks the current site to see if the mainsite options should be disabled * * @return bool Whether or not the mainsite options should be disabled */ function maybe_disable_mainsite_options() { return !is_multisite(); } /** * The administrative page for Breadcrumb NavXT */ function admin_page() { global $wp_taxonomies, $wp_post_types; $this->security(); //Do a check on deprecated settings $this->deprecated_settings_warn(); //Do a check for unknown CPTs and Taxnomies $this->unknown_custom_types_warn(); //Do a check for multisite settings mode $this->multisite_settings_warn(); do_action($this->unique_prefix . '_settings_pre_messages', $this->settings); //Display our messages $this->messages(); ?>

full_name; ?>

version_check($this->get_option($this->unique_prefix . '_version'))) { return; } ?>

form->textbox($this->settings['hseparator'], '2', false, __('Placed in between each breadcrumb.', 'breadcrumb-navxt')); do_action($this->unique_prefix . '_settings_general', $this->settings); ?>

form->input_check($this->settings['bcurrent_item_linked'], __('Yes', 'breadcrumb-navxt')); $this->form->input_check($this->settings['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'), 'adminkit-enset-ctrl adminkit-enset'); $this->form->textbox($this->settings['Hpaged_template'], '4', false, __('The template for paged breadcrumbs.', 'breadcrumb-navxt'), 'adminkit-enset'); do_action($this->unique_prefix . '_settings_current_item', $this->settings); ?>

form->input_check($this->settings['bhome_display'], __('Place the home breadcrumb in the trail.', 'breadcrumb-navxt'), false, '', 'adminkit-enset-ctrl adminkit-enset'); $this->form->textbox($this->settings['Hhome_template'], '6', false, __('The template for the home breadcrumb.', 'breadcrumb-navxt'), 'adminkit-enset'); $this->form->textbox($this->settings['Hhome_template_no_anchor'], '4', false, __('The template for the home breadcrumb, used when the breadcrumb is not linked.', 'breadcrumb-navxt'), 'adminkit-enset'); do_action($this->unique_prefix . '_settings_home', $this->settings); ?>

form->input_check($this->settings['bblog_display'], __('Place the blog breadcrumb in the trail.', 'breadcrumb-navxt'), $this->maybe_disable_blog_options(), '', 'adminkit-enset-ctrl adminkit-enset'); do_action($this->unique_prefix . '_settings_blog', $this->settings); ?>

form->input_check($this->settings['bmainsite_display'], __('Place the main site home breadcrumb in the trail in an multisite setup.', 'breadcrumb-navxt'), $this->maybe_disable_mainsite_options(), '', 'adminkit-enset-ctrl adminkit-enset'); $this->form->textbox($this->settings['Hmainsite_template'], '6', $this->maybe_disable_mainsite_options(), __('The template for the main site home breadcrumb, used only in multisite environments.', 'breadcrumb-navxt'), 'adminkit-enset'); $this->form->textbox($this->settings['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.', 'breadcrumb-navxt'), 'adminkit-enset'); do_action($this->unique_prefix . '_settings_mainsite', $this->settings); ?>
unique_prefix . '_after_settings_tab_general', $this->settings); ?>
public, $post_type->name) || !isset($this->settings['Hpost_' . $post_type->name . '_template'])) { continue; } $singular_name_lc = mb_strtolower($post_type->labels->singular_name, 'UTF-8'); ?>

labels->singular_name; ?>

form->textbox($this->settings['Hpost_' . $post_type->name . '_template'], '6', false, sprintf(__('The template for %s breadcrumbs.', 'breadcrumb-navxt'), $singular_name_lc)); $this->form->textbox($this->settings['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)); if(!in_array($post_type->name, array('page', 'post'))) { $optid = form::get_valid_id('apost_' . $post_type->name . '_root'); ?> form->input_check($this->settings['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); } if(in_array($post_type->name, array('page'))) { $this->form->input_hidden($this->settings['bpost_' . $post_type->name . '_hierarchy_display']); $this->form->input_hidden($this->settings['bpost_' . $post_type->name . '_hierarchy_parent_first']); $this->form->input_hidden($this->settings['bpost_' . $post_type->name . '_taxonomy_referer']); } else { $this->form->input_check($this->settings['bpost_' . $post_type->name . '_hierarchy_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'); $this->form->input_check($this->settings['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.', 'breadcrumb-navxt'), $singular_name_lc), false, '', 'adminkit-enset'); $this->form->input_check($this->settings['bpost_' . $post_type->name . '_taxonomy_referer'], __('Allow the referring page to influence the taxonomy selected for the hierarchy.', 'breadcrumb-navxt'), false, '', 'adminkit-enset'); ?>
$this->unique_prefix . '_options[apost_' . $post_type->name . '_root]', 'id' => $optid, 'echo' => 1, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => $this->settings['apost_' . $post_type->name . '_root']->get_value()));?>
labels->singular_name); ?> form->input_radio($this->settings['Epost_' . $post_type->name . '_hierarchy_type'], 'BCN_POST_PARENT', __('Post Parent', 'breadcrumb-navxt'), false, 'adminkit-enset'); $this->form->input_radio($this->settings['Epost_' . $post_type->name . '_hierarchy_type'], 'BCN_DATE', __('Dates', 'breadcrumb-navxt'), false, 'adminkit-enset'); //Loop through all of the taxonomies in the array foreach($wp_taxonomies as $taxonomy) { //Check for non-public taxonomies if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name, $post_type->name)) { continue; } //We only want custom taxonomies if($taxonomy->object_type == $post_type->name || in_array($post_type->name, $taxonomy->object_type)) { $this->form->input_radio($this->settings['Epost_' . $post_type->name . '_hierarchy_type'], $taxonomy->name, $taxonomy->labels->singular_name, false, 'adminkit-enset'); } } ?>

hierarchical) { esc_html_e('The hierarchy which the breadcrumb trail will show.', 'breadcrumb-navxt'); } else { 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.', 'breadcrumb-navxt'); } ?>

unique_prefix . '_after_settings_tab_post', $this->settings); //FIXME: Why don't we use the taxonomy loop for all taxonomies? We do it with posts now ?>

form->textbox($this->settings['Htax_category_template'], '6', false, __('The template for category breadcrumbs.', 'breadcrumb-navxt')); $this->form->textbox($this->settings['Htax_category_template_no_anchor'], '4', false, __('The template for category breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); ?>

form->textbox($this->settings['Htax_post_tag_template'], '6', false, __('The template for tag breadcrumbs.', 'breadcrumb-navxt')); $this->form->textbox($this->settings['Htax_post_tag_template_no_anchor'], '4', false, __('The template for tag breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); ?>

form->textbox($this->settings['Htax_post_format_template'], '6', false, __('The template for post format breadcrumbs.', 'breadcrumb-navxt')); $this->form->textbox($this->settings['Htax_post_format_template_no_anchor'], '4', false, __('The template for post_format breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); ?>
public, $taxonomy->name, null) || !isset($this->settings['Htax_' . $taxonomy->name . '_template'])) { continue; } //We only want custom taxonomies if(!$taxonomy->_builtin) { $label_lc = mb_strtolower($taxonomy->label, 'UTF-8'); ?>

label, MB_CASE_TITLE, 'UTF-8'); ?>

form->textbox($this->settings['Htax_' . $taxonomy->name . '_template'], '6', false, sprintf(__('The template for %s breadcrumbs.', 'breadcrumb-navxt'), $label_lc)); $this->form->textbox($this->settings['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)); ?>
unique_prefix . '_after_settings_tab_taxonomy', $this->settings); ?>

form->textbox($this->settings['Hauthor_template'], '6', false, __('The template for author breadcrumbs.', 'breadcrumb-navxt')); $this->form->textbox($this->settings['Hauthor_template_no_anchor'], '4', false, __('The template for author breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); $this->form->input_select($this->settings['Eauthor_name'], $this->settings['Eauthor_name']->get_allowed_vals(), 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')); $optid = form::get_valid_id('aauthor_root'); ?>
$this->unique_prefix . '_options[aauthor_root]', 'id' => $optid, 'echo' => 1, 'show_option_none' => __( '— Select —' ), 'option_none_value' => '0', 'selected' => $this->settings['aauthor_root']->get_value()));?>

form->textbox($this->settings['Hdate_template'], '6', false, __('The template for date breadcrumbs.', 'breadcrumb-navxt')); $this->form->textbox($this->settings['Hdate_template_no_anchor'], '4', false, __('The template for date breadcrumbs, used only when the breadcrumb is not linked.', 'breadcrumb-navxt')); $this->form->textbox($this->settings['Hsearch_template'], '6', false, __('The anchor template for search breadcrumbs, used only when the search results span several pages.', 'breadcrumb-navxt')); $this->form->textbox($this->settings['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')); $this->form->input_text($this->settings['S404_title'], 'regular-text'); $this->form->textbox($this->settings['H404_template'], '4', false, __('The template for 404 breadcrumbs.', 'breadcrumb-navxt')); ?>


unique_prefix . '_after_settings_tab_miscellaneous', $this->settings); ?>
unique_prefix . '_after_settings_tabs', $this->settings); ?>