PK ! cVl l class.bcn_admin.phpnu [
' . __('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.3.1'; 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(); } function is_network_admin() { return false; } /** * 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)); } /** * Fills in the help tab contents * * @param WP_Screen $screen The screen to add the help tab items to */ function help_contents(\WP_Screen &$screen) { $general_tab = '' . esc_html__('Tips for the settings are located below select options.', 'breadcrumb-navxt') . '
' . 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') . '
<div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">' . "
<?php if(function_exists('bcn_display'))
{
bcn_display();
}?>
</div>
" .
'<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(!($post_type instanceof WP_Post_Type))
{
$this->messages[] = new message(
sprintf(
esc_html__('Error: WP_Post_Types global contains non WP_Post_Type object. Debug information: %1$s', 'breadcrumb-navxt'),
var_export($post_type, true)),
'error',
true,
'badtypeWP_Post_Types');
continue;
}
//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(!($taxonomy instanceof WP_Taxonomy))
{
//If we haven't seen this taxonomy before, warn the user
$this->messages[] = new message(
sprintf(
esc_html__('Error: WP_Taxonomies global contains non WP_Taxonomy object. Debug information: %1$s', 'breadcrumb-navxt'),
var_export($taxonomy, true)),
'error',
true,
'badtypeWP_Taxonomies');
continue;
}
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();
//Grab the network options, if multisite
$network_opts = array();
$local_opts = array();
$overriden = array();
$overriden_style = array();
if(is_multisite() && !$this->is_network_admin())
{
$network_opts = get_site_option('bcn_options');
$local_opts = get_option('bcn_options');
}
foreach($this->settings as $key => $setting)
{
if(isset($network_opts[$key]) && ((defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK) || (defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK)))
{
$overriden[$key] = ' ' . __('Value has been set via network wide setting.', 'breadcrumb-navxt');
$overriden_style[$key] = ' disabled';
}
else
{
$overriden[$key] = '';
$overriden_style[$key] = '';
}
}
?>