' . esc_html__('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;
}
require_once(dirname(__FILE__) . '/includes/multibyte_supplicant.php');
//Include admin base class
if(!class_exists('\mtekk\adminKit\adminKit'))
{
require_once(dirname(__FILE__) . '/includes/adminKit/class-mtekk_adminkit.php');
}
//Include the breadcrumb class
require_once(dirname(__FILE__) . '/class.bcn_breadcrumb.php');
//Include the breadcrumb trail class
require_once(dirname(__FILE__) . '/class.bcn_breadcrumb_trail.php');
if(class_exists('WP_Widget'))
{
//Include the WP 2.8+ widget class
require_once(dirname(__FILE__) . '/class.bcn_widget.php');
}
use mtekk\adminKit\adminKit as adminKit;
use mtekk\adminKit\setting;
$breadcrumb_navxt = null;
//TODO change to extends \mtekk\plugKit
class breadcrumb_navxt
{
const version = '7.4.1';
protected $name = 'Breadcrumb NavXT';
protected $identifier = 'breadcrumb-navxt';
protected $unique_prefix = 'bcn';
protected $plugin_basename = null;
protected $opt = null;
protected $settings = array();
protected $breadcrumb_trail = null;
protected $admin = null;
protected $rest_controller = null;
/**
* Constructor for a new breadcrumb_navxt object
*
*/
public function __construct()
{
//We set the plugin basename here
$this->plugin_basename = plugin_basename(__FILE__);
add_action('rest_api_init', array($this, 'rest_api_init'), 10);
//Run much later than everyone else to give other plugins a chance to hook into the filters and actions in this
add_action('init', array($this, 'init'), 9000);
//Register the WordPress 2.8 Widget
add_action('widgets_init', array($this, 'register_widget'));
}
public function init()
{
//Create an instance of bcn_breadcrumb_trail
$bcn_breadcrumb_trail = new bcn_breadcrumb_trail();
//Allow others to swap out the breadcrumb trail object
$this->breadcrumb_trail = apply_filters('bcn_breadcrumb_trail_object', $bcn_breadcrumb_trail);
add_filter('bcn_allowed_html', array($this, 'allowed_html'), 1, 1);
add_filter('mtekk_adminkit_allowed_html', array($this, 'adminkit_allowed_html'), 1, 1);
//We want to run late for using our breadcrumbs
add_filter('tha_breadcrumb_navigation', array($this, 'tha_compat'), 99);
//Only include the REST API if enabled
if(!defined('BCN_DISABLE_REST_API') || !BCN_DISABLE_REST_API)
{
require_once(dirname(__FILE__) . '/class.bcn_rest_controller.php');
$this->rest_controller = new bcn_rest_controller($this->breadcrumb_trail, $this->unique_prefix);
}
breadcrumb_navxt::setup_setting_defaults($this->settings);
if(!is_admin() || (!isset($_POST[$this->unique_prefix . '_admin_reset']) && !isset($_POST[$this->unique_prefix . '_admin_options'])))
{
$this->get_settings(); //This breaks the reset options script, so only do it if we're not trying to reset the settings
}
//Register Guternberg Block
$this->register_block();
//Load our network admin if in the network dashboard (yes is_network_admin() doesn't exist)
if(defined('WP_NETWORK_ADMIN') && WP_NETWORK_ADMIN)
{
require_once(dirname(__FILE__) . '/class.bcn_network_admin.php');
//Instantiate our new admin object
$this->admin = new bcn_network_admin($this->breadcrumb_trail->opt, $this->plugin_basename, $this->settings);
}
//Load our main admin if in the dashboard, but only if we're not in the network dashboard (prevents goofy bugs)
else if(is_admin() || defined('WP_UNINSTALL_PLUGIN'))
{
require_once(dirname(__FILE__) . '/class.bcn_admin.php');
//Instantiate our new admin object
$this->admin = new bcn_admin($this->breadcrumb_trail->opt, $this->plugin_basename, $this->settings);
}
}
public function rest_api_init()
{
add_filter('bcn_register_rest_endpoint', array($this, 'api_enable_for_block'), 10, 4);
}
public function register_widget()
{
return register_widget($this->unique_prefix . '_widget');
}
/**
* Handles registering the Breadcrumb Trail Gutenberg block
*/
public function register_block()
{
if(function_exists('register_block_type'))
{
register_block_type( dirname(__FILE__) . '/includes/blocks/build/breadcrumb-trail');
}
}
public function api_enable_for_block($register_rest_endpoint, $endpoint, $version, $methods)
{
//Enable if the current user can edit posts
if(current_user_can('edit_posts') && $endpoint === 'post')
{
return true;
}
return $register_rest_endpoint;
}
public function adminkit_allowed_html($tags)
{
//Hoop through normal allowed_html filters
return apply_filters('bcn_allowed_html', $tags);
}
public function allowed_html($tags)
{
$allowed_html = array(
'a' => array(
'href' => true,
'title' => true,
'class' => true,
'id' => true,
'media' => true,
'dir' => true,
'relList' => true,
'rel' => true,
'aria-hidden' => true,
'data-icon' => true,
'itemref' => true,
'itemid' => true,
'itemprop' => true,
'itemscope' => true,
'itemtype' => true,
'xmlns:v' => true,
'typeof' => true,
'property' => true,
'vocab' => true,
'translate' => true,
'lang' => true,
'bcn-aria-current' => true
),
'img' => array(
'alt' => true,
'align' => true,
'height' => true,
'width' => true,
'src' => true,
'srcset' => true,
'sizes' => true,
'id' => true,
'class' => true,
'aria-hidden' => true,
'data-icon' => true,
'itemref' => true,
'itemid' => true,
'itemprop' => true,
'itemscope' => true,
'itemtype' => true,
'xmlns:v' => true,
'typeof' => true,
'property' => true,
'vocab' => true,
'lang' => true
),
'span' => array(
'title' => true,
'class' => true,
'id' => true,
'dir' => true,
'align' => true,
'lang' => true,
'xml:lang' => true,
'aria-hidden' => true,
'data-icon' => true,
'itemref' => true,
'itemid' => true,
'itemprop' => true,
'itemscope' => true,
'itemtype' => true,
'xmlns:v' => true,
'typeof' => true,
'property' => true,
'vocab' => true,
'translate' => true,
'lang' => true
),
'h1' => array(
'title' => true,
'class' => true,
'id' => true,
'dir' => true,
'align' => true,
'lang' => true,
'xml:lang' => true,
'aria-hidden' => true,
'data-icon' => true,
'itemref' => true,
'itemid' => true,
'itemprop' => true,
'itemscope' => true,
'itemtype' => true,
'xmlns:v' => true,
'typeof' => true,
'property' => true,
'vocab' => true,
'translate' => true,
'lang' => true
),
'h2' => array(
'title' => true,
'class' => true,
'id' => true,
'dir' => true,
'align' => true,
'lang' => true,
'xml:lang' => true,
'aria-hidden' => true,
'data-icon' => true,
'itemref' => true,
'itemid' => true,
'itemprop' => true,
'itemscope' => true,
'itemtype' => true,
'xmlns:v' => true,
'typeof' => true,
'property' => true,
'vocab' => true,
'translate' => true,
'lang' => true
),
'meta' => array(
'content' => true,
'property' => true,
'vocab' => true,
'itemprop' => true
)
);
if(!is_array($tags))
{
$tags = array();
}
return adminKit::array_merge_recursive($tags, $allowed_html);
}
public function get_version()
{
return self::version;
}
public function uninstall()
{
$this->admin->uninstall();
}
static function setup_setting_defaults(array &$settings)
{
//Hook for letting other plugins add in their default settings (has to go first to prevent other from overriding base settings)
$settings = apply_filters('bcn_settings_init', $settings);
//Now on to our settings
$settings['bmainsite_display'] = new setting\setting_bool(
'mainsite_display',
true,
__('Main Site Breadcrumb', 'breadcrumb-navxt'));
$settings['Hmainsite_template'] = new setting\setting_html(
'mainsite_template',
bcn_breadcrumb::get_default_template(),
__('Main Site Home Template', 'breadcrumb-navxt'));
$settings['Hmainsite_template_no_anchor'] = new setting\setting_html(
'mainsite_template_no_anchor',
bcn_breadcrumb::default_template_no_anchor,
__('Main Site Home Template (Unlinked)', 'breadcrumb-navxt'));
$settings['bhome_display'] = new setting\setting_bool(
'home_display',
true,
__('Home Breadcrumb', 'breadcrumb-navxt'));
$settings['Hhome_template'] = new setting\setting_html(
'home_template',
(isset($settings['Hhome_template']) && is_string($settings['Hhome_template'])) ? $settings['Hhome_template'] : bcn_breadcrumb::get_default_template(),
__('Home Template', 'breadcrumb-navxt'));
$settings['Hhome_template_no_anchor'] = new setting\setting_html(
'home_template_no_anchor',
(isset($settings['Hhome_template_no_anchor']) && is_string($settings['Hhome_template_no_anchor'])) ? $settings['Hhome_template_no_anchor'] : bcn_breadcrumb::default_template_no_anchor,
__('Home Template (Unlinked)', 'breadcrumb-navxt'));
$settings['bblog_display'] = new setting\setting_bool(
'blog_display',
true,
__('Blog Breadcrumb', 'breadcrumb-navxt'));
$settings['hseparator'] = new setting\setting_html(
'separator',
(isset($settings['hseparator']) && is_string($settings['hseparator'])) ? $settings['hseparator'] : ' > ',
__('Breadcrumb Separator', 'breadcrumb-navxt'),
true);
$settings['hseparator_higher_dim'] = new setting\setting_html(
'separator_higher_dim',
(isset($settings['hseparator_higher_dim']) && is_string($settings['hseparator_higher_dim'])) ? $settings['hseparator_higher_dim'] : ', ',
__('Breadcrumb Separator (Higher Dimension)', 'breadcrumb-navxt'),
true);
$settings['bcurrent_item_linked'] = new setting\setting_bool(
'current_item_linked',
false,
__('Link Current Item', 'breadcrumb-navxt'));
$settings['Hpaged_template'] = new setting\setting_html(
'paged_template',
sprintf('