Version Description
Release date: December, 26th 2017
- Behavior change:
bcn_breadcrumb_trail::display_list()
deprecated in favor of using the$template
parameter inbcn_breadcrumb_trail::display()
. - Behavior change:
bcn_breadcrumb_trail::do_attachment()
deprecated in favor of callingbcn_breadcrumb_trail::do_post()
. - Behavior change:
bcn_breadcrumb_trail::do_front_page()
deprecated in favor of callingbcn_breadcrumb_trail::do_home()
. - Behavior change:
bcn_li_attributes
filter was deprecated in favor ofbcn_display_attributes
. - Behavior change:
bcn_breadcrumb_trail::do_archive_by_date()
deprecated in favor of calling bcn_breadcrumb_trail::do_day(),
bcn_breadcrumb_trail::do_month(), and/or
bcn_breadcrumb_trail::do_year()`. - Behavior change:
bcn_breadcrumb_trail::find_type()
deprecated and removed from bcn_breadcrumb_trail. - Behavior change: Breadcrumb for 404 error pages changed to be a child of the front page.
- New feature: Added support for various HTML tags in the widget's pretext field.
- New feature: Added
bcn_default_hierarchy_display
filter. - New feature: Added
bcn_default_hierarchy_type
filter. - New feature: Added
$posttype_name
as the third parameter tobcn_show_tax_private
. - Bug fix: Fixed UI/UX issue in the settings screen where enabling/disabling settings groups for the Home, Blog, and Mainsite breadcrumb settings did not work.
- Bug fix: Fixed UI/UX issue in the settings screen where not including the paged breadcrumb still allowed the paged breadcrumb template to be edited.
- Bug fix: Removed use of
create_function
in registering the widget as it was deprecated in PHP 7.2.
Download this release
Release Info
Developer | mtekk |
Plugin | Breadcrumb NavXT |
Version | 6.0.0 |
Comparing to | |
See all releases |
Code changes from version 5.7.1 to 6.0.0
- breadcrumb-navxt.php +47 -25
- class.bcn_admin.php +99 -60
- class.bcn_breadcrumb.php +24 -24
- class.bcn_breadcrumb_trail.php +337 -356
- class.bcn_network_admin.php +34 -639
- class.bcn_widget.php +27 -23
- includes/block_direct_access.php +2 -1
- includes/class.mtekk_adminkit.php +174 -106
- includes/class.mtekk_adminkit_message.php +99 -0
- includes/class.mtekk_adminkit_uninstaller.php +1 -1
- includes/mtekk_adminkit_engroups.js +2 -2
- includes/mtekk_adminkit_engroups.min.js +1 -1
- includes/mtekk_adminkit_messages.js +11 -0
- includes/mtekk_adminkit_messages.min.js +11 -0
- includes/multibyte_supplicant.php +1 -1
- readme.txt +25 -8
breadcrumb-navxt.php
CHANGED
@@ -3,14 +3,15 @@
|
|
3 |
Plugin Name: Breadcrumb NavXT
|
4 |
Plugin URI: http://mtekk.us/code/breadcrumb-navxt/
|
5 |
Description: Adds a breadcrumb navigation showing the visitor's path to their current location. For details on how to use this plugin visit <a href="http://mtekk.us/code/breadcrumb-navxt/">Breadcrumb NavXT</a>.
|
6 |
-
Version:
|
7 |
Author: John Havlik
|
8 |
Author URI: http://mtekk.us/
|
9 |
License: GPL2
|
10 |
Text Domain: breadcrumb-navxt
|
11 |
Domain Path: /languages
|
12 |
*/
|
13 |
-
/*
|
|
|
14 |
|
15 |
This program is free software; you can redistribute it and/or modify
|
16 |
it under the terms of the GNU General Public License as published by
|
@@ -32,7 +33,7 @@ if(version_compare(phpversion(), '5.3.0', '<'))
|
|
32 |
//Only purpose of this function is to echo out the PHP version error
|
33 |
function bcn_phpold()
|
34 |
{
|
35 |
-
printf('<div class="error"><p>' .
|
36 |
}
|
37 |
//If we are in the admin, let's print a warning then return
|
38 |
if(is_admin())
|
@@ -56,11 +57,11 @@ if(class_exists('WP_Widget'))
|
|
56 |
//Include the WP 2.8+ widget class
|
57 |
require_once(dirname(__FILE__) . '/class.bcn_widget.php');
|
58 |
}
|
59 |
-
$breadcrumb_navxt =
|
60 |
//TODO change to extends mtekk_plugKit
|
61 |
class breadcrumb_navxt
|
62 |
{
|
63 |
-
const version = '
|
64 |
protected $name = 'Breadcrumb NavXT';
|
65 |
protected $identifier = 'breadcrumb-navxt';
|
66 |
protected $unique_prefix = 'bcn';
|
@@ -85,7 +86,7 @@ class breadcrumb_navxt
|
|
85 |
add_action('wp_loaded', array($this, 'wp_loaded'), 15);
|
86 |
add_action('init', array($this, 'init'));
|
87 |
//Register the WordPress 2.8 Widget
|
88 |
-
add_action('widgets_init',
|
89 |
//Load our network admin if in the network dashboard (yes is_network_admin() doesn't exist)
|
90 |
if(defined('WP_NETWORK_ADMIN') && WP_NETWORK_ADMIN)
|
91 |
{
|
@@ -107,6 +108,10 @@ class breadcrumb_navxt
|
|
107 |
//We want to run late for using our breadcrumbs
|
108 |
add_filter('tha_breadcrumb_navigation', array($this, 'tha_compat'), 99);
|
109 |
}
|
|
|
|
|
|
|
|
|
110 |
public function allowed_html($tags)
|
111 |
{
|
112 |
$allowed_html = array(
|
@@ -277,7 +282,7 @@ class breadcrumb_navxt
|
|
277 |
$opts['bpost_' . $post_type->name . '_taxonomy_referer'] = false;
|
278 |
}
|
279 |
//If the post type does not have settings in the options array yet, we need to load some defaults
|
280 |
-
if(!isset($opts['Hpost_' . $post_type->name . '_template']) || !$post_type->hierarchical && !isset($opts['Spost_' . $post_type->name . '
|
281 |
{
|
282 |
//Add the necessary option array members
|
283 |
$opts['Hpost_' . $post_type->name . '_template'] = bcn_breadcrumb::get_default_template();
|
@@ -293,28 +298,31 @@ class breadcrumb_navxt
|
|
293 |
//Default to not showing a post_root
|
294 |
$opts['apost_' . $post_type->name . '_root'] = 0;
|
295 |
//Default to not displaying a taxonomy
|
296 |
-
$opts['bpost_' . $post_type->name . '
|
297 |
//Loop through all of the possible taxonomies
|
298 |
foreach($wp_taxonomies as $taxonomy)
|
299 |
{
|
300 |
//Check for non-public taxonomies
|
301 |
-
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name))
|
302 |
{
|
303 |
continue;
|
304 |
}
|
305 |
//Activate the first taxonomy valid for this post type and exit the loop
|
306 |
if($taxonomy->object_type == $post_type->name || in_array($post_type->name, $taxonomy->object_type))
|
307 |
{
|
308 |
-
$opts['bpost_' . $post_type->name . '
|
309 |
-
$opts['Spost_' . $post_type->name . '
|
310 |
break;
|
311 |
}
|
312 |
}
|
313 |
-
//If there are no valid taxonomies for this type,
|
314 |
-
if(!isset($opts['Spost_' . $post_type->name . '
|
315 |
{
|
316 |
-
$opts['Spost_' . $post_type->name . '
|
317 |
}
|
|
|
|
|
|
|
318 |
}
|
319 |
}
|
320 |
}
|
@@ -391,8 +399,12 @@ class breadcrumb_navxt
|
|
391 |
* @param bool $linked Whether to allow hyperlinks in the trail or not.
|
392 |
* @param bool $reverse Whether to reverse the output or not.
|
393 |
* @param bool $force Whether or not to force the fill function to run.
|
|
|
|
|
|
|
|
|
394 |
*/
|
395 |
-
public function display($return = false, $linked = true, $reverse = false, $force = false)
|
396 |
{
|
397 |
$this->get_settings();
|
398 |
//If we're being forced to fill the trail, clear it before calling fill
|
@@ -407,22 +419,20 @@ class breadcrumb_navxt
|
|
407 |
/**
|
408 |
* Outputs the breadcrumb trail with each element encapsulated with li tags
|
409 |
*
|
|
|
|
|
410 |
* @param bool $return Whether to return or echo the trail.
|
411 |
* @param bool $linked Whether to allow hyperlinks in the trail or not.
|
412 |
* @param bool $reverse Whether to reverse the output or not.
|
413 |
* @param bool $force Whether or not to force the fill function to run.
|
|
|
|
|
|
|
414 |
*/
|
415 |
public function display_list($return = false, $linked = true, $reverse = false, $force = false)
|
416 |
{
|
417 |
-
|
418 |
-
|
419 |
-
if($force)
|
420 |
-
{
|
421 |
-
$this->breadcrumb_trail->breadcrumbs = array();
|
422 |
-
}
|
423 |
-
//Generate the breadcrumb trail
|
424 |
-
$this->breadcrumb_trail->fill();
|
425 |
-
return $this->breadcrumb_trail->display_list($return, $linked, $reverse);
|
426 |
}
|
427 |
/**
|
428 |
* Outputs the breadcrumb trail in Schema.org BreadcrumbList compatible JSON-LD
|
@@ -430,6 +440,9 @@ class breadcrumb_navxt
|
|
430 |
* @param bool $return Whether to return or echo the trail.
|
431 |
* @param bool $reverse Whether to reverse the output or not.
|
432 |
* @param bool $force Whether or not to force the fill function to run.
|
|
|
|
|
|
|
433 |
*/
|
434 |
public function display_json_ld($return = false, $reverse = false, $force = false)
|
435 |
{
|
@@ -461,6 +474,9 @@ function bcn_init()
|
|
461 |
* @param bool $linked Whether to allow hyperlinks in the trail or not. (optional)
|
462 |
* @param bool $reverse Whether to reverse the output or not. (optional)
|
463 |
* @param bool $force Whether or not to force the fill function to run. (optional)
|
|
|
|
|
|
|
464 |
*/
|
465 |
function bcn_display($return = false, $linked = true, $reverse = false, $force = false)
|
466 |
{
|
@@ -477,13 +493,16 @@ function bcn_display($return = false, $linked = true, $reverse = false, $force =
|
|
477 |
* @param bool $linked Whether to allow hyperlinks in the trail or not. (optional)
|
478 |
* @param bool $reverse Whether to reverse the output or not. (optional)
|
479 |
* @param bool $force Whether or not to force the fill function to run. (optional)
|
|
|
|
|
|
|
480 |
*/
|
481 |
function bcn_display_list($return = false, $linked = true, $reverse = false, $force = false)
|
482 |
{
|
483 |
global $breadcrumb_navxt;
|
484 |
if($breadcrumb_navxt !== null)
|
485 |
{
|
486 |
-
return $breadcrumb_navxt->
|
487 |
}
|
488 |
}
|
489 |
/**
|
@@ -492,6 +511,9 @@ function bcn_display_list($return = false, $linked = true, $reverse = false, $fo
|
|
492 |
* @param bool $return Whether to return or echo the trail. (optional)
|
493 |
* @param bool $reverse Whether to reverse the output or not. (optional)
|
494 |
* @param bool $force Whether or not to force the fill function to run. (optional)
|
|
|
|
|
|
|
495 |
*/
|
496 |
function bcn_display_json_ld($return = false, $reverse = false, $force = false)
|
497 |
{
|
3 |
Plugin Name: Breadcrumb NavXT
|
4 |
Plugin URI: http://mtekk.us/code/breadcrumb-navxt/
|
5 |
Description: Adds a breadcrumb navigation showing the visitor's path to their current location. For details on how to use this plugin visit <a href="http://mtekk.us/code/breadcrumb-navxt/">Breadcrumb NavXT</a>.
|
6 |
+
Version: 6.0.0
|
7 |
Author: John Havlik
|
8 |
Author URI: http://mtekk.us/
|
9 |
License: GPL2
|
10 |
Text Domain: breadcrumb-navxt
|
11 |
Domain Path: /languages
|
12 |
*/
|
13 |
+
/*
|
14 |
+
Copyright 2007-2017 John Havlik (email : john.havlik@mtekk.us)
|
15 |
|
16 |
This program is free software; you can redistribute it and/or modify
|
17 |
it under the terms of the GNU General Public License as published by
|
33 |
//Only purpose of this function is to echo out the PHP version error
|
34 |
function bcn_phpold()
|
35 |
{
|
36 |
+
printf('<div class="notice notice-error"><p>' . 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') . '</p></div>', phpversion(), '5.3.0');
|
37 |
}
|
38 |
//If we are in the admin, let's print a warning then return
|
39 |
if(is_admin())
|
57 |
//Include the WP 2.8+ widget class
|
58 |
require_once(dirname(__FILE__) . '/class.bcn_widget.php');
|
59 |
}
|
60 |
+
$breadcrumb_navxt = null;
|
61 |
//TODO change to extends mtekk_plugKit
|
62 |
class breadcrumb_navxt
|
63 |
{
|
64 |
+
const version = '6.0.0';
|
65 |
protected $name = 'Breadcrumb NavXT';
|
66 |
protected $identifier = 'breadcrumb-navxt';
|
67 |
protected $unique_prefix = 'bcn';
|
86 |
add_action('wp_loaded', array($this, 'wp_loaded'), 15);
|
87 |
add_action('init', array($this, 'init'));
|
88 |
//Register the WordPress 2.8 Widget
|
89 |
+
add_action('widgets_init', array($this, 'register_widget'));
|
90 |
//Load our network admin if in the network dashboard (yes is_network_admin() doesn't exist)
|
91 |
if(defined('WP_NETWORK_ADMIN') && WP_NETWORK_ADMIN)
|
92 |
{
|
108 |
//We want to run late for using our breadcrumbs
|
109 |
add_filter('tha_breadcrumb_navigation', array($this, 'tha_compat'), 99);
|
110 |
}
|
111 |
+
public function register_widget()
|
112 |
+
{
|
113 |
+
return register_widget($this->unique_prefix . '_widget');
|
114 |
+
}
|
115 |
public function allowed_html($tags)
|
116 |
{
|
117 |
$allowed_html = array(
|
282 |
$opts['bpost_' . $post_type->name . '_taxonomy_referer'] = false;
|
283 |
}
|
284 |
//If the post type does not have settings in the options array yet, we need to load some defaults
|
285 |
+
if(!isset($opts['Hpost_' . $post_type->name . '_template']) || !$post_type->hierarchical && !isset($opts['Spost_' . $post_type->name . '_hierarchy_type']))
|
286 |
{
|
287 |
//Add the necessary option array members
|
288 |
$opts['Hpost_' . $post_type->name . '_template'] = bcn_breadcrumb::get_default_template();
|
298 |
//Default to not showing a post_root
|
299 |
$opts['apost_' . $post_type->name . '_root'] = 0;
|
300 |
//Default to not displaying a taxonomy
|
301 |
+
$opts['bpost_' . $post_type->name . '_hierarchy_display'] = false;
|
302 |
//Loop through all of the possible taxonomies
|
303 |
foreach($wp_taxonomies as $taxonomy)
|
304 |
{
|
305 |
//Check for non-public taxonomies
|
306 |
+
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name, $post_type->name))
|
307 |
{
|
308 |
continue;
|
309 |
}
|
310 |
//Activate the first taxonomy valid for this post type and exit the loop
|
311 |
if($taxonomy->object_type == $post_type->name || in_array($post_type->name, $taxonomy->object_type))
|
312 |
{
|
313 |
+
$opts['bpost_' . $post_type->name . '_hierarchy_display'] = true;
|
314 |
+
$opts['Spost_' . $post_type->name . '_hierarchy_type'] = $taxonomy->name;
|
315 |
break;
|
316 |
}
|
317 |
}
|
318 |
+
//If there are no valid taxonomies for this type, setup our defaults
|
319 |
+
if(!isset($opts['Spost_' . $post_type->name . '_hierarchy_type']))
|
320 |
{
|
321 |
+
$opts['Spost_' . $post_type->name . '_hierarchy_type'] = 'BCN_DATE';
|
322 |
}
|
323 |
+
//Run through some filters, allowing extensions to directly influence the default hierarchy selection/display
|
324 |
+
$opts['Spost_' . $post_type->name . '_hierarchy_type'] = apply_filters('bcn_default_hierarchy_type', $opts['Spost_' . $post_type->name . '_hierarchy_type'], $post_type->name);
|
325 |
+
$opts['bpost_' . $post_type->name . '_hierarchy_display'] = apply_filters('bcn_default_hierarchy_display', $opts['bpost_' . $post_type->name . '_hierarchy_display'], $post_type->name, $opts['Spost_' . $post_type->name . '_hierarchy_type']);
|
326 |
}
|
327 |
}
|
328 |
}
|
399 |
* @param bool $linked Whether to allow hyperlinks in the trail or not.
|
400 |
* @param bool $reverse Whether to reverse the output or not.
|
401 |
* @param bool $force Whether or not to force the fill function to run.
|
402 |
+
* @param string $template The template to use for the string output.
|
403 |
+
*
|
404 |
+
* @return void Void if Option to print out breadcrumb trail was chosen.
|
405 |
+
* @return string String-Data of breadcrumb trail.
|
406 |
*/
|
407 |
+
public function display($return = false, $linked = true, $reverse = false, $force = false, $template = '%1$s%2$s')
|
408 |
{
|
409 |
$this->get_settings();
|
410 |
//If we're being forced to fill the trail, clear it before calling fill
|
419 |
/**
|
420 |
* Outputs the breadcrumb trail with each element encapsulated with li tags
|
421 |
*
|
422 |
+
* @deprecated 6.0.0 No longer needed, superceeded by $template parameter in display
|
423 |
+
*
|
424 |
* @param bool $return Whether to return or echo the trail.
|
425 |
* @param bool $linked Whether to allow hyperlinks in the trail or not.
|
426 |
* @param bool $reverse Whether to reverse the output or not.
|
427 |
* @param bool $force Whether or not to force the fill function to run.
|
428 |
+
*
|
429 |
+
* @return void Void if Option to print out breadcrumb trail was chosen.
|
430 |
+
* @return string String-Data of breadcrumb trail.
|
431 |
*/
|
432 |
public function display_list($return = false, $linked = true, $reverse = false, $force = false)
|
433 |
{
|
434 |
+
_deprecated_function( __FUNCTION__, '6.0', 'breadcrumb_navxt::display');
|
435 |
+
return $this->display($return, $linked, $reverse, $force, "<li%3\$s>%1\$s</li>\n");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
436 |
}
|
437 |
/**
|
438 |
* Outputs the breadcrumb trail in Schema.org BreadcrumbList compatible JSON-LD
|
440 |
* @param bool $return Whether to return or echo the trail.
|
441 |
* @param bool $reverse Whether to reverse the output or not.
|
442 |
* @param bool $force Whether or not to force the fill function to run.
|
443 |
+
*
|
444 |
+
* @return void Void if Option to print out breadcrumb trail was chosen.
|
445 |
+
* @return string String-Data of breadcrumb trail.
|
446 |
*/
|
447 |
public function display_json_ld($return = false, $reverse = false, $force = false)
|
448 |
{
|
474 |
* @param bool $linked Whether to allow hyperlinks in the trail or not. (optional)
|
475 |
* @param bool $reverse Whether to reverse the output or not. (optional)
|
476 |
* @param bool $force Whether or not to force the fill function to run. (optional)
|
477 |
+
*
|
478 |
+
* @return void Void if Option to print out breadcrumb trail was chosen.
|
479 |
+
* @return string String-Data of breadcrumb trail.
|
480 |
*/
|
481 |
function bcn_display($return = false, $linked = true, $reverse = false, $force = false)
|
482 |
{
|
493 |
* @param bool $linked Whether to allow hyperlinks in the trail or not. (optional)
|
494 |
* @param bool $reverse Whether to reverse the output or not. (optional)
|
495 |
* @param bool $force Whether or not to force the fill function to run. (optional)
|
496 |
+
*
|
497 |
+
* @return void Void if Option to print out breadcrumb trail was chosen.
|
498 |
+
* @return string String-Data of breadcrumb trail.
|
499 |
*/
|
500 |
function bcn_display_list($return = false, $linked = true, $reverse = false, $force = false)
|
501 |
{
|
502 |
global $breadcrumb_navxt;
|
503 |
if($breadcrumb_navxt !== null)
|
504 |
{
|
505 |
+
return $breadcrumb_navxt->display($return, $linked, $reverse, $force, "<li%3\$s>%1\$s</li>\n");
|
506 |
}
|
507 |
}
|
508 |
/**
|
511 |
* @param bool $return Whether to return or echo the trail. (optional)
|
512 |
* @param bool $reverse Whether to reverse the output or not. (optional)
|
513 |
* @param bool $force Whether or not to force the fill function to run. (optional)
|
514 |
+
*
|
515 |
+
* @return void Void if Option to print out breadcrumb trail was chosen.
|
516 |
+
* @return string String-Data of breadcrumb trail.
|
517 |
*/
|
518 |
function bcn_display_json_ld($return = false, $reverse = false, $force = false)
|
519 |
{
|
class.bcn_admin.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
-
/*
|
|
|
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
|
@@ -22,7 +23,7 @@ if(version_compare(phpversion(), '5.3.0', '<'))
|
|
22 |
//Only purpose of this function is to echo out the PHP version error
|
23 |
function bcn_phpold()
|
24 |
{
|
25 |
-
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');
|
26 |
}
|
27 |
//If we are in the admin, let's print a warning then return
|
28 |
if(is_admin())
|
@@ -42,7 +43,7 @@ if(!class_exists('mtekk_adminKit'))
|
|
42 |
*/
|
43 |
class bcn_admin extends mtekk_adminKit
|
44 |
{
|
45 |
-
const version = '
|
46 |
protected $full_name = 'Breadcrumb NavXT Settings';
|
47 |
protected $short_name = 'Breadcrumb NavXT';
|
48 |
protected $access_level = 'manage_options';
|
@@ -61,7 +62,7 @@ class bcn_admin extends mtekk_adminKit
|
|
61 |
{
|
62 |
$this->breadcrumb_trail =& $breadcrumb_trail;
|
63 |
$this->plugin_basename = $basename;
|
64 |
-
$this->full_name =
|
65 |
//Grab defaults from the breadcrumb_trail object
|
66 |
$this->opt =& $this->breadcrumb_trail->opt;
|
67 |
//We're going to make sure we load the parent's constructor
|
@@ -100,8 +101,8 @@ class bcn_admin extends mtekk_adminKit
|
|
100 |
//Upgrading to 3.8.1
|
101 |
if(version_compare($version, '3.8.1', '<'))
|
102 |
{
|
103 |
-
$opts['post_page_root'] = get_option('page_on_front');
|
104 |
-
$opts['post_post_root'] = get_option('page_for_posts');
|
105 |
}
|
106 |
//Upgrading to 4.0
|
107 |
if(version_compare($version, '4.0.0', '<'))
|
@@ -258,6 +259,24 @@ class bcn_admin extends mtekk_adminKit
|
|
258 |
}
|
259 |
}
|
260 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
//Set the max title length to 20 if we are not limiting the title and the length was 0
|
262 |
if(!$opts['blimit_title'] && $opts['amax_title_length'] == 0)
|
263 |
{
|
@@ -292,14 +311,14 @@ class bcn_admin extends mtekk_adminKit
|
|
292 |
//Add contextual help on current screen
|
293 |
if($screen->id == 'settings_page_' . $this->identifier)
|
294 |
{
|
295 |
-
$general_tab = '<p>' .
|
296 |
-
'</p><h5>' .
|
297 |
-
sprintf(
|
298 |
-
sprintf(
|
299 |
-
sprintf(
|
300 |
-
'<h5>' .
|
301 |
-
sprintf(
|
302 |
-
sprintf(
|
303 |
|
304 |
$screen->add_help_tab(
|
305 |
array(
|
@@ -307,14 +326,14 @@ class bcn_admin extends mtekk_adminKit
|
|
307 |
'title' => __('General', 'breadcrumb-navxt'),
|
308 |
'content' => $general_tab
|
309 |
));
|
310 |
-
$quickstart_tab = '<p>' .
|
311 |
-
'</p><h5>' .
|
312 |
<?php if(function_exists('bcn_display'))
|
313 |
{
|
314 |
bcn_display();
|
315 |
}?>
|
316 |
</div></code></pre>" .
|
317 |
-
'<h5>' .
|
318 |
<?php if(function_exists('bcn_display_list'))
|
319 |
{
|
320 |
bcn_display_list();
|
@@ -326,7 +345,7 @@ class bcn_admin extends mtekk_adminKit
|
|
326 |
'title' => __('Quick Start', 'breadcrumb-navxt'),
|
327 |
'content' => $quickstart_tab
|
328 |
));
|
329 |
-
$styling_tab = '<p>' .
|
330 |
'<pre><code>.breadcrumbs
|
331 |
{
|
332 |
font-size: 1.1em;
|
@@ -388,20 +407,20 @@ class bcn_admin extends mtekk_adminKit
|
|
388 |
}
|
389 |
else if(defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK)
|
390 |
{
|
391 |
-
$this->
|
392 |
}
|
393 |
else if(defined('BCN_SETTINGS_FAVOR_LOCAL') && BCN_SETTINGS_FAVOR_LOCAL)
|
394 |
{
|
395 |
-
$this->
|
396 |
}
|
397 |
else if(defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK)
|
398 |
{
|
399 |
-
$this->
|
400 |
}
|
401 |
//Fall through if no settings mode was set
|
402 |
else
|
403 |
{
|
404 |
-
$this->
|
405 |
}
|
406 |
}
|
407 |
}
|
@@ -413,9 +432,27 @@ class bcn_admin extends mtekk_adminKit
|
|
413 |
//We're deprecating the limit title length setting, let the user know the new method of accomplishing this
|
414 |
if(isset($this->opt['blimit_title']) && $this->opt['blimit_title'])
|
415 |
{
|
416 |
-
$this->
|
417 |
}
|
418 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
419 |
/**
|
420 |
* The administrative page for Breadcrumb NavXT
|
421 |
*/
|
@@ -434,7 +471,7 @@ class bcn_admin extends mtekk_adminKit
|
|
434 |
<div class="wrap"><h2><?php echo $this->full_name; ?></h2>
|
435 |
<?php
|
436 |
//We exit after the version check if there is an action the user needs to take before saving settings
|
437 |
-
if(!$this->version_check(get_option($this->unique_prefix . '_version')))
|
438 |
{
|
439 |
return;
|
440 |
}
|
@@ -452,38 +489,38 @@ class bcn_admin extends mtekk_adminKit
|
|
452 |
?>
|
453 |
</table>
|
454 |
<h3><?php _e('Current Item', 'breadcrumb-navxt'); ?></h3>
|
455 |
-
<table class="form-table">
|
456 |
<?php
|
457 |
$this->input_check(__('Link Current Item', 'breadcrumb-navxt'), 'bcurrent_item_linked', __('Yes', 'breadcrumb-navxt'));
|
458 |
-
$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'));
|
459 |
-
$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'));
|
460 |
do_action($this->unique_prefix . '_settings_current_item', $this->opt);
|
461 |
?>
|
462 |
</table>
|
463 |
<h3><?php _e('Home Breadcrumb', 'breadcrumb-navxt'); ?></h3>
|
464 |
-
<table class="form-table adminkit-
|
465 |
<?php
|
466 |
-
$this->input_check(__('Home Breadcrumb', 'breadcrumb-navxt'), 'bhome_display', __('Place the home breadcrumb in the trail.', 'breadcrumb-navxt'));
|
467 |
-
$this->textbox(__('Home Template', 'breadcrumb-navxt'), 'Hhome_template', '6', false, __('The template for the home breadcrumb.', 'breadcrumb-navxt'));
|
468 |
-
$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'));
|
469 |
do_action($this->unique_prefix . '_settings_home', $this->opt);
|
470 |
?>
|
471 |
</table>
|
472 |
<h3><?php _e('Blog Breadcrumb', 'breadcrumb-navxt'); ?></h3>
|
473 |
-
<table class="form-table adminkit-
|
474 |
<?php
|
475 |
-
$this->input_check(__('Blog Breadcrumb', 'breadcrumb-navxt'), 'bblog_display', __('Place the blog breadcrumb in the trail.', 'breadcrumb-navxt'), (
|
476 |
-
$this->textbox(__('Blog Template', 'breadcrumb-navxt'), 'Hblog_template', '6', (
|
477 |
-
$this->textbox(__('Blog Template (Unlinked)', 'breadcrumb-navxt'), 'Hblog_template_no_anchor', '4', (
|
478 |
do_action($this->unique_prefix . '_settings_blog', $this->opt);
|
479 |
?>
|
480 |
</table>
|
481 |
<h3><?php _e('Mainsite Breadcrumb', 'breadcrumb-navxt'); ?></h3>
|
482 |
-
<table class="form-table adminkit-
|
483 |
<?php
|
484 |
-
$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'),
|
485 |
-
$this->textbox(__('Main Site Home Template', 'breadcrumb-navxt'), 'Hmainsite_template', '6',
|
486 |
-
$this->textbox(__('Main Site Home Template (Unlinked)', 'breadcrumb-navxt'), 'Hmainsite_template_no_anchor', '4',
|
487 |
do_action($this->unique_prefix . '_settings_mainsite', $this->opt);
|
488 |
?>
|
489 |
</table>
|
@@ -496,7 +533,7 @@ class bcn_admin extends mtekk_adminKit
|
|
496 |
<?php
|
497 |
$this->textbox(__('Post Template', 'breadcrumb-navxt'), 'Hpost_post_template', '6', false, __('The template for post breadcrumbs.', 'breadcrumb-navxt'));
|
498 |
$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'));
|
499 |
-
$this->input_check(__('Post Hierarchy Display', 'breadcrumb-navxt'), '
|
500 |
$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');
|
501 |
?>
|
502 |
<tr valign="top">
|
@@ -505,27 +542,27 @@ class bcn_admin extends mtekk_adminKit
|
|
505 |
</th>
|
506 |
<td>
|
507 |
<?php
|
508 |
-
$this->input_radio('
|
509 |
-
$this->input_radio('
|
510 |
-
$this->input_radio('
|
511 |
//We use the value 'page' but really, this will follow the parent post hierarchy
|
512 |
-
$this->input_radio('
|
513 |
//Loop through all of the taxonomies in the array
|
514 |
foreach($wp_taxonomies as $taxonomy)
|
515 |
{
|
516 |
//Check for non-public taxonomies
|
517 |
-
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name))
|
518 |
{
|
519 |
continue;
|
520 |
}
|
521 |
//We only want custom taxonomies
|
522 |
if(($taxonomy->object_type == 'post' || is_array($taxonomy->object_type) && in_array('post', $taxonomy->object_type)) && !$taxonomy->_builtin)
|
523 |
{
|
524 |
-
$this->input_radio('
|
525 |
}
|
526 |
}
|
527 |
?>
|
528 |
-
<p class="description"><?php
|
529 |
</td>
|
530 |
</tr>
|
531 |
</table>
|
@@ -534,6 +571,8 @@ class bcn_admin extends mtekk_adminKit
|
|
534 |
<?php
|
535 |
$this->textbox(__('Page Template', 'breadcrumb-navxt'), 'Hpost_page_template', '6', false, __('The template for page breadcrumbs.', 'breadcrumb-navxt'));
|
536 |
$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'));
|
|
|
|
|
537 |
?>
|
538 |
</table>
|
539 |
<h3><?php _e('Attachments', 'breadcrumb-navxt'); ?></h3>
|
@@ -562,11 +601,11 @@ class bcn_admin extends mtekk_adminKit
|
|
562 |
<?php
|
563 |
$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));
|
564 |
$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));
|
565 |
-
$optid =
|
566 |
?>
|
567 |
<tr valign="top">
|
568 |
<th scope="row">
|
569 |
-
<label for="<?php echo $optid;?>"><?php printf(
|
570 |
</th>
|
571 |
<td>
|
572 |
<?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']));?>
|
@@ -574,7 +613,7 @@ class bcn_admin extends mtekk_adminKit
|
|
574 |
</tr>
|
575 |
<?php
|
576 |
$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);
|
577 |
-
$this->input_check(sprintf(__('%s Hierarchy Display', 'breadcrumb-navxt'), $post_type->labels->singular_name), 'bpost_' . $post_type->name . '
|
578 |
$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');
|
579 |
?>
|
580 |
<tr valign="top">
|
@@ -584,20 +623,20 @@ class bcn_admin extends mtekk_adminKit
|
|
584 |
<td>
|
585 |
<?php
|
586 |
//We use the value 'page' but really, this will follow the parent post hierarchy
|
587 |
-
$this->input_radio('Spost_' . $post_type->name . '
|
588 |
-
$this->input_radio('Spost_' . $post_type->name . '
|
589 |
//Loop through all of the taxonomies in the array
|
590 |
foreach($wp_taxonomies as $taxonomy)
|
591 |
{
|
592 |
//Check for non-public taxonomies
|
593 |
-
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name))
|
594 |
{
|
595 |
continue;
|
596 |
}
|
597 |
//We only want custom taxonomies
|
598 |
if($taxonomy->object_type == $post_type->name || in_array($post_type->name, $taxonomy->object_type))
|
599 |
{
|
600 |
-
$this->input_radio('Spost_' . $post_type->name . '
|
601 |
}
|
602 |
}
|
603 |
?>
|
@@ -605,11 +644,11 @@ class bcn_admin extends mtekk_adminKit
|
|
605 |
<?php
|
606 |
if($post_type->hierarchical)
|
607 |
{
|
608 |
-
|
609 |
}
|
610 |
else
|
611 |
{
|
612 |
-
|
613 |
}
|
614 |
?>
|
615 |
</p>
|
@@ -650,7 +689,7 @@ class bcn_admin extends mtekk_adminKit
|
|
650 |
foreach($wp_taxonomies as $taxonomy)
|
651 |
{
|
652 |
//Check for non-public taxonomies
|
653 |
-
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name))
|
654 |
{
|
655 |
continue;
|
656 |
}
|
@@ -696,17 +735,17 @@ class bcn_admin extends mtekk_adminKit
|
|
696 |
<table class="form-table">
|
697 |
<tr valign="top">
|
698 |
<th scope="row">
|
699 |
-
<?php
|
700 |
</th>
|
701 |
<td>
|
702 |
<label>
|
703 |
<input name="bcn_options[blimit_title]" type="checkbox" id="blimit_title" value="true" <?php checked(true, $this->opt['blimit_title']); ?> />
|
704 |
-
<?php printf(
|
705 |
</label><br />
|
706 |
<ul>
|
707 |
<li>
|
708 |
<label for="amax_title_length">
|
709 |
-
<?php
|
710 |
<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" />
|
711 |
</label>
|
712 |
</li>
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
Copyright 2015-2017 John Havlik (email : john.havlik@mtekk.us)
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
23 |
//Only purpose of this function is to echo out the PHP version error
|
24 |
function bcn_phpold()
|
25 |
{
|
26 |
+
printf('<div class="notice notice-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');
|
27 |
}
|
28 |
//If we are in the admin, let's print a warning then return
|
29 |
if(is_admin())
|
43 |
*/
|
44 |
class bcn_admin extends mtekk_adminKit
|
45 |
{
|
46 |
+
const version = '6.0.0';
|
47 |
protected $full_name = 'Breadcrumb NavXT Settings';
|
48 |
protected $short_name = 'Breadcrumb NavXT';
|
49 |
protected $access_level = 'manage_options';
|
62 |
{
|
63 |
$this->breadcrumb_trail =& $breadcrumb_trail;
|
64 |
$this->plugin_basename = $basename;
|
65 |
+
$this->full_name = esc_html__('Breadcrumb NavXT Settings', 'breadcrumb-navxt');
|
66 |
//Grab defaults from the breadcrumb_trail object
|
67 |
$this->opt =& $this->breadcrumb_trail->opt;
|
68 |
//We're going to make sure we load the parent's constructor
|
101 |
//Upgrading to 3.8.1
|
102 |
if(version_compare($version, '3.8.1', '<'))
|
103 |
{
|
104 |
+
$opts['post_page_root'] = $this->get_option('page_on_front');
|
105 |
+
$opts['post_post_root'] = $this->get_option('page_for_posts');
|
106 |
}
|
107 |
//Upgrading to 4.0
|
108 |
if(version_compare($version, '4.0.0', '<'))
|
259 |
}
|
260 |
}
|
261 |
}
|
262 |
+
//Upgrading to 6.0.0
|
263 |
+
if(version_compare($version, '6.0.0', '<'))
|
264 |
+
{
|
265 |
+
//Loop through all of the post types in the array
|
266 |
+
foreach($wp_post_types as $post_type)
|
267 |
+
{
|
268 |
+
if(isset($this->opt['Spost_' . $post_type->name . '_taxonomy_type']))
|
269 |
+
{
|
270 |
+
$this->opt['Spost_' . $post_type->name . '_hierarchy_type'] = $this->opt['Spost_' . $post_type->name . '_taxonomy_type'];
|
271 |
+
unset($this->opt['Spost_' . $post_type->name . '_taxonomy_type']);
|
272 |
+
}
|
273 |
+
if(isset($this->opt['Spost_' . $post_type->name . '_taxonomy_display']))
|
274 |
+
{
|
275 |
+
$this->opt['Spost_' . $post_type->name . '_hierarchy_display'] = $this->opt['Spost_' . $post_type->name . '_taxonomy_display'];
|
276 |
+
unset($this->opt['Spost_' . $post_type->name . '_taxonomy_display']);
|
277 |
+
}
|
278 |
+
}
|
279 |
+
}
|
280 |
//Set the max title length to 20 if we are not limiting the title and the length was 0
|
281 |
if(!$opts['blimit_title'] && $opts['amax_title_length'] == 0)
|
282 |
{
|
311 |
//Add contextual help on current screen
|
312 |
if($screen->id == 'settings_page_' . $this->identifier)
|
313 |
{
|
314 |
+
$general_tab = '<p>' . esc_html__('Tips for the settings are located below select options.', 'breadcrumb-navxt') .
|
315 |
+
'</p><h5>' . esc_html__('Resources', 'breadcrumb-navxt') . '</h5><ul><li>' .
|
316 |
+
sprintf(esc_html__("%sTutorials and How Tos%s: There are several guides, tutorials, and how tos available on the author's website.", 'breadcrumb-navxt'),'<a title="' . esc_attr__('Go to the Breadcrumb NavXT tag archive.', 'breadcrumb-navxt') . '" href="https://mtekk.us/archives/tag/breadcrumb-navxt">', '</a>') . '</li><li>' .
|
317 |
+
sprintf(esc_html__('%sOnline Documentation%s: Check out the documentation for more indepth technical information.', 'breadcrumb-navxt'), '<a title="' . esc_attr__('Go to the Breadcrumb NavXT online documentation', 'breadcrumb-navxt') . '" href="https://mtekk.us/code/breadcrumb-navxt/breadcrumb-navxt-doc/">', '</a>') . '</li><li>' .
|
318 |
+
sprintf(esc_html__('%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="' . esc_attr__('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>' .
|
319 |
+
'<h5>' . esc_html__('Giving Back', 'breadcrumb-navxt') . '</h5><ul><li>' .
|
320 |
+
sprintf(esc_html__('%sDonate%s: Love Breadcrumb NavXT and want to help development? Consider buying the author a beer.', 'breadcrumb-navxt'),'<a title="' . esc_attr__('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>' .
|
321 |
+
sprintf(esc_html__('%sTranslate%s: Is your language not available? Visit the Breadcrumb NavXT translation project on WordPress.org to start translating.', 'breadcrumb-navxt'),'<a title="' . esc_attr__('Go to the Breadcrumb NavXT translation project.', 'breadcrumb-navxt') . '" href="https://translate.wordpress.org/projects/wp-plugins/breadcrumb-navxt">', '</a>') . '</li></ul>';
|
322 |
|
323 |
$screen->add_help_tab(
|
324 |
array(
|
326 |
'title' => __('General', 'breadcrumb-navxt'),
|
327 |
'content' => $general_tab
|
328 |
));
|
329 |
+
$quickstart_tab = '<p>' . 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') .
|
330 |
+
'</p><h5>' . esc_html__('Breadcrumb trail with separators', 'breadcrumb-navxt') . '</h5><pre><code><div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">' . "
|
331 |
<?php if(function_exists('bcn_display'))
|
332 |
{
|
333 |
bcn_display();
|
334 |
}?>
|
335 |
</div></code></pre>" .
|
336 |
+
'<h5>' . esc_html__('Breadcrumb trail in list form', 'breadcrumb-navxt').'</h5><pre><code><ol class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">'."
|
337 |
<?php if(function_exists('bcn_display_list'))
|
338 |
{
|
339 |
bcn_display_list();
|
345 |
'title' => __('Quick Start', 'breadcrumb-navxt'),
|
346 |
'content' => $quickstart_tab
|
347 |
));
|
348 |
+
$styling_tab = '<p>' . 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') . '</p>' .
|
349 |
'<pre><code>.breadcrumbs
|
350 |
{
|
351 |
font-size: 1.1em;
|
407 |
}
|
408 |
else if(defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK)
|
409 |
{
|
410 |
+
$this->messages[] = new mtekk_adminKit_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');
|
411 |
}
|
412 |
else if(defined('BCN_SETTINGS_FAVOR_LOCAL') && BCN_SETTINGS_FAVOR_LOCAL)
|
413 |
{
|
414 |
+
$this->messages[] = new mtekk_adminKit_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');
|
415 |
}
|
416 |
else if(defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK)
|
417 |
{
|
418 |
+
$this->messages[] = new mtekk_adminKit_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');
|
419 |
}
|
420 |
//Fall through if no settings mode was set
|
421 |
else
|
422 |
{
|
423 |
+
$this->messages[] = new mtekk_adminKit_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');
|
424 |
}
|
425 |
}
|
426 |
}
|
432 |
//We're deprecating the limit title length setting, let the user know the new method of accomplishing this
|
433 |
if(isset($this->opt['blimit_title']) && $this->opt['blimit_title'])
|
434 |
{
|
435 |
+
$this->messages[] = new mtekk_adminKit_message(sprintf(esc_html__('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>'), 'warning');
|
436 |
}
|
437 |
}
|
438 |
+
/**
|
439 |
+
* Function checks the current site to see if the blog options should be disabled
|
440 |
+
*
|
441 |
+
* @return boool Whether or not the blog options should be disabled
|
442 |
+
*/
|
443 |
+
function maybe_disable_blog_options()
|
444 |
+
{
|
445 |
+
return (get_option('show_on_front') !== 'page' || get_option('page_for_posts') < 1);
|
446 |
+
}
|
447 |
+
/**
|
448 |
+
* Function checks the current site to see if the mainsite options should be disabled
|
449 |
+
*
|
450 |
+
* @return bool Whether or not the mainsite options should be disabled
|
451 |
+
*/
|
452 |
+
function maybe_disable_mainsite_options()
|
453 |
+
{
|
454 |
+
return !is_multisite();
|
455 |
+
}
|
456 |
/**
|
457 |
* The administrative page for Breadcrumb NavXT
|
458 |
*/
|
471 |
<div class="wrap"><h2><?php echo $this->full_name; ?></h2>
|
472 |
<?php
|
473 |
//We exit after the version check if there is an action the user needs to take before saving settings
|
474 |
+
if(!$this->version_check($this->get_option($this->unique_prefix . '_version')))
|
475 |
{
|
476 |
return;
|
477 |
}
|
489 |
?>
|
490 |
</table>
|
491 |
<h3><?php _e('Current Item', 'breadcrumb-navxt'); ?></h3>
|
492 |
+
<table class="form-table adminkit-enset-top">
|
493 |
<?php
|
494 |
$this->input_check(__('Link Current Item', 'breadcrumb-navxt'), 'bcurrent_item_linked', __('Yes', 'breadcrumb-navxt'));
|
495 |
+
$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'), 'adminkit-enset-ctrl adminkit-enset');
|
496 |
+
$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 adminkit-enset', false, __('The template for paged breadcrumbs.', 'breadcrumb-navxt'));
|
497 |
do_action($this->unique_prefix . '_settings_current_item', $this->opt);
|
498 |
?>
|
499 |
</table>
|
500 |
<h3><?php _e('Home Breadcrumb', 'breadcrumb-navxt'); ?></h3>
|
501 |
+
<table class="form-table adminkit-enset-top">
|
502 |
<?php
|
503 |
+
$this->input_check(__('Home Breadcrumb', 'breadcrumb-navxt'), 'bhome_display', __('Place the home breadcrumb in the trail.', 'breadcrumb-navxt'), false, '', 'adminkit-enset-ctrl adminkit-enset');
|
504 |
+
$this->textbox(__('Home Template', 'breadcrumb-navxt'), 'Hhome_template', '6', false, __('The template for the home breadcrumb.', 'breadcrumb-navxt'), 'adminkit-enset');
|
505 |
+
$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'), 'adminkit-enset');
|
506 |
do_action($this->unique_prefix . '_settings_home', $this->opt);
|
507 |
?>
|
508 |
</table>
|
509 |
<h3><?php _e('Blog Breadcrumb', 'breadcrumb-navxt'); ?></h3>
|
510 |
+
<table class="form-table adminkit-enset-top">
|
511 |
<?php
|
512 |
+
$this->input_check(__('Blog Breadcrumb', 'breadcrumb-navxt'), 'bblog_display', __('Place the blog breadcrumb in the trail.', 'breadcrumb-navxt'), $this->maybe_disable_blog_options(), '', 'adminkit-enset-ctrl adminkit-enset');
|
513 |
+
$this->textbox(__('Blog Template', 'breadcrumb-navxt'), 'Hblog_template', '6', $this->maybe_disable_blog_options(), __('The template for the blog breadcrumb, used only in static front page environments.', 'breadcrumb-navxt'), 'adminkit-enset');
|
514 |
+
$this->textbox(__('Blog Template (Unlinked)', 'breadcrumb-navxt'), 'Hblog_template_no_anchor', '4', $this->maybe_disable_blog_options(), __('The template for the blog breadcrumb, used only in static front page environments and when the breadcrumb is not linked.', 'breadcrumb-navxt'), 'adminkit-enset');
|
515 |
do_action($this->unique_prefix . '_settings_blog', $this->opt);
|
516 |
?>
|
517 |
</table>
|
518 |
<h3><?php _e('Mainsite Breadcrumb', 'breadcrumb-navxt'); ?></h3>
|
519 |
+
<table class="form-table adminkit-enset-top">
|
520 |
<?php
|
521 |
+
$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'), $this->maybe_disable_mainsite_options(), '', 'adminkit-enset-ctrl adminkit-enset');
|
522 |
+
$this->textbox(__('Main Site Home Template', 'breadcrumb-navxt'), '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');
|
523 |
+
$this->textbox(__('Main Site Home Template (Unlinked)', 'breadcrumb-navxt'), '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');
|
524 |
do_action($this->unique_prefix . '_settings_mainsite', $this->opt);
|
525 |
?>
|
526 |
</table>
|
533 |
<?php
|
534 |
$this->textbox(__('Post Template', 'breadcrumb-navxt'), 'Hpost_post_template', '6', false, __('The template for post breadcrumbs.', 'breadcrumb-navxt'));
|
535 |
$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'));
|
536 |
+
$this->input_check(__('Post Hierarchy Display', 'breadcrumb-navxt'), 'bpost_post_hierarchy_display', __('Show the hierarchy (specified below) leading to a post in the breadcrumb trail.', 'breadcrumb-navxt'), false, '', 'adminkit-enset-ctrl adminkit-enset');
|
537 |
$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');
|
538 |
?>
|
539 |
<tr valign="top">
|
542 |
</th>
|
543 |
<td>
|
544 |
<?php
|
545 |
+
$this->input_radio('Spost_post_hierarchy_type', 'category', __('Categories'), false, 'adminkit-enset');
|
546 |
+
$this->input_radio('Spost_post_hierarchy_type', 'BCN_DATE', __('Dates', 'breadcrumb-navxt'), false, 'adminkit-enset');
|
547 |
+
$this->input_radio('Spost_post_hierarchy_type', 'post_tag', __('Tags'), false, 'adminkit-enset');
|
548 |
//We use the value 'page' but really, this will follow the parent post hierarchy
|
549 |
+
$this->input_radio('Spost_post_hierarchy_type', 'BCN_POST_PARENT', __('Post Parent', 'breadcrumb-navxt'), false, 'adminkit-enset');
|
550 |
//Loop through all of the taxonomies in the array
|
551 |
foreach($wp_taxonomies as $taxonomy)
|
552 |
{
|
553 |
//Check for non-public taxonomies
|
554 |
+
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name, 'post'))
|
555 |
{
|
556 |
continue;
|
557 |
}
|
558 |
//We only want custom taxonomies
|
559 |
if(($taxonomy->object_type == 'post' || is_array($taxonomy->object_type) && in_array('post', $taxonomy->object_type)) && !$taxonomy->_builtin)
|
560 |
{
|
561 |
+
$this->input_radio('Spost_post_hierarchy_type', $taxonomy->name, mb_convert_case($taxonomy->label, MB_CASE_TITLE, 'UTF-8'), false, 'adminkit-enset');
|
562 |
}
|
563 |
}
|
564 |
?>
|
565 |
+
<p class="description"><?php 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'); ?></p>
|
566 |
</td>
|
567 |
</tr>
|
568 |
</table>
|
571 |
<?php
|
572 |
$this->textbox(__('Page Template', 'breadcrumb-navxt'), 'Hpost_page_template', '6', false, __('The template for page breadcrumbs.', 'breadcrumb-navxt'));
|
573 |
$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'));
|
574 |
+
$this->input_hidden('bpost_page_hierarchy_display');
|
575 |
+
$this->input_hidden('Spost_page_hierarchy_type');
|
576 |
?>
|
577 |
</table>
|
578 |
<h3><?php _e('Attachments', 'breadcrumb-navxt'); ?></h3>
|
601 |
<?php
|
602 |
$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));
|
603 |
$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));
|
604 |
+
$optid = mtekk_adminKit::get_valid_id('apost_' . $post_type->name . '_root');
|
605 |
?>
|
606 |
<tr valign="top">
|
607 |
<th scope="row">
|
608 |
+
<label for="<?php echo $optid;?>"><?php printf(esc_html__('%s Root Page', 'breadcrumb-navxt'), $post_type->labels->singular_name);?></label>
|
609 |
</th>
|
610 |
<td>
|
611 |
<?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']));?>
|
613 |
</tr>
|
614 |
<?php
|
615 |
$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);
|
616 |
+
$this->input_check(sprintf(__('%s Hierarchy Display', 'breadcrumb-navxt'), $post_type->labels->singular_name), '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');
|
617 |
$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');
|
618 |
?>
|
619 |
<tr valign="top">
|
623 |
<td>
|
624 |
<?php
|
625 |
//We use the value 'page' but really, this will follow the parent post hierarchy
|
626 |
+
$this->input_radio('Spost_' . $post_type->name . '_hierarchy_type', 'BCN_POST_PARENT', __('Post Parent', 'breadcrumb-navxt'), false, 'adminkit-enset');
|
627 |
+
$this->input_radio('Spost_' . $post_type->name . '_hierarchy_type', 'BCN_DATE', __('Dates', 'breadcrumb-navxt'), false, 'adminkit-enset');
|
628 |
//Loop through all of the taxonomies in the array
|
629 |
foreach($wp_taxonomies as $taxonomy)
|
630 |
{
|
631 |
//Check for non-public taxonomies
|
632 |
+
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name, $post_type->name))
|
633 |
{
|
634 |
continue;
|
635 |
}
|
636 |
//We only want custom taxonomies
|
637 |
if($taxonomy->object_type == $post_type->name || in_array($post_type->name, $taxonomy->object_type))
|
638 |
{
|
639 |
+
$this->input_radio('Spost_' . $post_type->name . '_hierarchy_type', $taxonomy->name, $taxonomy->labels->singular_name, false, 'adminkit-enset');
|
640 |
}
|
641 |
}
|
642 |
?>
|
644 |
<?php
|
645 |
if($post_type->hierarchical)
|
646 |
{
|
647 |
+
esc_html_e('The hierarchy which the breadcrumb trail will show.', 'breadcrumb-navxt');
|
648 |
}
|
649 |
else
|
650 |
{
|
651 |
+
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');
|
652 |
}
|
653 |
?>
|
654 |
</p>
|
689 |
foreach($wp_taxonomies as $taxonomy)
|
690 |
{
|
691 |
//Check for non-public taxonomies
|
692 |
+
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name, null))
|
693 |
{
|
694 |
continue;
|
695 |
}
|
735 |
<table class="form-table">
|
736 |
<tr valign="top">
|
737 |
<th scope="row">
|
738 |
+
<?php esc_html_e('Title Length', 'breadcrumb-navxt'); ?>
|
739 |
</th>
|
740 |
<td>
|
741 |
<label>
|
742 |
<input name="bcn_options[blimit_title]" type="checkbox" id="blimit_title" value="true" <?php checked(true, $this->opt['blimit_title']); ?> />
|
743 |
+
<?php printf(esc_html__('Limit the length of the breadcrumb title. (Deprecated, %suse CSS instead%s)', 'breadcrumb-navxt'), '<a title="' . esc_attr__('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>');?>
|
744 |
</label><br />
|
745 |
<ul>
|
746 |
<li>
|
747 |
<label for="amax_title_length">
|
748 |
+
<?php esc_html_e('Max Title Length: ','breadcrumb-navxt');?>
|
749 |
<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" />
|
750 |
</label>
|
751 |
</li>
|
class.bcn_breadcrumb.php
CHANGED
@@ -21,7 +21,7 @@ require_once(dirname(__FILE__) . '/includes/block_direct_access.php');
|
|
21 |
class bcn_breadcrumb
|
22 |
{
|
23 |
//Our member variables
|
24 |
-
const version = '
|
25 |
//The main text that will be shown
|
26 |
protected $title;
|
27 |
//The breadcrumb's template, used durring assembly
|
@@ -33,21 +33,21 @@ class bcn_breadcrumb
|
|
33 |
//The link the breadcrumb leads to, null if $linked == false
|
34 |
protected $url;
|
35 |
//The corresponding resource ID
|
36 |
-
protected $id =
|
37 |
-
private $_title =
|
38 |
//The type of this breadcrumb
|
39 |
protected $type;
|
40 |
protected $allowed_html = array();
|
41 |
const default_template_no_anchor = '<span property="itemListElement" typeof="ListItem"><span property="name">%htitle%</span><meta property="position" content="%position%"></span>';
|
42 |
/**
|
43 |
* The enhanced default constructor, ends up setting all parameters via the set_ functions
|
44 |
-
*
|
45 |
* @param string $title (optional) The title of the breadcrumb
|
46 |
* @param string $template (optional) The html template for the breadcrumb
|
47 |
* @param string $type (optional) The breadcrumb type
|
48 |
* @param string $url (optional) The url the breadcrumb links to
|
49 |
*/
|
50 |
-
public function __construct($title = '', $template = '', array $type = array(), $url = '', $id =
|
51 |
{
|
52 |
//Filter allowed_html array to allow others to add acceptable tags
|
53 |
$this->allowed_html = apply_filters('bcn_allowed_html', wp_kses_allowed_html('post'));
|
@@ -60,15 +60,15 @@ class bcn_breadcrumb
|
|
60 |
//Set the default anchorless templates value
|
61 |
$this->template_no_anchor = bcn_breadcrumb::default_template_no_anchor;
|
62 |
//If we didn't get a good template, use a default template
|
63 |
-
if($template ==
|
64 |
{
|
65 |
$this->set_template(bcn_breadcrumb::get_default_template());
|
66 |
}
|
67 |
//If something was passed in template wise, update the appropriate internal template
|
68 |
else
|
69 |
{
|
70 |
-
//Loose comparison, evaluates to true if URL is '' or
|
71 |
-
if($url ==
|
72 |
{
|
73 |
$this->template_no_anchor = wp_kses(apply_filters('bcn_breadcrumb_template_no_anchor', $template, $this->type, $this->id), $this->allowed_html);
|
74 |
$this->set_template(bcn_breadcrumb::get_default_template());
|
@@ -78,12 +78,12 @@ class bcn_breadcrumb
|
|
78 |
$this->set_template($template);
|
79 |
}
|
80 |
}
|
81 |
-
//Always
|
82 |
$this->set_url($url);
|
83 |
}
|
84 |
/**
|
85 |
* Function to return the translated default template
|
86 |
-
*
|
87 |
* @return string The default breadcrumb template
|
88 |
*/
|
89 |
static public function get_default_template()
|
@@ -92,7 +92,7 @@ class bcn_breadcrumb
|
|
92 |
}
|
93 |
/**
|
94 |
* Function to set the protected title member
|
95 |
-
*
|
96 |
* @param string $title The title of the breadcrumb
|
97 |
*/
|
98 |
public function set_title($title)
|
@@ -103,7 +103,7 @@ class bcn_breadcrumb
|
|
103 |
}
|
104 |
/**
|
105 |
* Function to get the protected title member
|
106 |
-
*
|
107 |
* @return $this->title
|
108 |
*/
|
109 |
public function get_title()
|
@@ -113,14 +113,14 @@ class bcn_breadcrumb
|
|
113 |
}
|
114 |
/**
|
115 |
* Function to set the internal URL variable
|
116 |
-
*
|
117 |
* @param string $url the url to link to
|
118 |
*/
|
119 |
public function set_url($url)
|
120 |
{
|
121 |
$this->url = apply_filters('bcn_breadcrumb_url', $url, $this->type, $this->id);
|
122 |
//If the URL seemed nullish, we are not linked
|
123 |
-
if($this->url ==
|
124 |
{
|
125 |
$this->linked = false;
|
126 |
}
|
@@ -131,7 +131,7 @@ class bcn_breadcrumb
|
|
131 |
}
|
132 |
/**
|
133 |
* Function to set the internal breadcrumb template
|
134 |
-
*
|
135 |
* @param string $template the template to use durring assebly
|
136 |
*/
|
137 |
public function set_template($template)
|
@@ -159,7 +159,7 @@ class bcn_breadcrumb
|
|
159 |
}
|
160 |
/**
|
161 |
* Append a type entry to the type array
|
162 |
-
*
|
163 |
* @param string $type the type to append
|
164 |
*/
|
165 |
public function add_type($type)
|
@@ -168,7 +168,7 @@ class bcn_breadcrumb
|
|
168 |
}
|
169 |
/**
|
170 |
* Return the type array
|
171 |
-
*
|
172 |
* @return array The type array
|
173 |
*/
|
174 |
public function get_types()
|
@@ -177,7 +177,7 @@ class bcn_breadcrumb
|
|
177 |
}
|
178 |
/**
|
179 |
* This function will intelligently trim the title to the value passed in through $max_length. This function is deprecated, do not call.
|
180 |
-
*
|
181 |
* @param int $max_length of the title.
|
182 |
* @deprecated since 5.2.0
|
183 |
*/
|
@@ -192,7 +192,7 @@ class bcn_breadcrumb
|
|
192 |
{
|
193 |
//Trim the title
|
194 |
$this->title = mb_substr($this->title, 0, $max_length - 1);
|
195 |
-
//Make sure we can split
|
196 |
if(mb_strpos($this->title, ' ', .75 * $max_length) > 0)
|
197 |
{
|
198 |
//Don't split mid word
|
@@ -205,14 +205,14 @@ class bcn_breadcrumb
|
|
205 |
$this->title = rtrim($this->title) . html_entity_decode('…', ENT_COMPAT, 'UTF-8');
|
206 |
}
|
207 |
//Return to the encoded version of all HTML entities (keep standards complance)
|
208 |
-
$this->title = htmlentities($this->title, ENT_COMPAT, 'UTF-8');
|
209 |
}
|
210 |
/**
|
211 |
* Assembles the parts of the breadcrumb into a html string
|
212 |
-
*
|
213 |
* @param bool $linked Allow the output to contain anchors?
|
214 |
* @param int $position The position of the breadcrumb in the trail (between 1 and n when there are n breadcrumbs in the trail)
|
215 |
-
*
|
216 |
* @return string The compiled breadcrumb string
|
217 |
*/
|
218 |
public function assemble($linked, $position)
|
@@ -248,9 +248,9 @@ class bcn_breadcrumb
|
|
248 |
}
|
249 |
/**
|
250 |
* Assembles the parts of the breadcrumb into a JSON-LD ready object-array
|
251 |
-
*
|
252 |
* @param int $position The position of the breadcrumb in the trail (between 1 and n when there are n breadcrumbs in the trail)
|
253 |
-
*
|
254 |
* @return array(object) The prepared array object ready to pass into json_encode
|
255 |
*/
|
256 |
public function assemble_json_ld($position)
|
21 |
class bcn_breadcrumb
|
22 |
{
|
23 |
//Our member variables
|
24 |
+
const version = '6.0.0';
|
25 |
//The main text that will be shown
|
26 |
protected $title;
|
27 |
//The breadcrumb's template, used durring assembly
|
33 |
//The link the breadcrumb leads to, null if $linked == false
|
34 |
protected $url;
|
35 |
//The corresponding resource ID
|
36 |
+
protected $id = null;
|
37 |
+
private $_title = null;
|
38 |
//The type of this breadcrumb
|
39 |
protected $type;
|
40 |
protected $allowed_html = array();
|
41 |
const default_template_no_anchor = '<span property="itemListElement" typeof="ListItem"><span property="name">%htitle%</span><meta property="position" content="%position%"></span>';
|
42 |
/**
|
43 |
* The enhanced default constructor, ends up setting all parameters via the set_ functions
|
44 |
+
*
|
45 |
* @param string $title (optional) The title of the breadcrumb
|
46 |
* @param string $template (optional) The html template for the breadcrumb
|
47 |
* @param string $type (optional) The breadcrumb type
|
48 |
* @param string $url (optional) The url the breadcrumb links to
|
49 |
*/
|
50 |
+
public function __construct($title = '', $template = '', array $type = array(), $url = '', $id = null)
|
51 |
{
|
52 |
//Filter allowed_html array to allow others to add acceptable tags
|
53 |
$this->allowed_html = apply_filters('bcn_allowed_html', wp_kses_allowed_html('post'));
|
60 |
//Set the default anchorless templates value
|
61 |
$this->template_no_anchor = bcn_breadcrumb::default_template_no_anchor;
|
62 |
//If we didn't get a good template, use a default template
|
63 |
+
if($template == null)
|
64 |
{
|
65 |
$this->set_template(bcn_breadcrumb::get_default_template());
|
66 |
}
|
67 |
//If something was passed in template wise, update the appropriate internal template
|
68 |
else
|
69 |
{
|
70 |
+
//Loose comparison, evaluates to true if URL is '' or null
|
71 |
+
if($url == null)
|
72 |
{
|
73 |
$this->template_no_anchor = wp_kses(apply_filters('bcn_breadcrumb_template_no_anchor', $template, $this->type, $this->id), $this->allowed_html);
|
74 |
$this->set_template(bcn_breadcrumb::get_default_template());
|
78 |
$this->set_template($template);
|
79 |
}
|
80 |
}
|
81 |
+
//Always null if unlinked
|
82 |
$this->set_url($url);
|
83 |
}
|
84 |
/**
|
85 |
* Function to return the translated default template
|
86 |
+
*
|
87 |
* @return string The default breadcrumb template
|
88 |
*/
|
89 |
static public function get_default_template()
|
92 |
}
|
93 |
/**
|
94 |
* Function to set the protected title member
|
95 |
+
*
|
96 |
* @param string $title The title of the breadcrumb
|
97 |
*/
|
98 |
public function set_title($title)
|
103 |
}
|
104 |
/**
|
105 |
* Function to get the protected title member
|
106 |
+
*
|
107 |
* @return $this->title
|
108 |
*/
|
109 |
public function get_title()
|
113 |
}
|
114 |
/**
|
115 |
* Function to set the internal URL variable
|
116 |
+
*
|
117 |
* @param string $url the url to link to
|
118 |
*/
|
119 |
public function set_url($url)
|
120 |
{
|
121 |
$this->url = apply_filters('bcn_breadcrumb_url', $url, $this->type, $this->id);
|
122 |
//If the URL seemed nullish, we are not linked
|
123 |
+
if($this->url == null)
|
124 |
{
|
125 |
$this->linked = false;
|
126 |
}
|
131 |
}
|
132 |
/**
|
133 |
* Function to set the internal breadcrumb template
|
134 |
+
*
|
135 |
* @param string $template the template to use durring assebly
|
136 |
*/
|
137 |
public function set_template($template)
|
159 |
}
|
160 |
/**
|
161 |
* Append a type entry to the type array
|
162 |
+
*
|
163 |
* @param string $type the type to append
|
164 |
*/
|
165 |
public function add_type($type)
|
168 |
}
|
169 |
/**
|
170 |
* Return the type array
|
171 |
+
*
|
172 |
* @return array The type array
|
173 |
*/
|
174 |
public function get_types()
|
177 |
}
|
178 |
/**
|
179 |
* This function will intelligently trim the title to the value passed in through $max_length. This function is deprecated, do not call.
|
180 |
+
*
|
181 |
* @param int $max_length of the title.
|
182 |
* @deprecated since 5.2.0
|
183 |
*/
|
192 |
{
|
193 |
//Trim the title
|
194 |
$this->title = mb_substr($this->title, 0, $max_length - 1);
|
195 |
+
//Make sure we can split, but we want to limmit to cutting at max an additional 25%
|
196 |
if(mb_strpos($this->title, ' ', .75 * $max_length) > 0)
|
197 |
{
|
198 |
//Don't split mid word
|
205 |
$this->title = rtrim($this->title) . html_entity_decode('…', ENT_COMPAT, 'UTF-8');
|
206 |
}
|
207 |
//Return to the encoded version of all HTML entities (keep standards complance)
|
208 |
+
$this->title = force_balance_tags(htmlentities($this->title, ENT_COMPAT, 'UTF-8'));
|
209 |
}
|
210 |
/**
|
211 |
* Assembles the parts of the breadcrumb into a html string
|
212 |
+
*
|
213 |
* @param bool $linked Allow the output to contain anchors?
|
214 |
* @param int $position The position of the breadcrumb in the trail (between 1 and n when there are n breadcrumbs in the trail)
|
215 |
+
*
|
216 |
* @return string The compiled breadcrumb string
|
217 |
*/
|
218 |
public function assemble($linked, $position)
|
248 |
}
|
249 |
/**
|
250 |
* Assembles the parts of the breadcrumb into a JSON-LD ready object-array
|
251 |
+
*
|
252 |
* @param int $position The position of the breadcrumb in the trail (between 1 and n when there are n breadcrumbs in the trail)
|
253 |
+
*
|
254 |
* @return array(object) The prepared array object ready to pass into json_encode
|
255 |
*/
|
256 |
public function assemble_json_ld($position)
|
class.bcn_breadcrumb_trail.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
-
Copyright
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
@@ -21,7 +21,7 @@ require_once(dirname(__FILE__) . '/includes/block_direct_access.php');
|
|
21 |
class bcn_breadcrumb_trail
|
22 |
{
|
23 |
//Our member variables
|
24 |
-
const version = '
|
25 |
//An array of breadcrumbs
|
26 |
public $breadcrumbs = array();
|
27 |
public $trail = array();
|
@@ -66,6 +66,10 @@ class bcn_breadcrumb_trail
|
|
66 |
//Current item options
|
67 |
'bcurrent_item_linked' => false,
|
68 |
//Static page options
|
|
|
|
|
|
|
|
|
69 |
//The anchor template for page breadcrumbs
|
70 |
'Hpost_page_template' => bcn_breadcrumb::get_default_template(),
|
71 |
//The anchor template for page breadcrumbs, used when an anchor is not needed
|
@@ -84,12 +88,12 @@ class bcn_breadcrumb_trail
|
|
84 |
'Hpost_post_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor,
|
85 |
//Just a link for the page for posts
|
86 |
'apost_post_root' => get_option('page_for_posts'),
|
87 |
-
//Should the trail include the
|
88 |
-
'
|
89 |
//Should the trail reflect the referer taxonomy or not
|
90 |
'bpost_post_taxonomy_referer' => false,
|
91 |
-
//What
|
92 |
-
'
|
93 |
//Attachment settings
|
94 |
//The breadcrumb template for attachment breadcrumbs
|
95 |
'Hpost_attachment_template' => bcn_breadcrumb::get_default_template(),
|
@@ -135,6 +139,8 @@ class bcn_breadcrumb_trail
|
|
135 |
}
|
136 |
/**
|
137 |
* This returns the internal version
|
|
|
|
|
138 |
*
|
139 |
* @return string internal version of the Breadcrumb trail
|
140 |
*/
|
@@ -147,6 +153,7 @@ class bcn_breadcrumb_trail
|
|
147 |
* Adds a breadcrumb to the breadcrumb trail
|
148 |
*
|
149 |
* @param bcn_breadcrumb $object Breadcrumb to add to the trail
|
|
|
150 |
* @return pointer to the just added Breadcrumb
|
151 |
*/
|
152 |
public function &add(bcn_breadcrumb $object)
|
@@ -158,49 +165,47 @@ class bcn_breadcrumb_trail
|
|
158 |
/**
|
159 |
* A Breadcrumb Trail Filling Function
|
160 |
*
|
161 |
-
* This functions fills a breadcrumb for a search page
|
|
|
|
|
|
|
162 |
*/
|
163 |
-
protected function do_search()
|
164 |
{
|
165 |
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
166 |
-
$breadcrumb = $this->add(new bcn_breadcrumb(
|
167 |
//If we're paged, or allowing the current item to be linked, let's link to the first page
|
168 |
-
if($this->opt['bcurrent_item_linked'] || (is_paged
|
169 |
{
|
170 |
//Since we are paged and are linking the root breadcrumb, time to change to the regular template
|
171 |
$breadcrumb->set_template($this->opt['Hsearch_template']);
|
172 |
//Figure out the anchor for the search
|
173 |
-
$breadcrumb->set_url(get_search_link());
|
174 |
}
|
175 |
}
|
176 |
/**
|
177 |
* A Breadcrumb Trail Filling Function
|
178 |
*
|
179 |
-
* This functions fills a breadcrumb for an author page
|
|
|
|
|
|
|
180 |
*/
|
181 |
-
protected function do_author()
|
182 |
{
|
183 |
-
if(get_query_var('author_name'))
|
184 |
-
{
|
185 |
-
$authordata = get_user_by('slug', get_query_var('author_name'));
|
186 |
-
}
|
187 |
-
else
|
188 |
-
{
|
189 |
-
$authordata = get_userdata(get_query_var('author'));
|
190 |
-
}
|
191 |
//Setup array of valid author_name values
|
192 |
$valid_author_name = array('display_name', 'nickname', 'first_name', 'last_name');
|
193 |
//Make sure user picks only safe values
|
194 |
if(in_array($this->opt['Sauthor_name'], $valid_author_name))
|
195 |
{
|
196 |
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
197 |
-
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_author_meta($this->opt['Sauthor_name'], $
|
198 |
//If we're paged, or allowing the current item to be linked, let's link to the first page
|
199 |
-
if($this->opt['bcurrent_item_linked'] || (is_paged
|
200 |
{
|
201 |
//Set the template to our one containing an anchor
|
202 |
$breadcrumb->set_template($this->opt['Hauthor_template']);
|
203 |
-
$breadcrumb->set_url(get_author_posts_url($
|
204 |
}
|
205 |
}
|
206 |
}
|
@@ -208,6 +213,7 @@ class bcn_breadcrumb_trail
|
|
208 |
* Determines the taxonomy name represented by the specified query var
|
209 |
*
|
210 |
* @param string $query_var The query var to attempt to find the corresponding taxonomy
|
|
|
211 |
* @return string|bool Either the name of the taxonomy corresponding to the query_var or false if no taxonomy exists for the specified query_var
|
212 |
*/
|
213 |
protected function query_var_to_taxonomy($query_var)
|
@@ -267,6 +273,7 @@ class bcn_breadcrumb_trail
|
|
267 |
* @param int $id The ID of the post to find the term for
|
268 |
* @param string $type The post type of the post to figure out the taxonomy for
|
269 |
* @param string $taxonomy The taxonomy to use
|
|
|
270 |
* @return WP_Term|bool The term object to use for the post hierarchy or false if no suitable term was found
|
271 |
*/
|
272 |
protected function pick_post_term($id, $type, $taxonomy)
|
@@ -296,26 +303,28 @@ class bcn_breadcrumb_trail
|
|
296 |
* A Breadcrumb Trail Filling Function
|
297 |
*
|
298 |
* This function fills breadcrumbs for any post taxonomy
|
|
|
299 |
* @param int $id The id of the post to figure out the taxonomy for
|
300 |
* @param string $type The post type of the post to figure out the taxonomy for
|
301 |
* @param int $parent (optional) The id of the parent of the current post, used if hiearchal posts will be the "taxonomy" for the current post
|
302 |
*/
|
303 |
-
protected function post_hierarchy($id, $type, $parent =
|
304 |
{
|
305 |
-
//Check to see if breadcrumbs for the
|
306 |
-
if($this->opt['bpost_' . $type . '
|
307 |
{
|
308 |
-
//TODO: Remove deprecated type selection
|
309 |
//Check if we have a date 'taxonomy' request
|
310 |
-
if($this->opt['Spost_' . $type . '
|
311 |
{
|
312 |
-
$
|
|
|
|
|
|
|
313 |
}
|
314 |
-
//TODO: Remove deprecated type selection
|
315 |
//Handle the use of hierarchical posts as the 'taxonomy'
|
316 |
-
else if($this->opt['Spost_' . $type . '
|
317 |
{
|
318 |
-
if($parent ==
|
319 |
{
|
320 |
//We have to grab the post to find its parent, can't use $post for this one
|
321 |
$parent = get_post($id);
|
@@ -323,16 +332,16 @@ class bcn_breadcrumb_trail
|
|
323 |
$parent = $parent->post_parent;
|
324 |
}
|
325 |
//Grab the frontpage, we'll need it shortly
|
326 |
-
$
|
327 |
//If there is a parent page let's find it
|
328 |
-
if($parent && $id != $parent && $
|
329 |
{
|
330 |
-
$parent = $this->post_parents($parent, $
|
331 |
}
|
332 |
}
|
333 |
else
|
334 |
{
|
335 |
-
$taxonomy = $this->opt['Spost_' . $type . '
|
336 |
//Possibly let the referer influence the taxonomy used
|
337 |
if($this->opt['bpost_' . $type . '_taxonomy_referer'] && $referrer_taxonomy = $this->determine_taxonomy())
|
338 |
{
|
@@ -368,12 +377,13 @@ class bcn_breadcrumb_trail
|
|
368 |
$parent = get_post($id);
|
369 |
}
|
370 |
//Finish off with trying to find the type archive
|
371 |
-
$this->type_archive($parent);
|
372 |
}
|
373 |
/**
|
374 |
* A Breadcrumb Trail Filling Function
|
375 |
*
|
376 |
* This functions fills a breadcrumb for the terms of a post
|
|
|
377 |
* @param int $id The id of the post to find the terms for
|
378 |
* @param string $taxonomy The name of the taxonomy that the term belongs to
|
379 |
*
|
@@ -399,20 +409,22 @@ class bcn_breadcrumb_trail
|
|
399 |
//This is a bit hackish, but it compiles the term anchor and appends it to the current breadcrumb title
|
400 |
$title .= str_replace(
|
401 |
array('%title%', '%link%', '%htitle%', '%type%'),
|
402 |
-
array($term->name, $this->maybe_add_post_type_arg(get_term_link($term),
|
403 |
$this->opt['Htax_' . $term->taxonomy . '_template']);
|
404 |
$is_first = false;
|
405 |
}
|
406 |
//Place the breadcrumb in the trail, uses the constructor to set the title, template, and type, get a pointer to it in return
|
407 |
-
$breadcrumb = $this->add(new bcn_breadcrumb($title,
|
408 |
}
|
409 |
}
|
410 |
/**
|
411 |
* A Breadcrumb Trail Filling Function
|
412 |
*
|
413 |
-
* This recursive functions fills the trail with breadcrumbs for parent terms
|
414 |
-
*
|
|
|
415 |
* @param string $taxonomy The name of the taxonomy that the term belongs to
|
|
|
416 |
* @return WP_Term The term we stopped at
|
417 |
*/
|
418 |
protected function term_parents($id, $taxonomy)
|
@@ -420,7 +432,7 @@ class bcn_breadcrumb_trail
|
|
420 |
//Get the current category object, filter applied within this call
|
421 |
$term = get_term($id, $taxonomy);
|
422 |
//Place the breadcrumb in the trail, uses the constructor to set the title, template, and type, get a pointer to it in return
|
423 |
-
$breadcrumb = $this->add(new bcn_breadcrumb($term->name, $this->opt['Htax_' . $taxonomy . '_template'], array('taxonomy', $taxonomy), $this->maybe_add_post_type_arg(get_term_link($term),
|
424 |
//Make sure the id is valid, and that we won't end up spinning in a loop
|
425 |
if($term->parent && $term->parent != $id)
|
426 |
{
|
@@ -432,9 +444,11 @@ class bcn_breadcrumb_trail
|
|
432 |
/**
|
433 |
* A Breadcrumb Trail Filling Function
|
434 |
*
|
435 |
-
* This recursive functions fills the trail with breadcrumbs for parent posts/pages
|
436 |
-
*
|
437 |
-
* @param int $
|
|
|
|
|
438 |
* @return WP_Post The parent we stopped at
|
439 |
*/
|
440 |
protected function post_parents($id, $frontpage)
|
@@ -456,9 +470,12 @@ class bcn_breadcrumb_trail
|
|
456 |
*
|
457 |
* This functions fills a breadcrumb for posts
|
458 |
*
|
459 |
-
* @param $post
|
|
|
|
|
|
|
460 |
*/
|
461 |
-
protected function do_post($post)
|
462 |
{
|
463 |
//If we did not get a WP_Post object, warn developer and return early
|
464 |
if(!($post instanceof WP_Post))
|
@@ -467,24 +484,31 @@ class bcn_breadcrumb_trail
|
|
467 |
return;
|
468 |
}
|
469 |
//Place the breadcrumb in the trail, uses the bcn_breadcrumb constructor to set the title, template, and type
|
470 |
-
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_title($post), $this->opt['Hpost_' . $post->post_type . '_template_no_anchor'], array('post', 'post-' . $post->post_type
|
471 |
-
|
472 |
-
|
|
|
|
|
|
|
|
|
473 |
{
|
474 |
//Change the template over to the normal, linked one
|
475 |
$breadcrumb->set_template($this->opt['Hpost_' . $post->post_type . '_template']);
|
476 |
//Add the link
|
477 |
$breadcrumb->set_url(get_permalink($post));
|
478 |
}
|
479 |
-
//If we have
|
480 |
-
if($post->post_type === '
|
481 |
{
|
482 |
//Done with the current item, now on to the parents
|
483 |
$frontpage = get_option('page_on_front');
|
484 |
-
//
|
485 |
-
if($post->post_parent && $post->ID != $post->post_parent && $frontpage != $post->post_parent)
|
486 |
{
|
487 |
-
|
|
|
|
|
|
|
488 |
}
|
489 |
}
|
490 |
//Otherwise we need the follow the hiearchy tree
|
@@ -497,49 +521,33 @@ class bcn_breadcrumb_trail
|
|
497 |
/**
|
498 |
* A Breadcrumb Trail Filling Function
|
499 |
*
|
|
|
|
|
500 |
* This functions fills a breadcrumb for an attachment page.
|
501 |
*/
|
502 |
protected function do_attachment()
|
503 |
{
|
504 |
-
|
505 |
-
|
506 |
-
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_title(), $this->opt['Hpost_attachment_template_no_anchor'], array('post', 'post-attachment', 'current-item'), NULL, $post->ID));
|
507 |
-
if($this->opt['bcurrent_item_linked'])
|
508 |
-
{
|
509 |
-
//Change the template over to the normal, linked one
|
510 |
-
$breadcrumb->set_template($this->opt['Hpost_attachment_template']);
|
511 |
-
//Add the link
|
512 |
-
$breadcrumb->set_url(get_permalink());
|
513 |
-
}
|
514 |
-
//Done with the current item, now on to the parents
|
515 |
-
$frontpage = get_option('page_on_front');
|
516 |
-
//Make sure the id is valid, and that we won't end up spinning in a loop
|
517 |
-
if($post->post_parent >= 0 && $post->post_parent != false && $post->ID != $post->post_parent && $frontpage != $post->post_parent)
|
518 |
-
{
|
519 |
-
//Get the parent's information
|
520 |
-
$parent = get_post($post->post_parent);
|
521 |
-
//Take care of the parent's breadcrumb
|
522 |
-
$this->do_post($parent);
|
523 |
-
}
|
524 |
}
|
525 |
/**
|
526 |
* A Breadcrumb Trail Filling Function
|
527 |
*
|
528 |
* This function fills a breadcrumb for any taxonomy archive, was previously two separate functions
|
|
|
|
|
|
|
529 |
*/
|
530 |
-
protected function do_archive_by_term()
|
531 |
{
|
532 |
-
global $wp_query;
|
533 |
-
//Simmilar to using $post, but for things $post doesn't cover
|
534 |
-
$term = $wp_query->get_queried_object();
|
535 |
//Place the breadcrumb in the trail, uses the constructor to set the title, template, and type, get a pointer to it in return
|
536 |
-
$breadcrumb = $this->add(new bcn_breadcrumb($term->name, $this->opt['Htax_' . $term->taxonomy . '_template_no_anchor'], array('archive', 'taxonomy', $term->taxonomy, 'current-item'),
|
537 |
//If we're paged, let's link to the first page
|
538 |
-
if($this->opt['bcurrent_item_linked'] || (is_paged
|
539 |
{
|
540 |
$breadcrumb->set_template($this->opt['Htax_' . $term->taxonomy . '_template']);
|
541 |
//Figure out the anchor for current category
|
542 |
-
$breadcrumb->set_url($this->maybe_add_post_type_arg(get_term_link($term),
|
543 |
}
|
544 |
//Get parents of current term
|
545 |
if($term->parent)
|
@@ -550,62 +558,82 @@ class bcn_breadcrumb_trail
|
|
550 |
/**
|
551 |
* A Breadcrumb Trail Filling Function
|
552 |
*
|
553 |
-
* This functions fills a breadcrumb for
|
554 |
*
|
555 |
-
* @param
|
|
|
|
|
|
|
556 |
*/
|
557 |
-
protected function
|
558 |
{
|
559 |
-
|
560 |
-
|
561 |
-
|
|
|
562 |
{
|
563 |
-
|
564 |
-
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_time(_x('d', 'day archive breadcrumb date format', 'breadcrumb-navxt')), $this->opt['Hdate_template_no_anchor'], array('archive', 'date-day')));
|
565 |
-
//If this is a day archive, add current-item type
|
566 |
-
if(is_day())
|
567 |
-
{
|
568 |
-
$breadcrumb->add_type('current-item');
|
569 |
-
}
|
570 |
-
//If we're paged, let's link to the first page
|
571 |
-
if($this->opt['bcurrent_item_linked'] || is_paged() && $this->opt['bpaged_display'] || is_single())
|
572 |
-
{
|
573 |
-
//We're linking, so set the linked template
|
574 |
-
$breadcrumb->set_template($this->opt['Hdate_template']);
|
575 |
-
$url = get_day_link(get_the_time('Y'), get_the_time('m'), get_the_time('d'));
|
576 |
-
//Deal with the anchor
|
577 |
-
$breadcrumb->set_url($this->maybe_add_post_type_arg($url, $type));
|
578 |
-
}
|
579 |
}
|
580 |
-
//
|
581 |
-
if(
|
582 |
{
|
583 |
-
//
|
584 |
-
$breadcrumb
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
591 |
-
|
592 |
-
|
593 |
-
|
594 |
-
|
595 |
-
|
596 |
-
|
597 |
-
|
598 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
599 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
600 |
//Place the year breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
601 |
-
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_time(_x('Y', 'year archive breadcrumb date format', 'breadcrumb-navxt')), $this->opt['Hdate_template_no_anchor'], array('archive', 'date-year')));
|
602 |
//If this is a year archive, add current-item type
|
603 |
-
if(
|
604 |
{
|
605 |
$breadcrumb->add_type('current-item');
|
606 |
}
|
607 |
//If we're paged, or not in the archive by year let's link to the first archive by year page
|
608 |
-
if($this->opt['bcurrent_item_linked']
|
609 |
{
|
610 |
//We're linking, so set the linked template
|
611 |
$breadcrumb->set_template($this->opt['Hdate_template']);
|
@@ -614,17 +642,46 @@ class bcn_breadcrumb_trail
|
|
614 |
$breadcrumb->set_url($this->maybe_add_post_type_arg($url, $type));
|
615 |
}
|
616 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
617 |
/**
|
618 |
* A Breadcrumb Trail Filling Function
|
619 |
*
|
620 |
* This functions fills a breadcrumb for a post type archive (WP 3.1 feature)
|
|
|
|
|
|
|
621 |
*/
|
622 |
-
protected function do_archive_by_post_type()
|
623 |
{
|
624 |
-
|
|
|
|
|
625 |
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
626 |
-
$breadcrumb = $this->add(new bcn_breadcrumb(
|
627 |
-
if($this->opt['bcurrent_item_linked'] || is_paged
|
628 |
{
|
629 |
|
630 |
$breadcrumb->set_template($this->opt['Hpost_' . $type_str . '_template']);
|
@@ -635,17 +692,30 @@ class bcn_breadcrumb_trail
|
|
635 |
/**
|
636 |
* A Breadcrumb Trail Filling Function
|
637 |
*
|
638 |
-
* This functions fills a breadcrumb for the front page
|
|
|
|
|
|
|
|
|
639 |
*/
|
640 |
-
protected function
|
641 |
{
|
642 |
global $current_site;
|
|
|
|
|
|
|
|
|
|
|
643 |
//Get the site name
|
644 |
$site_name = get_option('blogname');
|
645 |
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
646 |
-
$breadcrumb = $this->add(new bcn_breadcrumb($site_name, $this->opt['Hhome_template_no_anchor'], array('home'
|
647 |
-
|
648 |
-
|
|
|
|
|
|
|
|
|
649 |
{
|
650 |
$breadcrumb->set_template($this->opt['Hhome_template']);
|
651 |
//Figure out the anchor for home page
|
@@ -660,35 +730,11 @@ class bcn_breadcrumb_trail
|
|
660 |
$breadcrumb = $this->add(new bcn_breadcrumb($site_name, $this->opt['Hmainsite_template'], array('main-home'), get_home_url($current_site->blog_id)));
|
661 |
}
|
662 |
}
|
663 |
-
/**
|
664 |
-
* A Breadcrumb Trail Filling Function
|
665 |
-
*
|
666 |
-
* This functions fills a breadcrumb for the home page.
|
667 |
-
*/
|
668 |
-
protected function do_home()
|
669 |
-
{
|
670 |
-
global $current_site;
|
671 |
-
//On everything else we need to link, but no current item (pre/suf)fixes
|
672 |
-
if($this->opt['bhome_display'])
|
673 |
-
{
|
674 |
-
//Get the site name
|
675 |
-
$site_name = get_option('blogname');
|
676 |
-
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
677 |
-
$breadcrumb = $this->add(new bcn_breadcrumb($site_name, $this->opt['Hhome_template'], array('home'), get_home_url()));
|
678 |
-
//If we have a multi site and are not on the main site we need to add a breadcrumb for the main site
|
679 |
-
if($this->opt['bmainsite_display'] && !is_main_site())
|
680 |
-
{
|
681 |
-
//Get the site name
|
682 |
-
$site_name = get_site_option('site_name');
|
683 |
-
//Place the main site breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
684 |
-
$breadcrumb = $this->add(new bcn_breadcrumb($site_name, $this->opt['Hmainsite_template'], array('main-home'), get_home_url($current_site->blog_id)));
|
685 |
-
}
|
686 |
-
}
|
687 |
-
}
|
688 |
/**
|
689 |
* A modified version of WordPress' function of the same name
|
690 |
*
|
691 |
* @param object $object the post or taxonomy object used to attempt to find the title
|
|
|
692 |
* @return string the title
|
693 |
*/
|
694 |
protected function post_type_archive_title($object)
|
@@ -704,6 +750,7 @@ class bcn_breadcrumb_trail
|
|
704 |
* Determines if a post type is a built in type or not
|
705 |
*
|
706 |
* @param string $post_type the name of the post type
|
|
|
707 |
* @return bool
|
708 |
*/
|
709 |
protected function is_builtin($post_type)
|
@@ -724,6 +771,8 @@ class bcn_breadcrumb_trail
|
|
724 |
*
|
725 |
* @param string $post_type the name of the post type
|
726 |
* @return bool
|
|
|
|
|
727 |
*/
|
728 |
protected function treat_as_root_page($post_type)
|
729 |
{
|
@@ -733,6 +782,7 @@ class bcn_breadcrumb_trail
|
|
733 |
* Determines if a post type has archives enabled or not
|
734 |
*
|
735 |
* @param string $post_type the name of the post type
|
|
|
736 |
* @return bool
|
737 |
*/
|
738 |
protected function has_archive($post_type)
|
@@ -783,11 +833,11 @@ class bcn_breadcrumb_trail
|
|
783 |
*
|
784 |
* @return string The possibly modified URL
|
785 |
*/
|
786 |
-
protected function maybe_add_post_type_arg($url, $type =
|
787 |
{
|
788 |
global $wp_taxonomies;
|
789 |
//Rather than default to post, we should try to find the type
|
790 |
-
if($type ==
|
791 |
{
|
792 |
$type = $this->get_type_string_query_var();
|
793 |
}
|
@@ -806,12 +856,14 @@ class bcn_breadcrumb_trail
|
|
806 |
* Deals with the post type archive and taxonomy archives
|
807 |
*
|
808 |
* @param WP_Post|WP_Taxonomy $type The post or taxonomy to generate the archive breadcrumb for
|
|
|
|
|
|
|
809 |
*/
|
810 |
-
protected function type_archive($type)
|
811 |
{
|
812 |
global $wp_taxonomies;
|
813 |
-
$type_str
|
814 |
-
if(!isset($type->taxonomy)) //TODO could probably check the class type here
|
815 |
{
|
816 |
$type_str = $this->get_type_string_query_var();
|
817 |
}
|
@@ -834,114 +886,34 @@ class bcn_breadcrumb_trail
|
|
834 |
$breadcrumb = $this->add(new bcn_breadcrumb($this->post_type_archive_title(get_post_type_object($post_type)), $this->opt['Hpost_' . $post_type . '_template'], array('post', 'post-' . $post_type . '-archive'), get_post_type_archive_link($post_type)));
|
835 |
}
|
836 |
}
|
837 |
-
/**
|
838 |
-
* This function populates our type_str and root_id variables
|
839 |
-
*
|
840 |
-
* @param post $type A post object we are using to figureout the type
|
841 |
-
* @param string $type_str The type string variable, passed by reference
|
842 |
-
* @param int $root_id The ID for the post type root
|
843 |
-
*
|
844 |
-
* TODO, can probably clean up all the logic here and use the code for the CPT archives for all paths
|
845 |
-
*/
|
846 |
-
protected function find_type($type, &$type_str, &$root_id)
|
847 |
-
{
|
848 |
-
global $wp_taxonomies;
|
849 |
-
//We need to do special things for custom post types
|
850 |
-
if(is_singular() && !$this->is_builtin($type->post_type))
|
851 |
-
{
|
852 |
-
//We need the type for later, so save it
|
853 |
-
$type_str = $type->post_type;
|
854 |
-
//This will assign a ID for root page of a custom post
|
855 |
-
if(is_numeric($this->opt['apost_' . $type_str . '_root']))
|
856 |
-
{
|
857 |
-
$root_id = $this->opt['apost_' . $type_str . '_root'];
|
858 |
-
}
|
859 |
-
}
|
860 |
-
//For CPT archives
|
861 |
-
else if(is_post_type_archive() && !isset($type->taxonomy))
|
862 |
-
{
|
863 |
-
//We need the type for later, so save it
|
864 |
-
$type_str = get_query_var('post_type');
|
865 |
-
//May be an array, if so, rewind the iterator and grab first item
|
866 |
-
if(is_array($type_str))
|
867 |
-
{
|
868 |
-
$type_str = reset($type_str);
|
869 |
-
}
|
870 |
-
//This will assign a ID for root page of a custom post's taxonomy archive
|
871 |
-
if(is_numeric($this->opt['apost_' . $type_str . '_root']))
|
872 |
-
{
|
873 |
-
$root_id = $this->opt['apost_' . $type_str . '_root'];
|
874 |
-
}
|
875 |
-
}
|
876 |
-
//We need to do special things for custom post type archives, but not author or date archives
|
877 |
-
else if(is_archive() && !is_author() && !is_date() && isset($type->taxonomy) && !$this->is_builtin($this->get_type_string_query_var($wp_taxonomies[$type->taxonomy]->object_type[0])))
|
878 |
-
{
|
879 |
-
//We need the type for later, so save it
|
880 |
-
$type_str = $this->get_type_string_query_var($wp_taxonomies[$type->taxonomy]->object_type[0]);
|
881 |
-
//This will assign a ID for root page of a custom post's taxonomy archive
|
882 |
-
if(is_numeric($this->opt['apost_' . $type_str . '_root']))
|
883 |
-
{
|
884 |
-
$root_id = $this->opt['apost_' . $type_str . '_root'];
|
885 |
-
}
|
886 |
-
}
|
887 |
-
else if(is_singular() && $type instanceof WP_Post && $type->post_type == 'page')
|
888 |
-
{
|
889 |
-
$type_str = 'page';
|
890 |
-
$root_id = get_option('page_on_front');
|
891 |
-
}
|
892 |
-
else if(($this->opt['bblog_display'] || is_home()) && !is_search())
|
893 |
-
{
|
894 |
-
$type_str = 'post';
|
895 |
-
$root_id = get_option('page_for_posts');
|
896 |
-
}
|
897 |
-
}
|
898 |
/**
|
899 |
* A Breadcrumb Trail Filling Function
|
900 |
*
|
901 |
* Handles only the root page stuff for post types, including the "page for posts"
|
|
|
|
|
|
|
|
|
|
|
902 |
*/
|
903 |
-
protected function do_root()
|
904 |
{
|
905 |
-
global $wp_query;
|
906 |
-
//If this is an attachment then we need to change the queried object to the parent post
|
907 |
-
if(is_attachment())
|
908 |
-
{
|
909 |
-
//Could use the $post global, but we can't really trust it
|
910 |
-
$post = get_post();
|
911 |
-
$type = get_post($post->post_parent); //TODO check for WP_Error?
|
912 |
-
//If the parent of the attachment is a page, exit early (works around bug where is_single() returns true for an attachment to a page)
|
913 |
-
if($type->post_type == 'page')
|
914 |
-
{
|
915 |
-
return;
|
916 |
-
}
|
917 |
-
}
|
918 |
-
else
|
919 |
-
{
|
920 |
-
//Simmilar to using $post, but for things $post doesn't cover
|
921 |
-
$type = $wp_query->get_queried_object();
|
922 |
-
}
|
923 |
-
$root_id = -1;
|
924 |
-
$type_str = '';
|
925 |
-
//Find our type string and root_id
|
926 |
-
$this->find_type($type, $type_str, $root_id);
|
927 |
//Continue only if we have a valid root_id
|
928 |
-
if($root_id
|
929 |
{
|
930 |
$frontpage_id = get_option('page_on_front');
|
931 |
//We'll have to check if this ID is valid, e.g. user has specified a posts page
|
932 |
if($root_id && $root_id != $frontpage_id)
|
933 |
{
|
934 |
//Place the breadcrumb in the trail, uses the constructor to set the title, template, and type, we get a pointer to it in return
|
935 |
-
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_title($root_id), $this->opt['Hpost_' . $type_str . '_template_no_anchor'], array($type_str . '-root', 'post', 'post-' . $type_str),
|
936 |
//If we are at home, or any root page archive then we need to add the current item type
|
937 |
-
if($
|
938 |
{
|
939 |
$breadcrumb->add_type('current-item');
|
940 |
}
|
941 |
//If we're not on the current item we need to setup the anchor
|
942 |
-
if(!$this->
|
943 |
-
|| (is_paged() && $this->opt['bpaged_display'])
|
944 |
-
|| ($this->treat_as_root_page($type_str) && $this->opt['bcurrent_item_linked']))
|
945 |
{
|
946 |
$breadcrumb->set_template($this->opt['Hpost_' . $type_str . '_template']);
|
947 |
//Figure out the anchor for home page
|
@@ -971,22 +943,14 @@ class bcn_breadcrumb_trail
|
|
971 |
/**
|
972 |
* A Breadcrumb Trail Filling Function
|
973 |
*
|
974 |
-
* This functions fills a breadcrumb for paged pages
|
|
|
|
|
975 |
*/
|
976 |
-
protected function do_paged()
|
977 |
{
|
978 |
-
//Need to switch between paged and page for archives and singular (posts)
|
979 |
-
if(get_query_var('paged') > 0)
|
980 |
-
{
|
981 |
-
//Can use simple type hinting here to int since we already checked for greater than 0
|
982 |
-
$page_number = (int) get_query_var('paged');
|
983 |
-
}
|
984 |
-
else
|
985 |
-
{
|
986 |
-
$page_number = absint(get_query_var('page'));
|
987 |
-
}
|
988 |
//Place the breadcrumb in the trail, uses the bcn_breadcrumb constructor to set the title, prefix, and suffix
|
989 |
-
$this->breadcrumbs[] = new bcn_breadcrumb($page_number, $this->opt['Hpaged_template'], array('paged'));
|
990 |
}
|
991 |
/**
|
992 |
* Breadcrumb Trail Filling Function
|
@@ -1000,15 +964,26 @@ class bcn_breadcrumb_trail
|
|
1000 |
if(count($this->breadcrumbs) > 0)
|
1001 |
{
|
1002 |
//Exit early since we have breadcrumbs in the trail
|
1003 |
-
return
|
1004 |
}
|
1005 |
//Do any actions if necessary, we past through the current object instance to keep life simple
|
1006 |
do_action('bcn_before_fill', $this);
|
|
|
1007 |
//Do specific opperations for the various page types
|
1008 |
//Check if this isn't the first of a multi paged item
|
1009 |
if($this->opt['bpaged_display'] && (is_paged() || is_singular() && get_query_var('page') > 1))
|
1010 |
{
|
1011 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1012 |
}
|
1013 |
//For the front page, as it may also validate as a page, do it first
|
1014 |
if(is_front_page())
|
@@ -1016,37 +991,36 @@ class bcn_breadcrumb_trail
|
|
1016 |
//Must have two seperate branches so that we don't evaluate it as a page
|
1017 |
if($this->opt['bhome_display'])
|
1018 |
{
|
1019 |
-
$this->
|
1020 |
}
|
1021 |
}
|
1022 |
//For posts
|
1023 |
else if(is_singular())
|
1024 |
{
|
1025 |
-
|
|
|
1026 |
if(is_attachment())
|
1027 |
{
|
1028 |
-
$
|
1029 |
-
|
1030 |
-
|
1031 |
-
else
|
1032 |
-
{
|
1033 |
-
$this->do_post(get_post());
|
1034 |
}
|
|
|
1035 |
}
|
1036 |
//For searches
|
1037 |
else if(is_search())
|
1038 |
{
|
1039 |
-
$this->do_search();
|
1040 |
}
|
1041 |
//For author pages
|
1042 |
else if(is_author())
|
1043 |
{
|
1044 |
-
$this->do_author();
|
|
|
1045 |
}
|
1046 |
//For archives
|
1047 |
else if(is_archive())
|
1048 |
{
|
1049 |
-
$type = $wp_query->get_queried_object();
|
1050 |
//We need the type for later, so save it
|
1051 |
$type_str = get_query_var('post_type');
|
1052 |
//May be an array, if so, rewind the iterator and grab first item
|
@@ -1057,25 +1031,41 @@ class bcn_breadcrumb_trail
|
|
1057 |
//For date based archives
|
1058 |
if(is_date())
|
1059 |
{
|
1060 |
-
|
1061 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1062 |
}
|
1063 |
//If we have a post type archive, and it does not have a root page generate the archive
|
1064 |
else if(is_post_type_archive() && !isset($type->taxonomy)
|
1065 |
&& (!is_numeric($this->opt['apost_' . $type_str . '_root']) || $this->opt['bpost_' . $type_str . '_archive_display']))
|
1066 |
{
|
1067 |
-
$this->do_archive_by_post_type();
|
1068 |
}
|
1069 |
//For taxonomy based archives
|
1070 |
else if(is_category() || is_tag() || is_tax())
|
1071 |
{
|
1072 |
-
$this->do_archive_by_term();
|
1073 |
$this->type_archive($type);
|
|
|
1074 |
}
|
1075 |
else
|
1076 |
{
|
1077 |
$this->type_archive($type);
|
1078 |
}
|
|
|
|
|
|
|
|
|
1079 |
}
|
1080 |
//For 404 pages
|
1081 |
else if(is_404())
|
@@ -1084,20 +1074,23 @@ class bcn_breadcrumb_trail
|
|
1084 |
}
|
1085 |
else
|
1086 |
{
|
1087 |
-
//If we are here, there may have been problems detecting the type
|
1088 |
-
$type = $wp_query->get_queried_object();
|
1089 |
//If it looks, walks, and quacks like a taxonomy, treat is as one
|
1090 |
if(isset($type->taxonomy))
|
1091 |
{
|
1092 |
-
$this->do_archive_by_term();
|
1093 |
$this->type_archive($type);
|
|
|
|
|
|
|
|
|
|
|
1094 |
}
|
|
|
1095 |
}
|
1096 |
//We always do the home link last, unless on the frontpage
|
1097 |
if(!is_front_page())
|
1098 |
{
|
1099 |
-
$this->
|
1100 |
-
$this->do_home();
|
1101 |
}
|
1102 |
//Do any actions if necessary, we past through the current object instance to keep life simple
|
1103 |
do_action('bcn_after_fill', $this);
|
@@ -1124,51 +1117,20 @@ class bcn_breadcrumb_trail
|
|
1124 |
/**
|
1125 |
* This functions outputs or returns the breadcrumb trail in string form.
|
1126 |
*
|
1127 |
-
* @return void Void if Option to print out breadcrumb trail was chosen.
|
1128 |
-
* @return string String-Data of breadcrumb trail.
|
1129 |
* @param bool $return Whether to return data or to echo it.
|
1130 |
* @param bool $linked[optional] Whether to allow hyperlinks in the trail or not.
|
1131 |
* @param bool $reverse[optional] Whether to reverse the output or not.
|
|
|
1132 |
*
|
1133 |
-
*
|
|
|
1134 |
*/
|
1135 |
-
public function display($return = false, $linked = true, $reverse = false)
|
1136 |
{
|
1137 |
//Set trail order based on reverse flag
|
1138 |
$this->order($reverse);
|
1139 |
-
//Initilize the string which will hold the assembled trail
|
1140 |
-
$trail_str = '';
|
1141 |
-
$position = 1;
|
1142 |
//The main compiling loop
|
1143 |
-
|
1144 |
-
{
|
1145 |
-
//We do different things for the separator based on the breadcrumb order
|
1146 |
-
if($reverse)
|
1147 |
-
{
|
1148 |
-
//Add in the separator only if we are the 2nd or greater element
|
1149 |
-
if($key > 0)
|
1150 |
-
{
|
1151 |
-
$trail_str .= $this->opt['hseparator'];
|
1152 |
-
}
|
1153 |
-
}
|
1154 |
-
else
|
1155 |
-
{
|
1156 |
-
//Only show the separator when necessary
|
1157 |
-
if($position > 1)
|
1158 |
-
{
|
1159 |
-
$trail_str .= $this->opt['hseparator'];
|
1160 |
-
}
|
1161 |
-
}
|
1162 |
-
//Trim titles, if needed
|
1163 |
-
if($this->opt['blimit_title'] && $this->opt['amax_title_length'] > 0)
|
1164 |
-
{
|
1165 |
-
//Trim the breadcrumb's title
|
1166 |
-
$breadcrumb->title_trim($this->opt['amax_title_length']);
|
1167 |
-
}
|
1168 |
-
//Place in the breadcrumb's assembled elements
|
1169 |
-
$trail_str .= $breadcrumb->assemble($linked, $position);
|
1170 |
-
$position++;
|
1171 |
-
}
|
1172 |
//Should we return or echo the assembled trail?
|
1173 |
if($return)
|
1174 |
{
|
@@ -1184,43 +1146,72 @@ class bcn_breadcrumb_trail
|
|
1184 |
/**
|
1185 |
* This functions outputs or returns the breadcrumb trail in list form.
|
1186 |
*
|
1187 |
-
* @
|
1188 |
-
*
|
1189 |
* @param bool $return Whether to return data or to echo it.
|
1190 |
* @param bool $linked[optional] Whether to allow hyperlinks in the trail or not.
|
1191 |
-
* @param bool $reverse[optional] Whether to reverse the output or not.
|
1192 |
*
|
1193 |
-
*
|
|
|
1194 |
*/
|
1195 |
public function display_list($return = false, $linked = true, $reverse = false)
|
1196 |
{
|
1197 |
-
|
1198 |
-
$this->
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1199 |
//Initilize the string which will hold the assembled trail
|
1200 |
$trail_str = '';
|
1201 |
-
$position = 1;
|
1202 |
-
//The main compiling loop
|
1203 |
foreach($this->breadcrumbs as $key => $breadcrumb)
|
1204 |
{
|
1205 |
-
$
|
1206 |
//On the first run we need to add in a class for the home breadcrumb
|
1207 |
if($trail_str === '')
|
1208 |
{
|
1209 |
-
$
|
1210 |
if($key === 0)
|
1211 |
{
|
1212 |
-
$
|
1213 |
}
|
1214 |
-
$
|
1215 |
}
|
1216 |
//If we are on the current item there are some things that must be done
|
1217 |
else if($key === 0)
|
1218 |
{
|
1219 |
//Add in a class for current_item
|
1220 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1221 |
}
|
1222 |
//Filter li_attributes adding attributes to the li element
|
1223 |
-
$
|
|
|
1224 |
//Trim titles, if requested
|
1225 |
if($this->opt['blimit_title'] && $this->opt['amax_title_length'] > 0)
|
1226 |
{
|
@@ -1228,29 +1219,19 @@ class bcn_breadcrumb_trail
|
|
1228 |
$breadcrumb->title_trim($this->opt['amax_title_length']);
|
1229 |
}
|
1230 |
//Assemble the breadrumb and wrap with li's
|
1231 |
-
$trail_str .= sprintf(
|
1232 |
$position++;
|
1233 |
}
|
1234 |
-
|
1235 |
-
if($return)
|
1236 |
-
{
|
1237 |
-
return $trail_str;
|
1238 |
-
}
|
1239 |
-
else
|
1240 |
-
{
|
1241 |
-
//Helps track issues, please don't remove it
|
1242 |
-
$credits = "<!-- Breadcrumb NavXT " . $this::version . " -->\n";
|
1243 |
-
echo $credits . $trail_str;
|
1244 |
-
}
|
1245 |
}
|
1246 |
/**
|
1247 |
* This functions outputs or returns the breadcrumb trail in Schema.org BreadcrumbList compliant JSON-LD
|
1248 |
*
|
1249 |
-
* @return void Void if option to print out breadcrumb trail was chosen.
|
1250 |
-
* @return string String version of the breadcrumb trail.
|
1251 |
* @param bool $return Whether to return data or to echo it.
|
1252 |
-
* @param bool $reverse[optional] Whether to reverse the output or not.
|
1253 |
*
|
|
|
|
|
1254 |
*/
|
1255 |
public function display_json_ld($return = false, $reverse = false)
|
1256 |
{
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
Copyright 2015-2017 John Havlik (email : john.havlik@mtekk.us)
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
21 |
class bcn_breadcrumb_trail
|
22 |
{
|
23 |
//Our member variables
|
24 |
+
const version = '6.0.0';
|
25 |
//An array of breadcrumbs
|
26 |
public $breadcrumbs = array();
|
27 |
public $trail = array();
|
66 |
//Current item options
|
67 |
'bcurrent_item_linked' => false,
|
68 |
//Static page options
|
69 |
+
//Should the trail include the hierarchy of the page
|
70 |
+
'bpost_page_hierarchy_display' => true,
|
71 |
+
//What hierarchy should be shown leading to the page
|
72 |
+
'Spost_page_hierarchy_type' => 'BCN_POST_PARENT',
|
73 |
//The anchor template for page breadcrumbs
|
74 |
'Hpost_page_template' => bcn_breadcrumb::get_default_template(),
|
75 |
//The anchor template for page breadcrumbs, used when an anchor is not needed
|
88 |
'Hpost_post_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor,
|
89 |
//Just a link for the page for posts
|
90 |
'apost_post_root' => get_option('page_for_posts'),
|
91 |
+
//Should the trail include the hierarchy of the post
|
92 |
+
'bpost_post_hierarchy_display' => true,
|
93 |
//Should the trail reflect the referer taxonomy or not
|
94 |
'bpost_post_taxonomy_referer' => false,
|
95 |
+
//What hierarchy should be shown leading to the post, tag or category
|
96 |
+
'Spost_post_hierarchy_type' => 'category',
|
97 |
//Attachment settings
|
98 |
//The breadcrumb template for attachment breadcrumbs
|
99 |
'Hpost_attachment_template' => bcn_breadcrumb::get_default_template(),
|
139 |
}
|
140 |
/**
|
141 |
* This returns the internal version
|
142 |
+
*
|
143 |
+
* @deprecated 5.2.0 No longer needed, superceeded bcn_breadcrumb_trail::version
|
144 |
*
|
145 |
* @return string internal version of the Breadcrumb trail
|
146 |
*/
|
153 |
* Adds a breadcrumb to the breadcrumb trail
|
154 |
*
|
155 |
* @param bcn_breadcrumb $object Breadcrumb to add to the trail
|
156 |
+
*
|
157 |
* @return pointer to the just added Breadcrumb
|
158 |
*/
|
159 |
public function &add(bcn_breadcrumb $object)
|
165 |
/**
|
166 |
* A Breadcrumb Trail Filling Function
|
167 |
*
|
168 |
+
* This functions fills a breadcrumb for a search page
|
169 |
+
*
|
170 |
+
* @param string $search_query The search query that was performed
|
171 |
+
* @param bool $is_paged Whether or not the current resource is on a page other than page 1
|
172 |
*/
|
173 |
+
protected function do_search($search_query, $is_paged = false)
|
174 |
{
|
175 |
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
176 |
+
$breadcrumb = $this->add(new bcn_breadcrumb($search_query, $this->opt['Hsearch_template_no_anchor'], array('search', 'current-item')));
|
177 |
//If we're paged, or allowing the current item to be linked, let's link to the first page
|
178 |
+
if($this->opt['bcurrent_item_linked'] || ($is_paged && $this->opt['bpaged_display']))
|
179 |
{
|
180 |
//Since we are paged and are linking the root breadcrumb, time to change to the regular template
|
181 |
$breadcrumb->set_template($this->opt['Hsearch_template']);
|
182 |
//Figure out the anchor for the search
|
183 |
+
$breadcrumb->set_url(get_search_link($search_query));
|
184 |
}
|
185 |
}
|
186 |
/**
|
187 |
* A Breadcrumb Trail Filling Function
|
188 |
*
|
189 |
+
* This functions fills a breadcrumb for an author page
|
190 |
+
*
|
191 |
+
* @param string $author_data The author to generate the breadcrumb for
|
192 |
+
* @param bool $is_paged Whether or not the current resource is on a page other than page 1
|
193 |
*/
|
194 |
+
protected function do_author($author_data, $is_paged = false)
|
195 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
//Setup array of valid author_name values
|
197 |
$valid_author_name = array('display_name', 'nickname', 'first_name', 'last_name');
|
198 |
//Make sure user picks only safe values
|
199 |
if(in_array($this->opt['Sauthor_name'], $valid_author_name))
|
200 |
{
|
201 |
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
202 |
+
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_author_meta($this->opt['Sauthor_name'], $author_data->ID), $this->opt['Hauthor_template_no_anchor'], array('author', 'current-item'), null, $author_data->ID));
|
203 |
//If we're paged, or allowing the current item to be linked, let's link to the first page
|
204 |
+
if($this->opt['bcurrent_item_linked'] || ($is_paged && $this->opt['bpaged_display']))
|
205 |
{
|
206 |
//Set the template to our one containing an anchor
|
207 |
$breadcrumb->set_template($this->opt['Hauthor_template']);
|
208 |
+
$breadcrumb->set_url(get_author_posts_url($author_data->ID));
|
209 |
}
|
210 |
}
|
211 |
}
|
213 |
* Determines the taxonomy name represented by the specified query var
|
214 |
*
|
215 |
* @param string $query_var The query var to attempt to find the corresponding taxonomy
|
216 |
+
*
|
217 |
* @return string|bool Either the name of the taxonomy corresponding to the query_var or false if no taxonomy exists for the specified query_var
|
218 |
*/
|
219 |
protected function query_var_to_taxonomy($query_var)
|
273 |
* @param int $id The ID of the post to find the term for
|
274 |
* @param string $type The post type of the post to figure out the taxonomy for
|
275 |
* @param string $taxonomy The taxonomy to use
|
276 |
+
*
|
277 |
* @return WP_Term|bool The term object to use for the post hierarchy or false if no suitable term was found
|
278 |
*/
|
279 |
protected function pick_post_term($id, $type, $taxonomy)
|
303 |
* A Breadcrumb Trail Filling Function
|
304 |
*
|
305 |
* This function fills breadcrumbs for any post taxonomy
|
306 |
+
*
|
307 |
* @param int $id The id of the post to figure out the taxonomy for
|
308 |
* @param string $type The post type of the post to figure out the taxonomy for
|
309 |
* @param int $parent (optional) The id of the parent of the current post, used if hiearchal posts will be the "taxonomy" for the current post
|
310 |
*/
|
311 |
+
protected function post_hierarchy($id, $type, $parent = null)
|
312 |
{
|
313 |
+
//Check to see if breadcrumbs for the hierarchy of the post needs to be generated
|
314 |
+
if($this->opt['bpost_' . $type . '_hierarchy_display'])
|
315 |
{
|
|
|
316 |
//Check if we have a date 'taxonomy' request
|
317 |
+
if($this->opt['Spost_' . $type . '_hierarchy_type'] === 'BCN_DATE')
|
318 |
{
|
319 |
+
$post = get_post($id);
|
320 |
+
$this->do_day($post, $type, false, false);
|
321 |
+
$this->do_month($post, $type, false, false);
|
322 |
+
$this->do_year($post, $type, false, false);
|
323 |
}
|
|
|
324 |
//Handle the use of hierarchical posts as the 'taxonomy'
|
325 |
+
else if($this->opt['Spost_' . $type . '_hierarchy_type'] === 'BCN_POST_PARENT')
|
326 |
{
|
327 |
+
if($parent == null)
|
328 |
{
|
329 |
//We have to grab the post to find its parent, can't use $post for this one
|
330 |
$parent = get_post($id);
|
332 |
$parent = $parent->post_parent;
|
333 |
}
|
334 |
//Grab the frontpage, we'll need it shortly
|
335 |
+
$frontpage = get_option('page_on_front');
|
336 |
//If there is a parent page let's find it
|
337 |
+
if($parent && $id != $parent && $frontpage != $parent)
|
338 |
{
|
339 |
+
$parent = $this->post_parents($parent, $frontpage);
|
340 |
}
|
341 |
}
|
342 |
else
|
343 |
{
|
344 |
+
$taxonomy = $this->opt['Spost_' . $type . '_hierarchy_type'];
|
345 |
//Possibly let the referer influence the taxonomy used
|
346 |
if($this->opt['bpost_' . $type . '_taxonomy_referer'] && $referrer_taxonomy = $this->determine_taxonomy())
|
347 |
{
|
377 |
$parent = get_post($id);
|
378 |
}
|
379 |
//Finish off with trying to find the type archive
|
380 |
+
$this->type_archive($parent, $type);
|
381 |
}
|
382 |
/**
|
383 |
* A Breadcrumb Trail Filling Function
|
384 |
*
|
385 |
* This functions fills a breadcrumb for the terms of a post
|
386 |
+
*
|
387 |
* @param int $id The id of the post to find the terms for
|
388 |
* @param string $taxonomy The name of the taxonomy that the term belongs to
|
389 |
*
|
409 |
//This is a bit hackish, but it compiles the term anchor and appends it to the current breadcrumb title
|
410 |
$title .= str_replace(
|
411 |
array('%title%', '%link%', '%htitle%', '%type%'),
|
412 |
+
array($term->name, $this->maybe_add_post_type_arg(get_term_link($term), null, $term->taxonomy), $term->name, $term->taxonomy),
|
413 |
$this->opt['Htax_' . $term->taxonomy . '_template']);
|
414 |
$is_first = false;
|
415 |
}
|
416 |
//Place the breadcrumb in the trail, uses the constructor to set the title, template, and type, get a pointer to it in return
|
417 |
+
$breadcrumb = $this->add(new bcn_breadcrumb($title, '%htitle%', array('taxonomy', $taxonomy)));
|
418 |
}
|
419 |
}
|
420 |
/**
|
421 |
* A Breadcrumb Trail Filling Function
|
422 |
*
|
423 |
+
* This recursive functions fills the trail with breadcrumbs for parent terms
|
424 |
+
*
|
425 |
+
* @param int $id The id of the term
|
426 |
* @param string $taxonomy The name of the taxonomy that the term belongs to
|
427 |
+
*
|
428 |
* @return WP_Term The term we stopped at
|
429 |
*/
|
430 |
protected function term_parents($id, $taxonomy)
|
432 |
//Get the current category object, filter applied within this call
|
433 |
$term = get_term($id, $taxonomy);
|
434 |
//Place the breadcrumb in the trail, uses the constructor to set the title, template, and type, get a pointer to it in return
|
435 |
+
$breadcrumb = $this->add(new bcn_breadcrumb($term->name, $this->opt['Htax_' . $taxonomy . '_template'], array('taxonomy', $taxonomy), $this->maybe_add_post_type_arg(get_term_link($term), null, $taxonomy), $id));
|
436 |
//Make sure the id is valid, and that we won't end up spinning in a loop
|
437 |
if($term->parent && $term->parent != $id)
|
438 |
{
|
444 |
/**
|
445 |
* A Breadcrumb Trail Filling Function
|
446 |
*
|
447 |
+
* This recursive functions fills the trail with breadcrumbs for parent posts/pages
|
448 |
+
*
|
449 |
+
* @param int $id The id of the parent page
|
450 |
+
* @param int $frontpage The id of the front page
|
451 |
+
*
|
452 |
* @return WP_Post The parent we stopped at
|
453 |
*/
|
454 |
protected function post_parents($id, $frontpage)
|
470 |
*
|
471 |
* This functions fills a breadcrumb for posts
|
472 |
*
|
473 |
+
* @param WP_Post $post Instance of WP_Post object to create a breadcrumb for
|
474 |
+
* @param bool $force_link Whether or not to force this breadcrumb to be linked
|
475 |
+
* @param bool $is_paged Whether or not the current resource is on a page other than page 1
|
476 |
+
* @param bool $is_current_item Whether or not the breadcrumb being generated is the current item
|
477 |
*/
|
478 |
+
protected function do_post($post, $force_link = false, $is_paged = false, $is_current_item = true)
|
479 |
{
|
480 |
//If we did not get a WP_Post object, warn developer and return early
|
481 |
if(!($post instanceof WP_Post))
|
484 |
return;
|
485 |
}
|
486 |
//Place the breadcrumb in the trail, uses the bcn_breadcrumb constructor to set the title, template, and type
|
487 |
+
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_title($post), $this->opt['Hpost_' . $post->post_type . '_template_no_anchor'], array('post', 'post-' . $post->post_type), null, $post->ID));
|
488 |
+
if($is_current_item)
|
489 |
+
{
|
490 |
+
$breadcrumb->add_type('current-item');
|
491 |
+
}
|
492 |
+
//Under a couple of circumstances we will want to link this breadcrumb
|
493 |
+
if($force_link || ($is_current_item && $this->opt['bcurrent_item_linked']) || ($is_paged && $this->opt['bpaged_display']))
|
494 |
{
|
495 |
//Change the template over to the normal, linked one
|
496 |
$breadcrumb->set_template($this->opt['Hpost_' . $post->post_type . '_template']);
|
497 |
//Add the link
|
498 |
$breadcrumb->set_url(get_permalink($post));
|
499 |
}
|
500 |
+
//If we have an attachment, run through the post again
|
501 |
+
if($post->post_type === 'attachment')
|
502 |
{
|
503 |
//Done with the current item, now on to the parents
|
504 |
$frontpage = get_option('page_on_front');
|
505 |
+
//Make sure the id is valid, and that we won't end up spinning in a loop
|
506 |
+
if($post->post_parent >= 0 && $post->post_parent != false && $post->ID != $post->post_parent && $frontpage != $post->post_parent)
|
507 |
{
|
508 |
+
//Get the parent's information
|
509 |
+
$parent = get_post($post->post_parent);
|
510 |
+
//Take care of the parent's breadcrumb
|
511 |
+
$this->do_post($parent, true, false, false);
|
512 |
}
|
513 |
}
|
514 |
//Otherwise we need the follow the hiearchy tree
|
521 |
/**
|
522 |
* A Breadcrumb Trail Filling Function
|
523 |
*
|
524 |
+
* @deprecated 6.0.0 No longer needed, superceeded by do_post
|
525 |
+
*
|
526 |
* This functions fills a breadcrumb for an attachment page.
|
527 |
*/
|
528 |
protected function do_attachment()
|
529 |
{
|
530 |
+
_deprecated_function( __FUNCTION__, '6.0', 'bcn_breadcrumb_trail::do_post');
|
531 |
+
$this->do_post(get_post());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
532 |
}
|
533 |
/**
|
534 |
* A Breadcrumb Trail Filling Function
|
535 |
*
|
536 |
* This function fills a breadcrumb for any taxonomy archive, was previously two separate functions
|
537 |
+
*
|
538 |
+
* @param WP_Term $term The term object to generate the breadcrumb for
|
539 |
+
* @param bool $is_paged Whether or not the current resource is on a page other than page 1
|
540 |
*/
|
541 |
+
protected function do_archive_by_term($term, $is_paged = false)
|
542 |
{
|
|
|
|
|
|
|
543 |
//Place the breadcrumb in the trail, uses the constructor to set the title, template, and type, get a pointer to it in return
|
544 |
+
$breadcrumb = $this->add(new bcn_breadcrumb($term->name, $this->opt['Htax_' . $term->taxonomy . '_template_no_anchor'], array('archive', 'taxonomy', $term->taxonomy, 'current-item'), null, $term->term_id));
|
545 |
//If we're paged, let's link to the first page
|
546 |
+
if($this->opt['bcurrent_item_linked'] || ($is_paged && $this->opt['bpaged_display']))
|
547 |
{
|
548 |
$breadcrumb->set_template($this->opt['Htax_' . $term->taxonomy . '_template']);
|
549 |
//Figure out the anchor for current category
|
550 |
+
$breadcrumb->set_url($this->maybe_add_post_type_arg(get_term_link($term), null, $term->taxonomy));
|
551 |
}
|
552 |
//Get parents of current term
|
553 |
if($term->parent)
|
558 |
/**
|
559 |
* A Breadcrumb Trail Filling Function
|
560 |
*
|
561 |
+
* This functions fills a breadcrumb for day date archives
|
562 |
*
|
563 |
+
* @param WP_Post $post Instance of WP_Post object to create a breadcrumb for
|
564 |
+
* @param string $type The name of the CPT to generate the archive breadcrumb for
|
565 |
+
* @param bool $is_paged Whether or not the current resource is on a page other than page 1
|
566 |
+
* @param bool $is_current_item Whether or not the breadcrumb being generated is the current item
|
567 |
*/
|
568 |
+
protected function do_day($post, $type, $is_paged = false, $is_current_item = true)
|
569 |
{
|
570 |
+
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
571 |
+
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_time(_x('d', 'day archive breadcrumb date format', 'breadcrumb-navxt'), $post), $this->opt['Hdate_template_no_anchor'], array('archive', 'date-day')));
|
572 |
+
//If this is a day archive, add current-item type
|
573 |
+
if($is_current_item)
|
574 |
{
|
575 |
+
$breadcrumb->add_type('current-item');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
576 |
}
|
577 |
+
//If we're paged, let's link to the first page
|
578 |
+
if(!$is_current_item || ($is_current_item && $this->opt['bcurrent_item_linked']) || ($is_paged && $this->opt['bpaged_display']))
|
579 |
{
|
580 |
+
//We're linking, so set the linked template
|
581 |
+
$breadcrumb->set_template($this->opt['Hdate_template']);
|
582 |
+
$url = get_day_link(get_the_time('Y'), get_the_time('m'), get_the_time('d'));
|
583 |
+
//Deal with the anchor
|
584 |
+
$breadcrumb->set_url($this->maybe_add_post_type_arg($url, $type));
|
585 |
+
}
|
586 |
+
}
|
587 |
+
/**
|
588 |
+
* A Breadcrumb Trail Filling Function
|
589 |
+
*
|
590 |
+
* This functions fills a breadcrumb for month date archives
|
591 |
+
*
|
592 |
+
* @param WP_Post $post Instance of WP_Post object to create a breadcrumb for
|
593 |
+
* @param string $type The name of the CPT to generate the archive breadcrumb for
|
594 |
+
* @param bool $is_paged Whether or not the current resource is on a page other than page 1
|
595 |
+
* @param bool $is_current_item Whether or not the breadcrumb being generated is the current item
|
596 |
+
*/
|
597 |
+
protected function do_month($post, $type, $is_paged = false, $is_current_item = true)
|
598 |
+
{
|
599 |
+
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
600 |
+
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_time(_x('F', 'month archive breadcrumb date format', 'breadcrumb-navxt'), $post), $this->opt['Hdate_template_no_anchor'], array('archive', 'date-month')));
|
601 |
+
//If this is a month archive, add current-item type
|
602 |
+
if($is_current_item)
|
603 |
+
{
|
604 |
+
$breadcrumb->add_type('current-item');
|
605 |
+
}
|
606 |
+
//If we're paged, or not in the archive by month let's link to the first archive by month page
|
607 |
+
if(!$is_current_item || ($is_current_item && $this->opt['bcurrent_item_linked']) || ($is_paged && $this->opt['bpaged_display']))
|
608 |
+
{
|
609 |
+
//We're linking, so set the linked template
|
610 |
+
$breadcrumb->set_template($this->opt['Hdate_template']);
|
611 |
+
$url = get_month_link(get_the_time('Y'), get_the_time('m'));
|
612 |
+
//Deal with the anchor
|
613 |
+
$breadcrumb->set_url($this->maybe_add_post_type_arg($url, $type));
|
614 |
}
|
615 |
+
}
|
616 |
+
/**
|
617 |
+
* A Breadcrumb Trail Filling Function
|
618 |
+
*
|
619 |
+
* This functions fills a breadcrumb for year date archives
|
620 |
+
*
|
621 |
+
* @param WP_Post $post Instance of WP_Post object to create a breadcrumb for
|
622 |
+
* @param string $type The name of the CPT to generate the archive breadcrumb for
|
623 |
+
* @param bool $is_paged Whether or not the current resource is on a page other than page 1
|
624 |
+
* @param bool $is_current_item Whether or not the breadcrumb being generated is the current item
|
625 |
+
*/
|
626 |
+
protected function do_year($post, $type, $is_paged = false, $is_current_item = true)
|
627 |
+
{
|
628 |
//Place the year breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
629 |
+
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_time(_x('Y', 'year archive breadcrumb date format', 'breadcrumb-navxt'), $post), $this->opt['Hdate_template_no_anchor'], array('archive', 'date-year')));
|
630 |
//If this is a year archive, add current-item type
|
631 |
+
if($is_current_item)
|
632 |
{
|
633 |
$breadcrumb->add_type('current-item');
|
634 |
}
|
635 |
//If we're paged, or not in the archive by year let's link to the first archive by year page
|
636 |
+
if(!$is_current_item || ($is_current_item && $this->opt['bcurrent_item_linked']) || ($is_paged && $this->opt['bpaged_display']))
|
637 |
{
|
638 |
//We're linking, so set the linked template
|
639 |
$breadcrumb->set_template($this->opt['Hdate_template']);
|
642 |
$breadcrumb->set_url($this->maybe_add_post_type_arg($url, $type));
|
643 |
}
|
644 |
}
|
645 |
+
/**
|
646 |
+
* A Breadcrumb Trail Filling Function
|
647 |
+
*
|
648 |
+
* This functions fills a breadcrumb for a date archive.
|
649 |
+
*
|
650 |
+
* @param string $type The type to restrict the date archives to
|
651 |
+
*
|
652 |
+
* @deprecated 6.0.0 No longer needed, superceeded by do_day, do_month, and/or do_year
|
653 |
+
*/
|
654 |
+
protected function do_archive_by_date($type)
|
655 |
+
{
|
656 |
+
_deprecated_function( __FUNCTION__, '6.0', 'bcn_breadcrumb_trail::do_day, bcn_breadcrumb_trail::do_month, and/or bcn_breadcrumb_trail::do_year');
|
657 |
+
//First deal with the day breadcrumb
|
658 |
+
if(is_day() || is_single())
|
659 |
+
{
|
660 |
+
$this->do_day(get_post(), $type, is_paged(), is_day());
|
661 |
+
}
|
662 |
+
//Now deal with the month breadcrumb
|
663 |
+
if(is_month() || is_day() || is_single())
|
664 |
+
{
|
665 |
+
$this->do_month(get_post(), $type, is_paged(), is_month());
|
666 |
+
}
|
667 |
+
$this->do_year(get_post(), $type, is_paged(), is_year());
|
668 |
+
}
|
669 |
/**
|
670 |
* A Breadcrumb Trail Filling Function
|
671 |
*
|
672 |
* This functions fills a breadcrumb for a post type archive (WP 3.1 feature)
|
673 |
+
*
|
674 |
+
* @param string type_str The name of the CPT to generate the archive breadcrumb for
|
675 |
+
* @param bool $is_paged Whether or not the current resource is on a page other than page 1
|
676 |
*/
|
677 |
+
protected function do_archive_by_post_type($type_str, $is_paged = false)
|
678 |
{
|
679 |
+
//Manually grabbing the post type object insted of post_type_archive_title('', false) to remove get_query_var() dependancy
|
680 |
+
$post_type_obj = get_post_type_object($type_str);
|
681 |
+
$title = apply_filters('post_type_archive_title', $post_type_obj->labels->name, $type_str);
|
682 |
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
683 |
+
$breadcrumb = $this->add(new bcn_breadcrumb($title, $this->opt['Hpost_' . $type_str . '_template_no_anchor'], array('archive', 'post-' . $type_str . '-archive', 'current-item')));
|
684 |
+
if($this->opt['bcurrent_item_linked'] || ($is_paged && $this->opt['bpaged_display']))
|
685 |
{
|
686 |
|
687 |
$breadcrumb->set_template($this->opt['Hpost_' . $type_str . '_template']);
|
692 |
/**
|
693 |
* A Breadcrumb Trail Filling Function
|
694 |
*
|
695 |
+
* This functions fills a breadcrumb for the front page
|
696 |
+
*
|
697 |
+
* @param bool $force_link Whether or not to force this breadcrumb to be linked
|
698 |
+
* @param bool $is_paged Whether or not the current resource is on a page other than page 1
|
699 |
+
* @param bool $is_current_item Whether or not the breadcrumb being generated is the current item
|
700 |
*/
|
701 |
+
protected function do_home($force_link = false, $is_paged = false, $is_current_item = true)
|
702 |
{
|
703 |
global $current_site;
|
704 |
+
//Exit early if we're not displaying the home breadcrumb
|
705 |
+
if(!$this->opt['bhome_display'])
|
706 |
+
{
|
707 |
+
return;
|
708 |
+
}
|
709 |
//Get the site name
|
710 |
$site_name = get_option('blogname');
|
711 |
//Place the breadcrumb in the trail, uses the constructor to set the title, prefix, and suffix, get a pointer to it in return
|
712 |
+
$breadcrumb = $this->add(new bcn_breadcrumb($site_name, $this->opt['Hhome_template_no_anchor'], array('home')));
|
713 |
+
if($is_current_item)
|
714 |
+
{
|
715 |
+
$breadcrumb->add_type('current-item');
|
716 |
+
}
|
717 |
+
//Under a couple of circumstances we will want to link this breadcrumb
|
718 |
+
if($force_link || ($is_current_item && $this->opt['bcurrent_item_linked']) || ($is_paged && $this->opt['bpaged_display']))
|
719 |
{
|
720 |
$breadcrumb->set_template($this->opt['Hhome_template']);
|
721 |
//Figure out the anchor for home page
|
730 |
$breadcrumb = $this->add(new bcn_breadcrumb($site_name, $this->opt['Hmainsite_template'], array('main-home'), get_home_url($current_site->blog_id)));
|
731 |
}
|
732 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
733 |
/**
|
734 |
* A modified version of WordPress' function of the same name
|
735 |
*
|
736 |
* @param object $object the post or taxonomy object used to attempt to find the title
|
737 |
+
*
|
738 |
* @return string the title
|
739 |
*/
|
740 |
protected function post_type_archive_title($object)
|
750 |
* Determines if a post type is a built in type or not
|
751 |
*
|
752 |
* @param string $post_type the name of the post type
|
753 |
+
*
|
754 |
* @return bool
|
755 |
*/
|
756 |
protected function is_builtin($post_type)
|
771 |
*
|
772 |
* @param string $post_type the name of the post type
|
773 |
* @return bool
|
774 |
+
*
|
775 |
+
* TODO: Remove dependancies to current state (state should be passed in)
|
776 |
*/
|
777 |
protected function treat_as_root_page($post_type)
|
778 |
{
|
782 |
* Determines if a post type has archives enabled or not
|
783 |
*
|
784 |
* @param string $post_type the name of the post type
|
785 |
+
*
|
786 |
* @return bool
|
787 |
*/
|
788 |
protected function has_archive($post_type)
|
833 |
*
|
834 |
* @return string The possibly modified URL
|
835 |
*/
|
836 |
+
protected function maybe_add_post_type_arg($url, $type = null, $taxonomy = null)
|
837 |
{
|
838 |
global $wp_taxonomies;
|
839 |
//Rather than default to post, we should try to find the type
|
840 |
+
if($type == null)
|
841 |
{
|
842 |
$type = $this->get_type_string_query_var();
|
843 |
}
|
856 |
* Deals with the post type archive and taxonomy archives
|
857 |
*
|
858 |
* @param WP_Post|WP_Taxonomy $type The post or taxonomy to generate the archive breadcrumb for
|
859 |
+
* @param string $type_str The type string for the archive
|
860 |
+
*
|
861 |
+
* TODO: Remove dependancies to current state (state should be passed in)
|
862 |
*/
|
863 |
+
protected function type_archive($type, $type_str = false)
|
864 |
{
|
865 |
global $wp_taxonomies;
|
866 |
+
if(!isset($type->taxonomy) && $type_str === false) //TODO could probably check the class type here
|
|
|
867 |
{
|
868 |
$type_str = $this->get_type_string_query_var();
|
869 |
}
|
886 |
$breadcrumb = $this->add(new bcn_breadcrumb($this->post_type_archive_title(get_post_type_object($post_type)), $this->opt['Hpost_' . $post_type . '_template'], array('post', 'post-' . $post_type . '-archive'), get_post_type_archive_link($post_type)));
|
887 |
}
|
888 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
889 |
/**
|
890 |
* A Breadcrumb Trail Filling Function
|
891 |
*
|
892 |
* Handles only the root page stuff for post types, including the "page for posts"
|
893 |
+
*
|
894 |
+
* @param string $type_str The type string variable
|
895 |
+
* @param int $root_id The ID for the post type root
|
896 |
+
* @param bool $is_paged Whether or not the current resource is on a page other than page 1
|
897 |
+
* @param bool $is_current_item Whether or not the breadcrumb being generated is the current item
|
898 |
*/
|
899 |
+
protected function do_root($type_str, $root_id, $is_paged = false, $is_current_item = true)
|
900 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
901 |
//Continue only if we have a valid root_id
|
902 |
+
if(is_numeric($root_id))
|
903 |
{
|
904 |
$frontpage_id = get_option('page_on_front');
|
905 |
//We'll have to check if this ID is valid, e.g. user has specified a posts page
|
906 |
if($root_id && $root_id != $frontpage_id)
|
907 |
{
|
908 |
//Place the breadcrumb in the trail, uses the constructor to set the title, template, and type, we get a pointer to it in return
|
909 |
+
$breadcrumb = $this->add(new bcn_breadcrumb(get_the_title($root_id), $this->opt['Hpost_' . $type_str . '_template_no_anchor'], array($type_str . '-root', 'post', 'post-' . $type_str), null, $root_id));
|
910 |
//If we are at home, or any root page archive then we need to add the current item type
|
911 |
+
if($is_current_item)
|
912 |
{
|
913 |
$breadcrumb->add_type('current-item');
|
914 |
}
|
915 |
//If we're not on the current item we need to setup the anchor
|
916 |
+
if(!$is_current_item || ($is_current_item && $this->opt['bcurrent_item_linked']) || ($is_paged && $this->opt['bpaged_display']))
|
|
|
|
|
917 |
{
|
918 |
$breadcrumb->set_template($this->opt['Hpost_' . $type_str . '_template']);
|
919 |
//Figure out the anchor for home page
|
943 |
/**
|
944 |
* A Breadcrumb Trail Filling Function
|
945 |
*
|
946 |
+
* This functions fills a breadcrumb for paged pages
|
947 |
+
*
|
948 |
+
* @param int $page_number The page number to create a breadcrumb for
|
949 |
*/
|
950 |
+
protected function do_paged($page_number)
|
951 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
952 |
//Place the breadcrumb in the trail, uses the bcn_breadcrumb constructor to set the title, prefix, and suffix
|
953 |
+
$this->breadcrumbs[] = new bcn_breadcrumb((string) $page_number, $this->opt['Hpaged_template'], array('paged'));
|
954 |
}
|
955 |
/**
|
956 |
* Breadcrumb Trail Filling Function
|
964 |
if(count($this->breadcrumbs) > 0)
|
965 |
{
|
966 |
//Exit early since we have breadcrumbs in the trail
|
967 |
+
return null;
|
968 |
}
|
969 |
//Do any actions if necessary, we past through the current object instance to keep life simple
|
970 |
do_action('bcn_before_fill', $this);
|
971 |
+
$type = $wp_query->get_queried_object();
|
972 |
//Do specific opperations for the various page types
|
973 |
//Check if this isn't the first of a multi paged item
|
974 |
if($this->opt['bpaged_display'] && (is_paged() || is_singular() && get_query_var('page') > 1))
|
975 |
{
|
976 |
+
//Need to switch between paged and page for archives and singular (posts)
|
977 |
+
if(get_query_var('paged') > 0)
|
978 |
+
{
|
979 |
+
//Can use simple type hinting here to int since we already checked for greater than 0
|
980 |
+
$page_number = (int) abs(get_query_var('paged'));
|
981 |
+
}
|
982 |
+
else
|
983 |
+
{
|
984 |
+
$page_number = (int) abs(get_query_var('page'));
|
985 |
+
}
|
986 |
+
$this->do_paged($page_number);
|
987 |
}
|
988 |
//For the front page, as it may also validate as a page, do it first
|
989 |
if(is_front_page())
|
991 |
//Must have two seperate branches so that we don't evaluate it as a page
|
992 |
if($this->opt['bhome_display'])
|
993 |
{
|
994 |
+
$this->do_home(false, is_paged());
|
995 |
}
|
996 |
}
|
997 |
//For posts
|
998 |
else if(is_singular())
|
999 |
{
|
1000 |
+
$this->do_post(get_post(), false, (get_query_var('page') > 1));
|
1001 |
+
//If this is an attachment then we need to change the queried object to the parent post
|
1002 |
if(is_attachment())
|
1003 |
{
|
1004 |
+
//Could use the $post global, but we can't really trust it
|
1005 |
+
$post = get_post();
|
1006 |
+
$type = get_post($post->post_parent); //TODO check for WP_Error?
|
|
|
|
|
|
|
1007 |
}
|
1008 |
+
$this->do_root($type->post_type, $this->opt['apost_' . $type->post_type . '_root'], is_paged(), false);
|
1009 |
}
|
1010 |
//For searches
|
1011 |
else if(is_search())
|
1012 |
{
|
1013 |
+
$this->do_search(get_search_query(), is_paged());
|
1014 |
}
|
1015 |
//For author pages
|
1016 |
else if(is_author())
|
1017 |
{
|
1018 |
+
$this->do_author($type, is_paged());
|
1019 |
+
$this->do_root('post', get_option('page_for_posts'), is_paged(), false);
|
1020 |
}
|
1021 |
//For archives
|
1022 |
else if(is_archive())
|
1023 |
{
|
|
|
1024 |
//We need the type for later, so save it
|
1025 |
$type_str = get_query_var('post_type');
|
1026 |
//May be an array, if so, rewind the iterator and grab first item
|
1031 |
//For date based archives
|
1032 |
if(is_date())
|
1033 |
{
|
1034 |
+
//First deal with the day breadcrumb
|
1035 |
+
if(is_day())
|
1036 |
+
{
|
1037 |
+
$this->do_day(get_post(), $this->get_type_string_query_var(), is_paged(), true);
|
1038 |
+
}
|
1039 |
+
//Now deal with the month breadcrumb
|
1040 |
+
if(is_month() || is_day())
|
1041 |
+
{
|
1042 |
+
$this->do_month(get_post(), $this->get_type_string_query_var(), is_paged(), is_month());
|
1043 |
+
}
|
1044 |
+
$this->do_year(get_post(), $this->get_type_string_query_var(), is_paged(), is_year());
|
1045 |
+
$type_str = $this->get_type_string_query_var();
|
1046 |
+
$this->type_archive($type, $type_str);
|
1047 |
}
|
1048 |
//If we have a post type archive, and it does not have a root page generate the archive
|
1049 |
else if(is_post_type_archive() && !isset($type->taxonomy)
|
1050 |
&& (!is_numeric($this->opt['apost_' . $type_str . '_root']) || $this->opt['bpost_' . $type_str . '_archive_display']))
|
1051 |
{
|
1052 |
+
$this->do_archive_by_post_type($this->get_type_string_query_var(), is_paged());
|
1053 |
}
|
1054 |
//For taxonomy based archives
|
1055 |
else if(is_category() || is_tag() || is_tax())
|
1056 |
{
|
1057 |
+
$this->do_archive_by_term($type, is_paged());
|
1058 |
$this->type_archive($type);
|
1059 |
+
$type_str = $this->get_type_string_query_var($GLOBALS['wp_taxonomies'][$type->taxonomy]->object_type[0]);
|
1060 |
}
|
1061 |
else
|
1062 |
{
|
1063 |
$this->type_archive($type);
|
1064 |
}
|
1065 |
+
if($type_str !== 'post')
|
1066 |
+
{
|
1067 |
+
$this->do_root($type_str, $this->opt['apost_' . $type_str . '_root'], is_paged(), $this->treat_as_root_page($type_str));
|
1068 |
+
}
|
1069 |
}
|
1070 |
//For 404 pages
|
1071 |
else if(is_404())
|
1074 |
}
|
1075 |
else
|
1076 |
{
|
|
|
|
|
1077 |
//If it looks, walks, and quacks like a taxonomy, treat is as one
|
1078 |
if(isset($type->taxonomy))
|
1079 |
{
|
1080 |
+
$this->do_archive_by_term($type, is_paged());
|
1081 |
$this->type_archive($type);
|
1082 |
+
$type_str = $this->get_type_string_query_var($wp_taxonomies[$type->taxonomy]->object_type[0]);
|
1083 |
+
}
|
1084 |
+
else if($this->opt['bblog_display'])
|
1085 |
+
{
|
1086 |
+
$type_str = 'post';
|
1087 |
}
|
1088 |
+
$this->do_root($type_str, $this->opt['apost_' . $type_str . '_root'], is_paged(), $this->treat_as_root_page($type_str));
|
1089 |
}
|
1090 |
//We always do the home link last, unless on the frontpage
|
1091 |
if(!is_front_page())
|
1092 |
{
|
1093 |
+
$this->do_home(true, false, false);
|
|
|
1094 |
}
|
1095 |
//Do any actions if necessary, we past through the current object instance to keep life simple
|
1096 |
do_action('bcn_after_fill', $this);
|
1117 |
/**
|
1118 |
* This functions outputs or returns the breadcrumb trail in string form.
|
1119 |
*
|
|
|
|
|
1120 |
* @param bool $return Whether to return data or to echo it.
|
1121 |
* @param bool $linked[optional] Whether to allow hyperlinks in the trail or not.
|
1122 |
* @param bool $reverse[optional] Whether to reverse the output or not.
|
1123 |
+
* @param string $template The template to use for the string output.
|
1124 |
*
|
1125 |
+
* @return void Void if Option to print out breadcrumb trail was chosen.
|
1126 |
+
* @return string String-Data of breadcrumb trail.
|
1127 |
*/
|
1128 |
+
public function display($return = false, $linked = true, $reverse = false, $template = '%1$s%2$s')
|
1129 |
{
|
1130 |
//Set trail order based on reverse flag
|
1131 |
$this->order($reverse);
|
|
|
|
|
|
|
1132 |
//The main compiling loop
|
1133 |
+
$trail_str = $this->display_loop($linked, $reverse, $template);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1134 |
//Should we return or echo the assembled trail?
|
1135 |
if($return)
|
1136 |
{
|
1146 |
/**
|
1147 |
* This functions outputs or returns the breadcrumb trail in list form.
|
1148 |
*
|
1149 |
+
* @deprecated 6.0.0 No longer needed, superceeded by $template parameter in display
|
1150 |
+
*
|
1151 |
* @param bool $return Whether to return data or to echo it.
|
1152 |
* @param bool $linked[optional] Whether to allow hyperlinks in the trail or not.
|
1153 |
+
* @param bool $reverse[optional] Whether to reverse the output or not.
|
1154 |
*
|
1155 |
+
* @return void Void if option to print out breadcrumb trail was chosen.
|
1156 |
+
* @return string String version of the breadcrumb trail.
|
1157 |
*/
|
1158 |
public function display_list($return = false, $linked = true, $reverse = false)
|
1159 |
{
|
1160 |
+
_deprecated_function( __FUNCTION__, '6.0', 'bcn_breadcrumb_trail::display');
|
1161 |
+
return $this->display($return, $linked, $reverse, "<li%3\$s>%1\$s</li>\n");
|
1162 |
+
}
|
1163 |
+
/**
|
1164 |
+
* This function assembles the breadcrumbs in the breadcrumb trail in accordance with the passed in template
|
1165 |
+
*
|
1166 |
+
* @param bool $linked Whether to allow hyperlinks in the trail or not.
|
1167 |
+
* @param bool $reverse Whether to reverse the output or not.
|
1168 |
+
* @param string $template The template to use for the string output.
|
1169 |
+
*
|
1170 |
+
* @return string String-Data of breadcrumb trail.
|
1171 |
+
*/
|
1172 |
+
protected function display_loop($linked, $reverse, $template)
|
1173 |
+
{
|
1174 |
+
$position = 1;
|
1175 |
//Initilize the string which will hold the assembled trail
|
1176 |
$trail_str = '';
|
|
|
|
|
1177 |
foreach($this->breadcrumbs as $key => $breadcrumb)
|
1178 |
{
|
1179 |
+
$class = '';
|
1180 |
//On the first run we need to add in a class for the home breadcrumb
|
1181 |
if($trail_str === '')
|
1182 |
{
|
1183 |
+
$class .= ' class="home';
|
1184 |
if($key === 0)
|
1185 |
{
|
1186 |
+
$class .= ' current_item';
|
1187 |
}
|
1188 |
+
$class .= '"';
|
1189 |
}
|
1190 |
//If we are on the current item there are some things that must be done
|
1191 |
else if($key === 0)
|
1192 |
{
|
1193 |
//Add in a class for current_item
|
1194 |
+
$class .= ' class="current_item"';
|
1195 |
+
}
|
1196 |
+
$separator = '';
|
1197 |
+
//Deal with determining if a separator is applicable
|
1198 |
+
if($reverse)
|
1199 |
+
{
|
1200 |
+
if($position > 1)
|
1201 |
+
{
|
1202 |
+
$separator = $this->opt['hseparator'];
|
1203 |
+
}
|
1204 |
+
}
|
1205 |
+
else
|
1206 |
+
{
|
1207 |
+
if($key > 0)
|
1208 |
+
{
|
1209 |
+
$separator = $this->opt['hseparator'];
|
1210 |
+
}
|
1211 |
}
|
1212 |
//Filter li_attributes adding attributes to the li element
|
1213 |
+
$attribs = apply_filters_deprecated('bcn_li_attributes', array($class, $breadcrumb->get_types(), $breadcrumb->get_id()), '6.0.0', 'bcn_display_attributes');
|
1214 |
+
$attribs = apply_filters('bcn_display_attributes', $class, $breadcrumb->get_types(), $breadcrumb->get_id());
|
1215 |
//Trim titles, if requested
|
1216 |
if($this->opt['blimit_title'] && $this->opt['amax_title_length'] > 0)
|
1217 |
{
|
1219 |
$breadcrumb->title_trim($this->opt['amax_title_length']);
|
1220 |
}
|
1221 |
//Assemble the breadrumb and wrap with li's
|
1222 |
+
$trail_str .= sprintf($template, $breadcrumb->assemble($linked, $position), $separator, $attribs);
|
1223 |
$position++;
|
1224 |
}
|
1225 |
+
return $trail_str;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1226 |
}
|
1227 |
/**
|
1228 |
* This functions outputs or returns the breadcrumb trail in Schema.org BreadcrumbList compliant JSON-LD
|
1229 |
*
|
|
|
|
|
1230 |
* @param bool $return Whether to return data or to echo it.
|
1231 |
+
* @param bool $reverse[optional] Whether to reverse the output or not.
|
1232 |
*
|
1233 |
+
* @return void Void if option to print out breadcrumb trail was chosen.
|
1234 |
+
* @return string String version of the breadcrumb trail.
|
1235 |
*/
|
1236 |
public function display_json_ld($return = false, $reverse = false)
|
1237 |
{
|
class.bcn_network_admin.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
-
/*
|
|
|
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
|
@@ -16,56 +17,35 @@
|
|
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 |
-
{
|
22 |
-
//Only purpose of this function is to echo out the PHP version error
|
23 |
-
function bcn_phpold()
|
24 |
-
{
|
25 |
-
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');
|
26 |
-
}
|
27 |
-
//If we are in the admin, let's print a warning then return
|
28 |
-
if(is_admin())
|
29 |
-
{
|
30 |
-
add_action('admin_notices', 'bcn_phpold');
|
31 |
-
}
|
32 |
-
return;
|
33 |
-
}
|
34 |
//Include admin base class
|
35 |
-
if(!class_exists('
|
36 |
{
|
37 |
-
require_once(dirname(__FILE__) . '/
|
38 |
}
|
39 |
/**
|
40 |
* The administrative interface class
|
41 |
*
|
42 |
*/
|
43 |
-
class bcn_network_admin extends
|
44 |
{
|
45 |
-
const version = '
|
46 |
protected $full_name = 'Breadcrumb NavXT Network Settings';
|
47 |
-
protected $short_name = 'Breadcrumb NavXT';
|
48 |
protected $access_level = 'manage_network_options';
|
49 |
-
protected $identifier = 'breadcrumb-navxt';
|
50 |
-
protected $unique_prefix = 'bcn';
|
51 |
-
protected $plugin_basename = null;
|
52 |
-
protected $support_url = 'http://mtekk.us/archives/wordpress/plugins-wordpress/breadcrumb-navxt-';
|
53 |
-
protected $breadcrumb_trail = null;
|
54 |
/**
|
55 |
* Administrative interface class default constructor
|
56 |
* @param bcn_breadcrumb_trail $breadcrumb_trail a breadcrumb trail object
|
57 |
* @param string $basename The basename of the plugin
|
58 |
*/
|
59 |
-
function __construct(bcn_breadcrumb_trail
|
60 |
{
|
61 |
-
|
62 |
-
$
|
|
|
63 |
$this->full_name = __('Breadcrumb NavXT Network Settings', 'breadcrumb-navxt');
|
64 |
-
//
|
65 |
-
$this
|
|
|
66 |
add_action('network_admin_menu', array($this, 'add_page'));
|
67 |
-
//We're going to make sure we load the parent's constructor
|
68 |
-
parent::__construct();
|
69 |
}
|
70 |
/**
|
71 |
* admin initialization callback function
|
@@ -83,7 +63,6 @@ class bcn_network_admin extends mtekk_adminKit
|
|
83 |
function wp_loaded()
|
84 |
{
|
85 |
parent::wp_loaded();
|
86 |
-
breadcrumb_navxt::setup_options($this->opt);
|
87 |
}
|
88 |
/**
|
89 |
* Return the URL of the settings page for the plugin
|
@@ -98,7 +77,7 @@ class bcn_network_admin extends mtekk_adminKit
|
|
98 |
function add_page()
|
99 |
{
|
100 |
//Add the submenu page to "settings" menu
|
101 |
-
$hookname = add_submenu_page('settings.php', $this->full_name, $this->short_name, $this->access_level, $this->identifier, array($this, '
|
102 |
// check capability of user to manage options (access control)
|
103 |
if(current_user_can($this->access_level))
|
104 |
{
|
@@ -155,297 +134,6 @@ class bcn_network_admin extends mtekk_adminKit
|
|
155 |
{
|
156 |
return delete_site_option($option);
|
157 |
}
|
158 |
-
/**
|
159 |
-
* Upgrades input options array, sets to $this->opt
|
160 |
-
*
|
161 |
-
* @param array $opts
|
162 |
-
* @param string $version the version of the passed in options
|
163 |
-
*/
|
164 |
-
function opts_upgrade($opts, $version)
|
165 |
-
{
|
166 |
-
global $wp_post_types, $wp_taxonomies;
|
167 |
-
//If our version is not the same as in the db, time to update
|
168 |
-
if(version_compare($version, $this::version, '<'))
|
169 |
-
{
|
170 |
-
//Upgrading to 3.8.1
|
171 |
-
if(version_compare($version, '3.8.1', '<'))
|
172 |
-
{
|
173 |
-
$opts['post_page_root'] = get_option('page_on_front');
|
174 |
-
$opts['post_post_root'] = get_option('page_for_posts');
|
175 |
-
}
|
176 |
-
//Upgrading to 4.0
|
177 |
-
if(version_compare($version, '4.0.0', '<'))
|
178 |
-
{
|
179 |
-
//Only migrate if we haven't migrated yet
|
180 |
-
if(isset($opts['current_item_linked']))
|
181 |
-
{
|
182 |
-
//Loop through the old options, migrate some of them
|
183 |
-
foreach($opts as $option => $value)
|
184 |
-
{
|
185 |
-
//Handle all of our boolean options first, they're real easy, just add a 'b'
|
186 |
-
if(strpos($option, 'display') > 0 || $option == 'current_item_linked')
|
187 |
-
{
|
188 |
-
$this->breadcrumb_trail->opt['b' . $option] = $value;
|
189 |
-
}
|
190 |
-
//Handle migration of anchor templates to the templates
|
191 |
-
else if(strpos($option, 'anchor') > 0)
|
192 |
-
{
|
193 |
-
$parts = explode('_', $option);
|
194 |
-
//Do excess slash removal sanitation
|
195 |
-
$this->breadcrumb_trail->opt['H' . $parts[0] . '_template'] = $value . '%htitle%</a>';
|
196 |
-
}
|
197 |
-
//Handle our abs integers
|
198 |
-
else if($option == 'max_title_length' || $option == 'post_post_root' || $option == 'post_page_root')
|
199 |
-
{
|
200 |
-
$this->breadcrumb_trail->opt['a' . $option] = $value;
|
201 |
-
}
|
202 |
-
//Now everything else, minus prefix and suffix
|
203 |
-
else if(strpos($option, 'prefix') === false && strpos($option, 'suffix') === false)
|
204 |
-
{
|
205 |
-
$this->breadcrumb_trail->opt['S' . $option] = $value;
|
206 |
-
}
|
207 |
-
}
|
208 |
-
}
|
209 |
-
//Add in the new settings for CPTs introduced in 4.0
|
210 |
-
foreach($wp_post_types as $post_type)
|
211 |
-
{
|
212 |
-
//We only want custom post types
|
213 |
-
if(!$post_type->_builtin)
|
214 |
-
{
|
215 |
-
//Add in the archive_display option
|
216 |
-
$this->breadcrumb_trail->opt['bpost_' . $post_type->name . '_archive_display'] = $post_type->has_archive;
|
217 |
-
}
|
218 |
-
}
|
219 |
-
$opts = $this->breadcrumb_trail->opt;
|
220 |
-
}
|
221 |
-
if(version_compare($version, '4.0.1', '<'))
|
222 |
-
{
|
223 |
-
if(isset($opts['Hcurrent_item_template_no_anchor']))
|
224 |
-
{
|
225 |
-
unset($opts['Hcurrent_item_template_no_anchor']);
|
226 |
-
}
|
227 |
-
if(isset($opts['Hcurrent_item_template']))
|
228 |
-
{
|
229 |
-
unset($opts['Hcurrent_item_template']);
|
230 |
-
}
|
231 |
-
}
|
232 |
-
//Upgrading to 4.3.0
|
233 |
-
if(version_compare($version, '4.3.0', '<'))
|
234 |
-
{
|
235 |
-
//Removed home_title
|
236 |
-
if(isset($opts['Shome_title']))
|
237 |
-
{
|
238 |
-
unset($opts['Shome_title']);
|
239 |
-
}
|
240 |
-
//Removed mainsite_title
|
241 |
-
if(isset($opts['Smainsite_title']))
|
242 |
-
{
|
243 |
-
unset($opts['Smainsite_title']);
|
244 |
-
}
|
245 |
-
}
|
246 |
-
//Upgrading to 5.1.0
|
247 |
-
if(version_compare($version, '5.1.0', '<'))
|
248 |
-
{
|
249 |
-
foreach($wp_taxonomies as $taxonomy)
|
250 |
-
{
|
251 |
-
//If we have the old options style for it, update
|
252 |
-
if($taxonomy->name !== 'post_format' && isset($opts['H' . $taxonomy->name . '_template']))
|
253 |
-
{
|
254 |
-
//Migrate to the new setting name
|
255 |
-
$opts['Htax_' . $taxonomy->name . '_template'] = $opts['H' . $taxonomy->name . '_template'];
|
256 |
-
$opts['Htax_' . $taxonomy->name . '_template_no_anchor'] = $opts['H' . $taxonomy->name . '_template_no_anchor'];
|
257 |
-
//Clean up old settings
|
258 |
-
unset($opts['H' . $taxonomy->name . '_template']);
|
259 |
-
unset($opts['H' . $taxonomy->name . '_template_no_anchor']);
|
260 |
-
}
|
261 |
-
}
|
262 |
-
}
|
263 |
-
//Upgrading to 5.4.0
|
264 |
-
if(version_compare($version, '5.4.0', '<'))
|
265 |
-
{
|
266 |
-
//Migrate users to schema.org breadcrumbs for author and search if still on the defaults for posts
|
267 |
-
if($opts['Hpost_post_template'] === bcn_breadcrumb::get_default_template() && $opts['Hpost_post_template_no_anchor'] === bcn_breadcrumb::default_template_no_anchor)
|
268 |
-
{
|
269 |
-
if($opts['Hpaged_template'] === 'Page %htitle%')
|
270 |
-
{
|
271 |
-
$opts['Hpaged_template'] = $this->opt['Hpaged_template'];
|
272 |
-
}
|
273 |
-
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>'')
|
274 |
-
{
|
275 |
-
$opts['Hsearch_template'] = $this->opt['Hsearch_template'];
|
276 |
-
}
|
277 |
-
if($opts['Hsearch_template_no_anchor'] === 'Search results for '%htitle%'' || $opts['Hsearch_template_no_anchor'] === 'Search results for '%htitle%'')
|
278 |
-
{
|
279 |
-
$opts['Hsearch_template_no_anchor'] = $this->opt['Hsearch_template_no_anchor'];
|
280 |
-
}
|
281 |
-
if($opts['Hauthor_template'] === 'Articles by: <a title="Go to the first page of posts by %title%." href="%link%" class="%type%">%htitle%</a>')
|
282 |
-
{
|
283 |
-
$opts['Hauthor_template'] = $this->opt['Hauthor_template'];
|
284 |
-
}
|
285 |
-
if($opts['Hauthor_template_no_anchor'] === 'Articles by: %htitle%')
|
286 |
-
{
|
287 |
-
$opts['Hauthor_template_no_anchor'] = $this->opt['Hauthor_template_no_anchor'];
|
288 |
-
}
|
289 |
-
}
|
290 |
-
}
|
291 |
-
//Upgrading to 5.5.0
|
292 |
-
if(version_compare($version, '5.5.0', '<'))
|
293 |
-
{
|
294 |
-
//Translate the old 'page' taxonomy type to BCN_POST_PARENT
|
295 |
-
if($this->opt['Spost_post_taxonomy_type'] === 'page')
|
296 |
-
{
|
297 |
-
$this->opt['Spost_post_taxonomy_type'] = 'BCN_POST_PARENT';
|
298 |
-
}
|
299 |
-
if(!isset($this->opt['Spost_post_taxonomy_referer']))
|
300 |
-
{
|
301 |
-
$this->opt['bpost_post_taxonomy_referer'] = false;
|
302 |
-
}
|
303 |
-
//Loop through all of the post types in the array
|
304 |
-
foreach($wp_post_types as $post_type)
|
305 |
-
{
|
306 |
-
//Check for non-public CPTs
|
307 |
-
if(!apply_filters('bcn_show_cpt_private', $post_type->public, $post_type->name))
|
308 |
-
{
|
309 |
-
continue;
|
310 |
-
}
|
311 |
-
//We only want custom post types
|
312 |
-
if(!$post_type->_builtin)
|
313 |
-
{
|
314 |
-
//Translate the old 'page' taxonomy type to BCN_POST_PARENT
|
315 |
-
if($this->opt['Spost_' . $post_type->name . '_taxonomy_type'] === 'page')
|
316 |
-
{
|
317 |
-
$this->opt['Spost_' . $post_type->name . '_taxonomy_type'] = 'BCN_POST_PARENT';
|
318 |
-
}
|
319 |
-
//Translate the old 'date' taxonomy type to BCN_DATE
|
320 |
-
if($this->opt['Spost_' . $post_type->name . '_taxonomy_type'] === 'date')
|
321 |
-
{
|
322 |
-
$this->opt['Spost_' . $post_type->name . '_taxonomy_type'] = 'BCN_DATE';
|
323 |
-
}
|
324 |
-
if(!isset($this->opt['Spost_' . $post_type->name . '_taxonomy_referer']))
|
325 |
-
{
|
326 |
-
$this->opt['bpost_' . $post_type->name . '_taxonomy_referer'] = false;
|
327 |
-
}
|
328 |
-
}
|
329 |
-
}
|
330 |
-
}
|
331 |
-
//S
|
332 |
-
//Set the max title length to 20 if we are not limiting the title and the length was 0
|
333 |
-
if(!$opts['blimit_title'] && $opts['amax_title_length'] == 0)
|
334 |
-
{
|
335 |
-
$opts['amax_title_length'] = 20;
|
336 |
-
}
|
337 |
-
}
|
338 |
-
//Save the passed in opts to the object's option array
|
339 |
-
$this->opt = $opts;
|
340 |
-
//End with resetting up the options
|
341 |
-
breadcrumb_navxt::setup_options($this->opt);
|
342 |
-
}
|
343 |
-
function opts_update_prebk(&$opts)
|
344 |
-
{
|
345 |
-
//Add any new custom post types, or taxonomies
|
346 |
-
breadcrumb_navxt::setup_options($opts);
|
347 |
-
$opts = apply_filters('bcn_opts_update_prebk', $opts);
|
348 |
-
}
|
349 |
-
/**
|
350 |
-
* help action hook function
|
351 |
-
*
|
352 |
-
* @return string
|
353 |
-
*
|
354 |
-
*/
|
355 |
-
function help()
|
356 |
-
{
|
357 |
-
$screen = get_current_screen();
|
358 |
-
//Exit early if the add_help_tab function doesn't exist
|
359 |
-
if(!method_exists($screen, 'add_help_tab'))
|
360 |
-
{
|
361 |
-
return;
|
362 |
-
}
|
363 |
-
//Add contextual help on current screen
|
364 |
-
if($screen->id == 'settings_page_' . $this->identifier)
|
365 |
-
{
|
366 |
-
$general_tab = '<p>' . __('Tips for the settings are located below select options.', 'breadcrumb-navxt') .
|
367 |
-
'</p><h5>' . __('Resources', 'breadcrumb-navxt') . '</h5><ul><li>' .
|
368 |
-
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>' .
|
369 |
-
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>' .
|
370 |
-
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>' .
|
371 |
-
'<h5>' . __('Giving Back', 'breadcrumb-navxt') . '</h5><ul><li>' .
|
372 |
-
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>' .
|
373 |
-
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>';
|
374 |
-
|
375 |
-
$screen->add_help_tab(
|
376 |
-
array(
|
377 |
-
'id' => $this->identifier . '-base',
|
378 |
-
'title' => __('General', 'breadcrumb-navxt'),
|
379 |
-
'content' => $general_tab
|
380 |
-
));
|
381 |
-
$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') .
|
382 |
-
'</p><h5>' . __('Breadcrumb trail with separators', 'breadcrumb-navxt') . '</h5><pre><code><div class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">' . "
|
383 |
-
<?php if(function_exists('bcn_display'))
|
384 |
-
{
|
385 |
-
bcn_display();
|
386 |
-
}?>
|
387 |
-
</div></code></pre>" .
|
388 |
-
'<h5>' . __('Breadcrumb trail in list form', 'breadcrumb-navxt').'</h5><pre><code><ol class="breadcrumbs" typeof="BreadcrumbList" vocab="https://schema.org/">'."
|
389 |
-
<?php if(function_exists('bcn_display_list'))
|
390 |
-
{
|
391 |
-
bcn_display_list();
|
392 |
-
}?>
|
393 |
-
</ol></code></pre>";
|
394 |
-
$screen->add_help_tab(
|
395 |
-
array(
|
396 |
-
'id' => $this->identifier . '-quick-start',
|
397 |
-
'title' => __('Quick Start', 'breadcrumb-navxt'),
|
398 |
-
'content' => $quickstart_tab
|
399 |
-
));
|
400 |
-
$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>' .
|
401 |
-
'<pre><code>.breadcrumbs
|
402 |
-
{
|
403 |
-
font-size: 1.1em;
|
404 |
-
color: #fff;
|
405 |
-
margin: 30px 0 0 10px;
|
406 |
-
position: relative;
|
407 |
-
float: left;
|
408 |
-
}</code></pre>';
|
409 |
-
$screen->add_help_tab(
|
410 |
-
array(
|
411 |
-
'id' => $this->identifier . '-styling',
|
412 |
-
'title' => __('Styling', 'breadcrumb-navxt'),
|
413 |
-
'content' => $styling_tab
|
414 |
-
));
|
415 |
-
$screen->add_help_tab(
|
416 |
-
array(
|
417 |
-
'id' => $this->identifier . '-import-export-reset',
|
418 |
-
'title' => __('Import/Export/Reset', 'breadcrumb-navxt'),
|
419 |
-
'content' => $this->import_form()
|
420 |
-
));
|
421 |
-
}
|
422 |
-
}
|
423 |
-
/**
|
424 |
-
* enqueue's the tab style sheet on the settings page
|
425 |
-
*/
|
426 |
-
function admin_styles()
|
427 |
-
{
|
428 |
-
wp_enqueue_style('mtekk_adminkit_tabs');
|
429 |
-
}
|
430 |
-
/**
|
431 |
-
* enqueue's the tab js and translation js on the settings page
|
432 |
-
*/
|
433 |
-
function admin_scripts()
|
434 |
-
{
|
435 |
-
//Enqueue ui-tabs
|
436 |
-
wp_enqueue_script('jquery-ui-tabs');
|
437 |
-
//Enqueue the admin tabs javascript
|
438 |
-
wp_enqueue_script('mtekk_adminkit_tabs');
|
439 |
-
//Load the translations for the tabs
|
440 |
-
wp_localize_script('mtekk_adminkit_tabs', 'objectL10n', array(
|
441 |
-
'mtad_uid' => 'bcn_admin',
|
442 |
-
'mtad_import' => __('Import', 'breadcrumb-navxt'),
|
443 |
-
'mtad_export' => __('Export', 'breadcrumb-navxt'),
|
444 |
-
'mtad_reset' => __('Reset', 'breadcrumb-navxt'),
|
445 |
-
));
|
446 |
-
//Enqueue the admin enable/disable groups javascript
|
447 |
-
wp_enqueue_script('mtekk_adminkit_engroups');
|
448 |
-
}
|
449 |
/**
|
450 |
* A message function that checks for the BCN_SETTINGS_* define statement
|
451 |
*/
|
@@ -455,7 +143,7 @@ class bcn_network_admin extends mtekk_adminKit
|
|
455 |
{
|
456 |
if(defined('BCN_SETTINGS_USE_LOCAL') && BCN_SETTINGS_USE_LOCAL)
|
457 |
{
|
458 |
-
$this->
|
459 |
}
|
460 |
else if(defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK)
|
461 |
{
|
@@ -463,17 +151,17 @@ class bcn_network_admin extends mtekk_adminKit
|
|
463 |
}
|
464 |
else if(defined('BCN_SETTINGS_FAVOR_LOCAL') && BCN_SETTINGS_FAVOR_LOCAL)
|
465 |
{
|
466 |
-
$this->
|
467 |
}
|
468 |
else if(defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK)
|
469 |
{
|
470 |
-
$this->
|
471 |
}
|
472 |
//Fall through if no settings mode was set
|
473 |
else
|
474 |
{
|
475 |
-
$this->
|
476 |
-
$this->
|
477 |
}
|
478 |
}
|
479 |
}
|
@@ -482,317 +170,24 @@ class bcn_network_admin extends mtekk_adminKit
|
|
482 |
*/
|
483 |
function deprecated_settings_warn()
|
484 |
{
|
485 |
-
|
486 |
-
if(isset($this->opt['blimit_title']) && $this->opt['blimit_title'])
|
487 |
-
{
|
488 |
-
$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>');
|
489 |
-
}
|
490 |
}
|
491 |
/**
|
492 |
-
*
|
|
|
|
|
493 |
*/
|
494 |
-
function
|
495 |
{
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
<div class="wrap"><h2><?php echo $this->full_name; ?></h2>
|
507 |
-
<?php
|
508 |
-
//We exit after the version check if there is an action the user needs to take before saving settings
|
509 |
-
if(!$this->version_check(get_site_option($this->unique_prefix . '_version')))
|
510 |
-
{
|
511 |
-
return;
|
512 |
-
}
|
513 |
-
?>
|
514 |
-
<form action="<?php echo $this->admin_url(); ?>" method="post" id="bcn_admin-options">
|
515 |
-
<?php settings_fields('bcn_options');?>
|
516 |
-
<div id="hasadmintabs">
|
517 |
-
<fieldset id="general" class="bcn_options">
|
518 |
-
<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>
|
519 |
-
<h3><?php _e('General', 'breadcrumb-navxt'); ?></h3>
|
520 |
-
<table class="form-table">
|
521 |
-
<?php
|
522 |
-
$this->input_text(__('Breadcrumb Separator', 'breadcrumb-navxt'), 'hseparator', 'regular-text', false, __('Placed in between each breadcrumb.', 'breadcrumb-navxt'));
|
523 |
-
do_action($this->unique_prefix . '_network_settings_general', $this->opt);
|
524 |
-
?>
|
525 |
-
</table>
|
526 |
-
<h3><?php _e('Current Item', 'breadcrumb-navxt'); ?></h3>
|
527 |
-
<table class="form-table">
|
528 |
-
<?php
|
529 |
-
$this->input_check(__('Link Current Item', 'breadcrumb-navxt'), 'bcurrent_item_linked', __('Yes', 'breadcrumb-navxt'));
|
530 |
-
$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'));
|
531 |
-
$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'));
|
532 |
-
do_action($this->unique_prefix . '_network_settings_current_item', $this->opt);
|
533 |
-
?>
|
534 |
-
</table>
|
535 |
-
<h3><?php _e('Home Breadcrumb', 'breadcrumb-navxt'); ?></h3>
|
536 |
-
<table class="form-table adminkit-engroup">
|
537 |
-
<?php
|
538 |
-
$this->input_check(__('Home Breadcrumb', 'breadcrumb-navxt'), 'bhome_display', __('Place the home breadcrumb in the trail.', 'breadcrumb-navxt'));
|
539 |
-
$this->textbox(__('Home Template', 'breadcrumb-navxt'), 'Hhome_template', '6', false, __('The template for the home breadcrumb.', 'breadcrumb-navxt'));
|
540 |
-
$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'));
|
541 |
-
do_action($this->unique_prefix . '_network_settings_home', $this->opt);
|
542 |
-
?>
|
543 |
-
</table>
|
544 |
-
<h3><?php _e('Blog Breadcrumb', 'breadcrumb-navxt'); ?></h3>
|
545 |
-
<table class="form-table adminkit-engroup">
|
546 |
-
<?php
|
547 |
-
$this->input_check(__('Blog Breadcrumb', 'breadcrumb-navxt'), 'bblog_display', __('Place the blog breadcrumb in the trail.', 'breadcrumb-navxt'));
|
548 |
-
$this->textbox(__('Blog Template', 'breadcrumb-navxt'), 'Hblog_template', '6', false, __('The template for the blog breadcrumb, used only in static front page environments.', 'breadcrumb-navxt'));
|
549 |
-
$this->textbox(__('Blog Template (Unlinked)', 'breadcrumb-navxt'), 'Hblog_template_no_anchor', '4', false , __('The template for the blog breadcrumb, used only in static front page environments and when the breadcrumb is not linked.', 'breadcrumb-navxt'));
|
550 |
-
do_action($this->unique_prefix . '_network_settings_blog', $this->opt);
|
551 |
-
?>
|
552 |
-
</table>
|
553 |
-
<h3><?php _e('Mainsite Breadcrumb', 'breadcrumb-navxt'); ?></h3>
|
554 |
-
<table class="form-table adminkit-engroup">
|
555 |
-
<?php
|
556 |
-
$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'));
|
557 |
-
$this->textbox(__('Main Site Home Template', 'breadcrumb-navxt'), 'Hmainsite_template', '6', false, __('The template for the main site home breadcrumb, used only in multisite environments.', 'breadcrumb-navxt'));
|
558 |
-
$this->textbox(__('Main Site Home Template (Unlinked)', 'breadcrumb-navxt'), 'Hmainsite_template_no_anchor', '4', false, __('The template for the main site home breadcrumb, used only in multisite environments and when the breadcrumb is not linked.', 'breadcrumb-navxt'));
|
559 |
-
do_action($this->unique_prefix . '_network_settings_mainsite', $this->opt);
|
560 |
-
?>
|
561 |
-
</table>
|
562 |
-
<?php do_action($this->unique_prefix . '_after_network_settings_tab_general', $this->opt); ?>
|
563 |
-
</fieldset>
|
564 |
-
<fieldset id="post" class="bcn_options">
|
565 |
-
<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>
|
566 |
-
<h3><?php _e('Posts', 'breadcrumb-navxt'); ?></h3>
|
567 |
-
<table class="form-table adminkit-enset-top">
|
568 |
-
<?php
|
569 |
-
$this->textbox(__('Post Template', 'breadcrumb-navxt'), 'Hpost_post_template', '6', false, __('The template for post breadcrumbs.', 'breadcrumb-navxt'));
|
570 |
-
$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'));
|
571 |
-
$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');
|
572 |
-
$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');
|
573 |
-
?>
|
574 |
-
<tr valign="top">
|
575 |
-
<th scope="row">
|
576 |
-
<?php _e('Post Hierarchy', 'breadcrumb-navxt'); ?>
|
577 |
-
</th>
|
578 |
-
<td>
|
579 |
-
<?php
|
580 |
-
$this->input_radio('Spost_post_taxonomy_type', 'category', __('Categories'), false, 'adminkit-enset');
|
581 |
-
$this->input_radio('Spost_post_taxonomy_type', 'BCN_DATE', __('Dates', 'breadcrumb-navxt'), false, 'adminkit-enset');
|
582 |
-
$this->input_radio('Spost_post_taxonomy_type', 'post_tag', __('Tags'), false, 'adminkit-enset');
|
583 |
-
//We use the value 'page' but really, this will follow the parent post hierarchy
|
584 |
-
$this->input_radio('Spost_post_taxonomy_type', 'BCN_POST_PARENT', __('Post Parent', 'breadcrumb-navxt'), false, 'adminkit-enset');
|
585 |
-
//Loop through all of the taxonomies in the array
|
586 |
-
foreach($wp_taxonomies as $taxonomy)
|
587 |
-
{
|
588 |
-
//Check for non-public taxonomies
|
589 |
-
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name))
|
590 |
-
{
|
591 |
-
continue;
|
592 |
-
}
|
593 |
-
//We only want custom taxonomies
|
594 |
-
if(($taxonomy->object_type == 'post' || is_array($taxonomy->object_type) && in_array('post', $taxonomy->object_type)) && !$taxonomy->_builtin)
|
595 |
-
{
|
596 |
-
$this->input_radio('Spost_post_taxonomy_type', $taxonomy->name, mb_convert_case($taxonomy->label, MB_CASE_TITLE, 'UTF-8'), false, 'adminkit-enset');
|
597 |
-
}
|
598 |
-
}
|
599 |
-
?>
|
600 |
-
<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>
|
601 |
-
</td>
|
602 |
-
</tr>
|
603 |
-
</table>
|
604 |
-
<h3><?php _e('Pages', 'breadcrumb-navxt'); ?></h3>
|
605 |
-
<table class="form-table">
|
606 |
-
<?php
|
607 |
-
$this->textbox(__('Page Template', 'breadcrumb-navxt'), 'Hpost_page_template', '6', false, __('The template for page breadcrumbs.', 'breadcrumb-navxt'));
|
608 |
-
$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'));
|
609 |
-
?>
|
610 |
-
</table>
|
611 |
-
<h3><?php _e('Attachments', 'breadcrumb-navxt'); ?></h3>
|
612 |
-
<table class="form-table">
|
613 |
-
<?php
|
614 |
-
$this->textbox(__('Attachment Template', 'breadcrumb-navxt'), 'Hpost_attachment_template', '6', false, __('The template for attachment breadcrumbs.', 'breadcrumb-navxt'));
|
615 |
-
$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'));
|
616 |
-
?>
|
617 |
-
</table>
|
618 |
-
<?php
|
619 |
-
//Loop through all of the post types in the array
|
620 |
-
foreach($wp_post_types as $post_type)
|
621 |
-
{
|
622 |
-
//Check for non-public CPTs
|
623 |
-
if(!apply_filters('bcn_show_cpt_private', $post_type->public, $post_type->name))
|
624 |
-
{
|
625 |
-
continue;
|
626 |
-
}
|
627 |
-
//We only want custom post types
|
628 |
-
if(!$post_type->_builtin)
|
629 |
-
{
|
630 |
-
$singular_name_lc = mb_strtolower($post_type->labels->singular_name, 'UTF-8');
|
631 |
-
?>
|
632 |
-
<h3><?php echo $post_type->labels->singular_name; ?></h3>
|
633 |
-
<table class="form-table adminkit-enset-top">
|
634 |
-
<?php
|
635 |
-
$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));
|
636 |
-
$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));
|
637 |
-
$optid = $this->get_valid_id('apost_' . $post_type->name . '_root');
|
638 |
-
?>
|
639 |
-
<tr valign="top">
|
640 |
-
<th scope="row">
|
641 |
-
<label for="<?php echo $optid;?>"><?php printf(__('%s Root Page', 'breadcrumb-navxt'), $post_type->labels->singular_name);?></label>
|
642 |
-
</th>
|
643 |
-
<td>
|
644 |
-
<?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']));?>
|
645 |
-
</td>
|
646 |
-
</tr>
|
647 |
-
<?php
|
648 |
-
$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);
|
649 |
-
$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');
|
650 |
-
$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');
|
651 |
-
?>
|
652 |
-
<tr valign="top">
|
653 |
-
<th scope="row">
|
654 |
-
<?php printf(__('%s Hierarchy', 'breadcrumb-navxt'), $post_type->labels->singular_name); ?>
|
655 |
-
</th>
|
656 |
-
<td>
|
657 |
-
<?php
|
658 |
-
//We use the value 'page' but really, this will follow the parent post hierarchy
|
659 |
-
$this->input_radio('Spost_' . $post_type->name . '_taxonomy_type', 'BCN_POST_PARENT', __('Post Parent', 'breadcrumb-navxt'), false, 'adminkit-enset');
|
660 |
-
$this->input_radio('Spost_' . $post_type->name . '_taxonomy_type', 'BCN_DATE', __('Dates', 'breadcrumb-navxt'), false, 'adminkit-enset');
|
661 |
-
//Loop through all of the taxonomies in the array
|
662 |
-
foreach($wp_taxonomies as $taxonomy)
|
663 |
-
{
|
664 |
-
//Check for non-public taxonomies
|
665 |
-
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name))
|
666 |
-
{
|
667 |
-
continue;
|
668 |
-
}
|
669 |
-
//We only want custom taxonomies
|
670 |
-
if($taxonomy->object_type == $post_type->name || in_array($post_type->name, $taxonomy->object_type))
|
671 |
-
{
|
672 |
-
$this->input_radio('Spost_' . $post_type->name . '_taxonomy_type', $taxonomy->name, $taxonomy->labels->singular_name, false, 'adminkit-enset');
|
673 |
-
}
|
674 |
-
}
|
675 |
-
?>
|
676 |
-
<p class="description">
|
677 |
-
<?php
|
678 |
-
if($post_type->hierarchical)
|
679 |
-
{
|
680 |
-
_e('The hierarchy which the breadcrumb trail will show.', 'breadcrumb-navxt');
|
681 |
-
}
|
682 |
-
else
|
683 |
-
{
|
684 |
-
_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');
|
685 |
-
}
|
686 |
-
?>
|
687 |
-
</p>
|
688 |
-
</td>
|
689 |
-
</tr>
|
690 |
-
</table>
|
691 |
-
<?php
|
692 |
-
}
|
693 |
-
}
|
694 |
-
do_action($this->unique_prefix . '_after_network_settings_tab_post', $this->opt);
|
695 |
-
?>
|
696 |
-
</fieldset>
|
697 |
-
<fieldset id="tax" class="bcn_options alttab">
|
698 |
-
<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>
|
699 |
-
<h3><?php _e('Categories', 'breadcrumb-navxt'); ?></h3>
|
700 |
-
<table class="form-table">
|
701 |
-
<?php
|
702 |
-
$this->textbox(__('Category Template', 'breadcrumb-navxt'), 'Htax_category_template', '6', false, __('The template for category breadcrumbs.', 'breadcrumb-navxt'));
|
703 |
-
$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'));
|
704 |
-
?>
|
705 |
-
</table>
|
706 |
-
<h3><?php _e('Tags', 'breadcrumb-navxt'); ?></h3>
|
707 |
-
<table class="form-table">
|
708 |
-
<?php
|
709 |
-
$this->textbox(__('Tag Template', 'breadcrumb-navxt'), 'Htax_post_tag_template', '6', false, __('The template for tag breadcrumbs.', 'breadcrumb-navxt'));
|
710 |
-
$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'));
|
711 |
-
?>
|
712 |
-
</table>
|
713 |
-
<h3><?php _e('Post Formats', 'breadcrumb-navxt'); ?></h3>
|
714 |
-
<table class="form-table">
|
715 |
-
<?php
|
716 |
-
$this->textbox(__('Post Format Template', 'breadcrumb-navxt'), 'Htax_post_format_template', '6', false, __('The template for post format breadcrumbs.', 'breadcrumb-navxt'));
|
717 |
-
$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'));
|
718 |
-
?>
|
719 |
-
</table>
|
720 |
-
<?php
|
721 |
-
//Loop through all of the taxonomies in the array
|
722 |
-
foreach($wp_taxonomies as $taxonomy)
|
723 |
-
{
|
724 |
-
//Check for non-public taxonomies
|
725 |
-
if(!apply_filters('bcn_show_tax_private', $taxonomy->public, $taxonomy->name))
|
726 |
-
{
|
727 |
-
continue;
|
728 |
-
}
|
729 |
-
//We only want custom taxonomies
|
730 |
-
if(!$taxonomy->_builtin)
|
731 |
-
{
|
732 |
-
$label_lc = mb_strtolower($taxonomy->label, 'UTF-8');
|
733 |
-
?>
|
734 |
-
<h3><?php echo mb_convert_case($taxonomy->label, MB_CASE_TITLE, 'UTF-8'); ?></h3>
|
735 |
-
<table class="form-table">
|
736 |
-
<?php
|
737 |
-
$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));
|
738 |
-
$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));
|
739 |
-
?>
|
740 |
-
</table>
|
741 |
-
<?php
|
742 |
-
}
|
743 |
-
}
|
744 |
-
do_action($this->unique_prefix . '_after_network_settings_tab_taxonomy', $this->opt); ?>
|
745 |
-
</fieldset>
|
746 |
-
<fieldset id="miscellaneous" class="bcn_options">
|
747 |
-
<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>
|
748 |
-
<h3><?php _e('Author Archives', 'breadcrumb-navxt'); ?></h3>
|
749 |
-
<table class="form-table">
|
750 |
-
<?php
|
751 |
-
$this->textbox(__('Author Template', 'breadcrumb-navxt'), 'Hauthor_template', '6', false, __('The template for author breadcrumbs.', 'breadcrumb-navxt'));
|
752 |
-
$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'));
|
753 |
-
$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'));
|
754 |
-
?>
|
755 |
-
</table>
|
756 |
-
<h3><?php _e('Miscellaneous', 'breadcrumb-navxt'); ?></h3>
|
757 |
-
<table class="form-table">
|
758 |
-
<?php
|
759 |
-
$this->textbox(__('Date Template', 'breadcrumb-navxt'), 'Hdate_template', '6', false, __('The template for date breadcrumbs.', 'breadcrumb-navxt'));
|
760 |
-
$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'));
|
761 |
-
$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'));
|
762 |
-
$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'));
|
763 |
-
$this->input_text(__('404 Title', 'breadcrumb-navxt'), 'S404_title', 'regular-text');
|
764 |
-
$this->textbox(__('404 Template', 'breadcrumb-navxt'), 'H404_template', '4', false, __('The template for 404 breadcrumbs.', 'breadcrumb-navxt'));
|
765 |
-
?>
|
766 |
-
</table>
|
767 |
-
<h3><?php _e('Deprecated', 'breadcrumb-navxt'); ?></h3>
|
768 |
-
<table class="form-table">
|
769 |
-
<tr valign="top">
|
770 |
-
<th scope="row">
|
771 |
-
<?php _e('Title Length', 'breadcrumb-navxt'); ?>
|
772 |
-
</th>
|
773 |
-
<td>
|
774 |
-
<label>
|
775 |
-
<input name="bcn_options[blimit_title]" type="checkbox" id="blimit_title" value="true" <?php checked(true, $this->opt['blimit_title']); ?> />
|
776 |
-
<?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>');?>
|
777 |
-
</label><br />
|
778 |
-
<ul>
|
779 |
-
<li>
|
780 |
-
<label for="amax_title_length">
|
781 |
-
<?php _e('Max Title Length: ','breadcrumb-navxt');?>
|
782 |
-
<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" />
|
783 |
-
</label>
|
784 |
-
</li>
|
785 |
-
</ul>
|
786 |
-
</td>
|
787 |
-
</tr>
|
788 |
-
</table>
|
789 |
-
<?php do_action($this->unique_prefix . '_after_network_settings_tab_miscellaneous', $this->opt); ?>
|
790 |
-
</fieldset>
|
791 |
-
<?php do_action($this->unique_prefix . '_after_network_settings_tabs', $this->opt); ?>
|
792 |
-
</div>
|
793 |
-
<p class="submit"><input type="submit" class="button-primary" name="bcn_admin_options" value="<?php esc_attr_e('Save Changes') ?>" /></p>
|
794 |
-
</form>
|
795 |
-
</div>
|
796 |
-
<?php
|
797 |
}
|
798 |
}
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
Copyright 2015-2017 John Havlik (email : john.havlik@mtekk.us)
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
*/
|
19 |
require_once(dirname(__FILE__) . '/includes/block_direct_access.php');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
20 |
//Include admin base class
|
21 |
+
if(!class_exists('bcn_admin'))
|
22 |
{
|
23 |
+
require_once(dirname(__FILE__) . '/class.bcn_admin.php');
|
24 |
}
|
25 |
/**
|
26 |
* The administrative interface class
|
27 |
*
|
28 |
*/
|
29 |
+
class bcn_network_admin extends bcn_admin
|
30 |
{
|
31 |
+
const version = '6.0.0';
|
32 |
protected $full_name = 'Breadcrumb NavXT Network Settings';
|
|
|
33 |
protected $access_level = 'manage_network_options';
|
|
|
|
|
|
|
|
|
|
|
34 |
/**
|
35 |
* Administrative interface class default constructor
|
36 |
* @param bcn_breadcrumb_trail $breadcrumb_trail a breadcrumb trail object
|
37 |
* @param string $basename The basename of the plugin
|
38 |
*/
|
39 |
+
function __construct(bcn_breadcrumb_trail &$breadcrumb_trail, $basename)
|
40 |
{
|
41 |
+
//We're going to make sure we load the parent's constructor
|
42 |
+
parent::__construct($breadcrumb_trail, $basename);
|
43 |
+
//Change to the proper name
|
44 |
$this->full_name = __('Breadcrumb NavXT Network Settings', 'breadcrumb-navxt');
|
45 |
+
//Remove the hook added by the parent as we don't want this classes settings page everywhere
|
46 |
+
remove_action('admin_menu', array($this, 'add_page'));
|
47 |
+
//Replace with the network_admin hook
|
48 |
add_action('network_admin_menu', array($this, 'add_page'));
|
|
|
|
|
49 |
}
|
50 |
/**
|
51 |
* admin initialization callback function
|
63 |
function wp_loaded()
|
64 |
{
|
65 |
parent::wp_loaded();
|
|
|
66 |
}
|
67 |
/**
|
68 |
* Return the URL of the settings page for the plugin
|
77 |
function add_page()
|
78 |
{
|
79 |
//Add the submenu page to "settings" menu
|
80 |
+
$hookname = add_submenu_page('settings.php', $this->full_name, $this->short_name, $this->access_level, $this->identifier, array($this, 'admin_page'));
|
81 |
// check capability of user to manage options (access control)
|
82 |
if(current_user_can($this->access_level))
|
83 |
{
|
134 |
{
|
135 |
return delete_site_option($option);
|
136 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
137 |
/**
|
138 |
* A message function that checks for the BCN_SETTINGS_* define statement
|
139 |
*/
|
143 |
{
|
144 |
if(defined('BCN_SETTINGS_USE_LOCAL') && BCN_SETTINGS_USE_LOCAL)
|
145 |
{
|
146 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Individual site settings will override any settings set in this page.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_ns_isiteoveride');
|
147 |
}
|
148 |
else if(defined('BCN_SETTINGS_USE_NETWORK') && BCN_SETTINGS_USE_NETWORK)
|
149 |
{
|
151 |
}
|
152 |
else if(defined('BCN_SETTINGS_FAVOR_LOCAL') && BCN_SETTINGS_FAVOR_LOCAL)
|
153 |
{
|
154 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Individual site settings may override any settings set in this page.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_ns_isitemayoveride');
|
155 |
}
|
156 |
else if(defined('BCN_SETTINGS_FAVOR_NETWORK') && BCN_SETTINGS_FAVOR_NETWORK)
|
157 |
{
|
158 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Individual site settings may override any settings set in this page.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_ns_nsmayoveride');
|
159 |
}
|
160 |
//Fall through if no settings mode was set
|
161 |
else
|
162 |
{
|
163 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: No BCN_SETTINGS_* define statement found, defaulting to BCN_SETTINGS_USE_LOCAL.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_ns_nosetting');
|
164 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Warning: Individual site settings will override any settings set in this page.', 'breadcrumb-navxt'), 'warning', true, $this->unique_prefix . '_msg_ns_isiteoveride');
|
165 |
}
|
166 |
}
|
167 |
}
|
170 |
*/
|
171 |
function deprecated_settings_warn()
|
172 |
{
|
173 |
+
parent::deprecated_settings_warn();
|
|
|
|
|
|
|
|
|
174 |
}
|
175 |
/**
|
176 |
+
* Function checks the current site to see if the blog options should be disabled
|
177 |
+
*
|
178 |
+
* @return boool Whether or not the blog options should be disabled
|
179 |
*/
|
180 |
+
function maybe_disable_blog_options()
|
181 |
{
|
182 |
+
return false;
|
183 |
+
}
|
184 |
+
/**
|
185 |
+
* Function checks the current site to see if the mainsite options should be disabled
|
186 |
+
*
|
187 |
+
* @return bool Whether or not the mainsite options should be disabled
|
188 |
+
*/
|
189 |
+
function maybe_disable_mainsite_options()
|
190 |
+
{
|
191 |
+
return false;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
192 |
}
|
193 |
}
|
class.bcn_widget.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
-
Copyright
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
@@ -19,11 +19,14 @@
|
|
19 |
require_once(dirname(__FILE__) . '/includes/block_direct_access.php');
|
20 |
class bcn_widget extends WP_Widget
|
21 |
{
|
22 |
-
const version = '
|
|
|
23 |
protected $defaults = array('title' => '', 'pretext' => '', 'type' => 'microdata', 'linked' => true, 'reverse' => false, 'front' => false, 'force' => false);
|
24 |
//Default constructor
|
25 |
function __construct()
|
26 |
{
|
|
|
|
|
27 |
//@see https://core.trac.wordpress.org/ticket/10527
|
28 |
if(!is_textdomain_loaded('breadcrumb-navxt'))
|
29 |
{
|
@@ -38,6 +41,7 @@ class bcn_widget extends WP_Widget
|
|
38 |
$instance = wp_parse_args((array) $instance, $this->defaults);
|
39 |
$instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
|
40 |
$instance['pretext'] = apply_filters('widget_text', $instance['pretext'], $instance);
|
|
|
41 |
//A bit of a hack but we need the DB settings to know if we should exit early
|
42 |
$opt = get_option('bcn_options');
|
43 |
//If we are on the front page and don't display on the front, return early
|
@@ -47,21 +51,21 @@ class bcn_widget extends WP_Widget
|
|
47 |
}
|
48 |
//Manditory before widget junk
|
49 |
echo $args['before_widget'];
|
50 |
-
if(!empty($
|
51 |
{
|
52 |
-
echo $args['before_title'] . $
|
53 |
}
|
54 |
//We'll want to switch between the two breadcrumb output types
|
55 |
if($instance['type'] == 'list')
|
56 |
{
|
57 |
//Display the list output breadcrumb
|
58 |
-
echo $instance['pretext'] . '<ol class="breadcrumb_trail breadcrumbs">';
|
59 |
bcn_display_list(false, $instance['linked'], $instance['reverse'], $instance['force']);
|
60 |
echo '</ol>';
|
61 |
}
|
62 |
else if($instance['type'] == 'microdata')
|
63 |
{
|
64 |
-
echo '<div class="breadcrumbs" vocab="https://schema.org/" typeof="BreadcrumbList">' . $instance['pretext'];
|
65 |
//Display the regular output breadcrumb
|
66 |
bcn_display(false, $instance['linked'], $instance['reverse'], $instance['force']);
|
67 |
echo '</div>';
|
@@ -69,7 +73,7 @@ class bcn_widget extends WP_Widget
|
|
69 |
else if($instance['type'] == 'plain')
|
70 |
{
|
71 |
//Display the pretext
|
72 |
-
echo $instance['pretext'];
|
73 |
//Display the regular output breadcrumb
|
74 |
bcn_display(false, $instance['linked'], $instance['reverse'], $instance['force']);
|
75 |
}
|
@@ -85,7 +89,7 @@ class bcn_widget extends WP_Widget
|
|
85 |
{
|
86 |
//Filter out anything that could be invalid
|
87 |
$old_instance['title'] = strip_tags($new_instance['title']);
|
88 |
-
$old_instance['pretext'] =
|
89 |
$old_instance['type'] = strip_tags($new_instance['type']);
|
90 |
$old_instance['linked'] = isset($new_instance['linked']);
|
91 |
$old_instance['reverse'] = isset($new_instance['reverse']);
|
@@ -97,16 +101,16 @@ class bcn_widget extends WP_Widget
|
|
97 |
{
|
98 |
$instance = wp_parse_args((array) $instance, $this->defaults);?>
|
99 |
<p>
|
100 |
-
<label for="<?php echo $this->get_field_id('title'); ?>"> <?php _e('Title:', 'breadcrumb-navxt'); ?></label>
|
101 |
-
<input class="widefat" type="text" name="<?php echo $this->get_field_name('title'); ?>" id="<?php echo $this->get_field_id('title'); ?>" value="<?php echo esc_attr($instance['title']);?>" />
|
102 |
</p>
|
103 |
<p>
|
104 |
-
<label for="<?php echo $this->get_field_id('pretext'); ?>"> <?php _e('Text to show before the trail:', 'breadcrumb-navxt'); ?></label>
|
105 |
-
<input class="widefat" type="text" name="<?php echo $this->get_field_name('pretext'); ?>" id="<?php echo $this->get_field_id('pretext'); ?>" value="<?php echo esc_attr($instance['pretext']);?>" />
|
106 |
</p>
|
107 |
<p>
|
108 |
-
<label for="<?php echo $this->get_field_id('type'); ?>"> <?php _e('Output trail as:', 'breadcrumb-navxt'); ?></label>
|
109 |
-
<select name="<?php echo $this->get_field_name('type'); ?>" id="<?php echo $this->get_field_id('type'); ?>">
|
110 |
<option value="list" <?php selected('list', $instance['type']);?>><?php _e('List', 'breadcrumb-navxt'); ?></option>
|
111 |
<option value="microdata" <?php selected('microdata', $instance['type']);?>><?php _e('Google (RDFa) Breadcrumbs', 'breadcrumb-navxt'); ?></option>
|
112 |
<option value="plain" <?php selected('plain', $instance['type']);?>><?php _e('Plain', 'breadcrumb-navxt'); ?></option>
|
@@ -114,14 +118,14 @@ class bcn_widget extends WP_Widget
|
|
114 |
</select>
|
115 |
</p>
|
116 |
<p>
|
117 |
-
<input class="checkbox" type="checkbox" name="<?php echo $this->get_field_name('linked'); ?>" id="<?php echo $this->get_field_id('linked'); ?>" value="true" <?php checked(true, $instance['linked']);?> />
|
118 |
-
<label for="<?php echo $this->get_field_id('linked'); ?>"> <?php _e('Link the breadcrumbs', 'breadcrumb-navxt'); ?></label><br />
|
119 |
-
<input class="checkbox" type="checkbox" name="<?php echo $this->get_field_name('reverse'); ?>" id="<?php echo $this->get_field_id('reverse'); ?>" value="true" <?php checked(true, $instance['reverse']);?> />
|
120 |
-
<label for="<?php echo $this->get_field_id('reverse'); ?>"> <?php _e('Reverse the order of the trail', 'breadcrumb-navxt'); ?></label><br />
|
121 |
-
<input class="checkbox" type="checkbox" name="<?php echo $this->get_field_name('front'); ?>" id="<?php echo $this->get_field_id('front'); ?>" value="true" <?php checked(true, $instance['front']);?> />
|
122 |
-
<label for="<?php echo $this->get_field_id('front'); ?>"> <?php _e('Hide the trail on the front page', 'breadcrumb-navxt'); ?></label><br />
|
123 |
-
<input class="checkbox" type="checkbox" name="<?php echo $this->get_field_name('force'); ?>" id="<?php echo $this->get_field_id('force'); ?>" value="true" <?php checked(true, $instance['force']);?> />
|
124 |
-
<label for="<?php echo $this->get_field_id('force'); ?>"> <?php _e('Ignore breadcrumb cache', 'breadcrumb-navxt'); ?></label><br />
|
125 |
</p>
|
126 |
<?php
|
127 |
}
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
Copyright 2015-2017 John Havlik (email : john.havlik@mtekk.us)
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
19 |
require_once(dirname(__FILE__) . '/includes/block_direct_access.php');
|
20 |
class bcn_widget extends WP_Widget
|
21 |
{
|
22 |
+
const version = '6.0.0';
|
23 |
+
protected $allowed_html = array();
|
24 |
protected $defaults = array('title' => '', 'pretext' => '', 'type' => 'microdata', 'linked' => true, 'reverse' => false, 'front' => false, 'force' => false);
|
25 |
//Default constructor
|
26 |
function __construct()
|
27 |
{
|
28 |
+
//Filter allowed_html array to allow others to add acceptable tags
|
29 |
+
$this->allowed_html = apply_filters('bcn_allowed_html', wp_kses_allowed_html('post'));
|
30 |
//@see https://core.trac.wordpress.org/ticket/10527
|
31 |
if(!is_textdomain_loaded('breadcrumb-navxt'))
|
32 |
{
|
41 |
$instance = wp_parse_args((array) $instance, $this->defaults);
|
42 |
$instance['title'] = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
|
43 |
$instance['pretext'] = apply_filters('widget_text', $instance['pretext'], $instance);
|
44 |
+
$title = apply_filters('widget_title', $instance['title'], $instance, $this->id_base);
|
45 |
//A bit of a hack but we need the DB settings to know if we should exit early
|
46 |
$opt = get_option('bcn_options');
|
47 |
//If we are on the front page and don't display on the front, return early
|
51 |
}
|
52 |
//Manditory before widget junk
|
53 |
echo $args['before_widget'];
|
54 |
+
if(!empty($title))
|
55 |
{
|
56 |
+
echo $args['before_title'] . $title . $args['after_title'];
|
57 |
}
|
58 |
//We'll want to switch between the two breadcrumb output types
|
59 |
if($instance['type'] == 'list')
|
60 |
{
|
61 |
//Display the list output breadcrumb
|
62 |
+
echo wp_kses($instance['pretext'], $this->allowed_html) . '<ol class="breadcrumb_trail breadcrumbs">';
|
63 |
bcn_display_list(false, $instance['linked'], $instance['reverse'], $instance['force']);
|
64 |
echo '</ol>';
|
65 |
}
|
66 |
else if($instance['type'] == 'microdata')
|
67 |
{
|
68 |
+
echo '<div class="breadcrumbs" vocab="https://schema.org/" typeof="BreadcrumbList">' . wp_kses($instance['pretext'], $this->allowed_html);
|
69 |
//Display the regular output breadcrumb
|
70 |
bcn_display(false, $instance['linked'], $instance['reverse'], $instance['force']);
|
71 |
echo '</div>';
|
73 |
else if($instance['type'] == 'plain')
|
74 |
{
|
75 |
//Display the pretext
|
76 |
+
echo wp_kses($instance['pretext'], $this->allowed_html);
|
77 |
//Display the regular output breadcrumb
|
78 |
bcn_display(false, $instance['linked'], $instance['reverse'], $instance['force']);
|
79 |
}
|
89 |
{
|
90 |
//Filter out anything that could be invalid
|
91 |
$old_instance['title'] = strip_tags($new_instance['title']);
|
92 |
+
$old_instance['pretext'] = wp_kses($new_instance['pretext'], $this->allowed_html);
|
93 |
$old_instance['type'] = strip_tags($new_instance['type']);
|
94 |
$old_instance['linked'] = isset($new_instance['linked']);
|
95 |
$old_instance['reverse'] = isset($new_instance['reverse']);
|
101 |
{
|
102 |
$instance = wp_parse_args((array) $instance, $this->defaults);?>
|
103 |
<p>
|
104 |
+
<label for="<?php echo esc_attr($this->get_field_id('title')); ?>"> <?php _e('Title:', 'breadcrumb-navxt'); ?></label>
|
105 |
+
<input class="widefat" type="text" name="<?php echo esc_attr($this->get_field_name('title')); ?>" id="<?php echo esc_attr($this->get_field_id('title')); ?>" value="<?php echo esc_attr($instance['title']);?>" />
|
106 |
</p>
|
107 |
<p>
|
108 |
+
<label for="<?php echo esc_attr($this->get_field_id('pretext')); ?>"> <?php _e('Text to show before the trail:', 'breadcrumb-navxt'); ?></label>
|
109 |
+
<input class="widefat" type="text" name="<?php echo esc_attr($this->get_field_name('pretext')); ?>" id="<?php echo esc_attr($this->get_field_id('pretext')); ?>" value="<?php echo esc_attr($instance['pretext']);?>" />
|
110 |
</p>
|
111 |
<p>
|
112 |
+
<label for="<?php echo esc_attr($this->get_field_id('type')); ?>"> <?php _e('Output trail as:', 'breadcrumb-navxt'); ?></label>
|
113 |
+
<select name="<?php echo esc_attr($this->get_field_name('type')); ?>" id="<?php echo esc_attr($this->get_field_id('type')); ?>">
|
114 |
<option value="list" <?php selected('list', $instance['type']);?>><?php _e('List', 'breadcrumb-navxt'); ?></option>
|
115 |
<option value="microdata" <?php selected('microdata', $instance['type']);?>><?php _e('Google (RDFa) Breadcrumbs', 'breadcrumb-navxt'); ?></option>
|
116 |
<option value="plain" <?php selected('plain', $instance['type']);?>><?php _e('Plain', 'breadcrumb-navxt'); ?></option>
|
118 |
</select>
|
119 |
</p>
|
120 |
<p>
|
121 |
+
<input class="checkbox" type="checkbox" name="<?php echo esc_attr($this->get_field_name('linked')); ?>" id="<?php echo esc_attr($this->get_field_id('linked')); ?>" value="true" <?php checked(true, $instance['linked']);?> />
|
122 |
+
<label for="<?php echo esc_attr($this->get_field_id('linked')); ?>"> <?php _e('Link the breadcrumbs', 'breadcrumb-navxt'); ?></label><br />
|
123 |
+
<input class="checkbox" type="checkbox" name="<?php echo esc_attr($this->get_field_name('reverse')); ?>" id="<?php echo esc_attr($this->get_field_id('reverse')); ?>" value="true" <?php checked(true, $instance['reverse']);?> />
|
124 |
+
<label for="<?php echo esc_attr($this->get_field_id('reverse')); ?>"> <?php _e('Reverse the order of the trail', 'breadcrumb-navxt'); ?></label><br />
|
125 |
+
<input class="checkbox" type="checkbox" name="<?php echo esc_attr($this->get_field_name('front')); ?>" id="<?php echo esc_attr($this->get_field_id('front')); ?>" value="true" <?php checked(true, $instance['front']);?> />
|
126 |
+
<label for="<?php echo esc_attr($this->get_field_id('front')); ?>"> <?php _e('Hide the trail on the front page', 'breadcrumb-navxt'); ?></label><br />
|
127 |
+
<input class="checkbox" type="checkbox" name="<?php echo esc_attr($this->get_field_name('force')); ?>" id="<?php echo esc_attr($this->get_field_id('force')); ?>" value="true" <?php checked(true, $instance['force']);?> />
|
128 |
+
<label for="<?php echo esc_attr($this->get_field_id('force')); ?>"> <?php _e('Ignore breadcrumb cache', 'breadcrumb-navxt'); ?></label><br />
|
129 |
</p>
|
130 |
<?php
|
131 |
}
|
includes/block_direct_access.php
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
<?php
|
2 |
-
/*
|
|
|
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
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
Copyright 2015-2017 John Havlik (email : john.havlik@mtekk.us)
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
includes/class.mtekk_adminkit.php
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
-
Copyright
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
@@ -17,9 +17,14 @@
|
|
17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
*/
|
19 |
require_once(dirname(__FILE__) . '/block_direct_access.php');
|
|
|
|
|
|
|
|
|
|
|
20 |
abstract class mtekk_adminKit
|
21 |
{
|
22 |
-
const version = '
|
23 |
protected $full_name;
|
24 |
protected $short_name;
|
25 |
protected $plugin_basename;
|
@@ -27,11 +32,14 @@ abstract class mtekk_adminKit
|
|
27 |
protected $identifier;
|
28 |
protected $unique_prefix;
|
29 |
protected $opt = array();
|
|
|
30 |
protected $message;
|
31 |
protected $support_url;
|
32 |
protected $allowed_html;
|
33 |
function __construct()
|
34 |
{
|
|
|
|
|
35 |
//Admin Init Hook
|
36 |
add_action('admin_init', array($this, 'init'));
|
37 |
//WordPress Admin interface hook
|
@@ -91,7 +99,7 @@ abstract class mtekk_adminKit
|
|
91 |
//Assemble our url, nonce and all
|
92 |
$url = wp_nonce_url(add_query_arg($this->unique_prefix . '_' . $mode, $value, $uri), $this->unique_prefix . '_' . $mode);
|
93 |
//Return a valid anchor
|
94 |
-
return ' <a title="' . $title . '" href="' . $url . '" '. $anchor_extras . '>' . $text . '</a>';
|
95 |
}
|
96 |
/**
|
97 |
* Abstracts the check_admin_referer so that all the end user has to supply is the mode
|
@@ -167,6 +175,8 @@ abstract class mtekk_adminKit
|
|
167 |
{
|
168 |
$suffix = '.min';
|
169 |
}
|
|
|
|
|
170 |
//Register JS for enable/disable settings groups
|
171 |
wp_register_script('mtekk_adminkit_engroups', plugins_url('/mtekk_adminkit_engroups' . $suffix . '.js', dirname(__FILE__) . '/mtekk_adminkit_engroups' . $suffix . '.js'), array('jquery'), self::version, true);
|
172 |
//Register JS for tabs
|
@@ -179,6 +189,7 @@ abstract class mtekk_adminKit
|
|
179 |
$this->opt = $this::parse_args($this->get_option($this->unique_prefix . '_options'), $this->opt);
|
180 |
//Run the opts fix filter
|
181 |
$this->opts_fix($this->opt);
|
|
|
182 |
}
|
183 |
/**
|
184 |
* Adds the adminpage the menu and the nice little settings link
|
@@ -233,7 +244,7 @@ abstract class mtekk_adminKit
|
|
233 |
if($file == $this->plugin_basename)
|
234 |
{
|
235 |
//Add our link to the end of the array to better integrate into the WP 2.8 plugins page
|
236 |
-
$links[] = '<a href="' . $this->admin_url() . '">' .
|
237 |
}
|
238 |
return $links;
|
239 |
}
|
@@ -309,7 +320,8 @@ abstract class mtekk_adminKit
|
|
309 |
if($version && version_compare($version, $this::version, '<') && is_array($this->opt))
|
310 |
{
|
311 |
//Throw an error since the DB version is out of date
|
312 |
-
$this->
|
|
|
313 |
//Output any messages that there may be
|
314 |
$this->messages();
|
315 |
return false;
|
@@ -318,7 +330,8 @@ abstract class mtekk_adminKit
|
|
318 |
else if($version && version_compare($version, $this::version, '>') && is_array($this->opt))
|
319 |
{
|
320 |
//Let the user know that their settings are for a newer version
|
321 |
-
$this->
|
|
|
322 |
//Output any messages that there may be
|
323 |
$this->messages();
|
324 |
return true;
|
@@ -326,7 +339,8 @@ abstract class mtekk_adminKit
|
|
326 |
else if(!is_array($this->opt))
|
327 |
{
|
328 |
//Throw an error since it appears the options were never registered
|
329 |
-
$this->
|
|
|
330 |
//Output any messages that there may be
|
331 |
$this->messages();
|
332 |
return false;
|
@@ -334,7 +348,8 @@ abstract class mtekk_adminKit
|
|
334 |
else if(!$this->opts_validate($this->opt))
|
335 |
{
|
336 |
//Throw an error since it appears the options contain invalid data
|
337 |
-
$this->
|
|
|
338 |
//Output any messages that there may be
|
339 |
$this->messages();
|
340 |
return false;
|
@@ -396,7 +411,7 @@ abstract class mtekk_adminKit
|
|
396 |
break;
|
397 |
//Handle the absolute integer options
|
398 |
case 'a':
|
399 |
-
$opts[$option] =
|
400 |
break;
|
401 |
//Handle the floating point options
|
402 |
case 'f':
|
@@ -404,7 +419,6 @@ abstract class mtekk_adminKit
|
|
404 |
break;
|
405 |
//Handle the HTML options
|
406 |
case 'h':
|
407 |
-
//May be better to use wp_kses here
|
408 |
$opts[$option] = wp_kses(stripslashes($input[$option]), $this->allowed_html);
|
409 |
break;
|
410 |
//Handle the HTML options that must not be null
|
@@ -533,26 +547,28 @@ abstract class mtekk_adminKit
|
|
533 |
if($updated && count(array_diff_key($input, $this->opt)) == 0)
|
534 |
{
|
535 |
//Let the user know everything went ok
|
536 |
-
$this->
|
|
|
537 |
}
|
538 |
else if(!$updated && count(array_diff_key($opt_prev, $this->opt)) == 0)
|
539 |
{
|
540 |
-
$this->
|
541 |
}
|
542 |
else if(!$updated)
|
543 |
{
|
544 |
-
$this->
|
545 |
}
|
546 |
else
|
547 |
{
|
548 |
//Let the user know the following were not saved
|
549 |
-
$this->
|
550 |
-
|
|
|
551 |
foreach(array_diff_key($input, $this->opt) as $setting => $value)
|
552 |
{
|
553 |
$temp .= '<br />' . $setting;
|
554 |
}
|
555 |
-
$this->
|
556 |
}
|
557 |
add_action('admin_notices', array($this, 'messages'));
|
558 |
}
|
@@ -651,12 +667,13 @@ abstract class mtekk_adminKit
|
|
651 |
//Commit the loaded options to the database
|
652 |
$this->update_option($this->unique_prefix . '_options', $this->opt);
|
653 |
//Everything was successful, let the user know
|
654 |
-
$this->
|
|
|
655 |
}
|
656 |
else
|
657 |
{
|
658 |
//Throw an error since we could not load the file for various reasons
|
659 |
-
$this->
|
660 |
}
|
661 |
//Reset to the default error handler after we're done
|
662 |
restore_error_handler();
|
@@ -675,7 +692,8 @@ abstract class mtekk_adminKit
|
|
675 |
//Load in the hard coded default option values
|
676 |
$this->update_option($this->unique_prefix . '_options', $this->opt);
|
677 |
//Reset successful, let the user know
|
678 |
-
$this->
|
|
|
679 |
add_action('admin_notices', array($this, 'messages'));
|
680 |
}
|
681 |
/**
|
@@ -692,7 +710,8 @@ abstract class mtekk_adminKit
|
|
692 |
//Set the backup options to the undone options
|
693 |
$this->update_option($this->unique_prefix . '_options_bk', $opt);
|
694 |
//Send the success/undo message
|
695 |
-
$this->
|
|
|
696 |
add_action('admin_notices', array($this, 'messages'));
|
697 |
}
|
698 |
/**
|
@@ -727,14 +746,14 @@ abstract class mtekk_adminKit
|
|
727 |
//Store the options
|
728 |
$this->update_option($this->unique_prefix . '_options', $this->opt);
|
729 |
//Send the success message
|
730 |
-
$this->
|
731 |
}
|
732 |
else
|
733 |
{
|
734 |
//Run the install script
|
735 |
$this->install();
|
736 |
//Send the success message
|
737 |
-
$this->
|
738 |
}
|
739 |
add_action('admin_notices', array($this, 'messages'));
|
740 |
}
|
@@ -753,24 +772,41 @@ abstract class mtekk_adminKit
|
|
753 |
|
754 |
}
|
755 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
756 |
/**
|
757 |
* Prints to screen all of the messages stored in the message member variable
|
758 |
*/
|
759 |
function messages()
|
760 |
{
|
|
|
|
|
|
|
|
|
|
|
761 |
if(count($this->message))
|
762 |
{
|
|
|
763 |
//Loop through our message classes
|
764 |
foreach($this->message as $key => $class)
|
765 |
{
|
766 |
//Loop through the messages in the current class
|
767 |
foreach($class as $message)
|
768 |
{
|
769 |
-
printf('<div class="%s"><p>%s</p></div>', $key, $message);
|
770 |
}
|
771 |
}
|
|
|
772 |
}
|
773 |
-
$this->
|
774 |
}
|
775 |
/**
|
776 |
* Function prototype to prevent errors
|
@@ -784,21 +820,21 @@ abstract class mtekk_adminKit
|
|
784 |
*/
|
785 |
function admin_scripts()
|
786 |
{
|
787 |
-
|
788 |
}
|
789 |
/**
|
790 |
* Function prototype to prevent errors
|
791 |
*/
|
792 |
function admin_head()
|
793 |
{
|
794 |
-
|
795 |
}
|
796 |
/**
|
797 |
* Function prototype to prevent errors
|
798 |
*/
|
799 |
function admin_page()
|
800 |
{
|
801 |
-
|
802 |
}
|
803 |
/**
|
804 |
* Function prototype to prevent errors
|
@@ -809,11 +845,10 @@ abstract class mtekk_adminKit
|
|
809 |
}
|
810 |
/**
|
811 |
* Returns a valid xHTML element ID
|
812 |
-
*
|
813 |
* @param object $option
|
814 |
-
* @return
|
815 |
*/
|
816 |
-
function get_valid_id($option)
|
817 |
{
|
818 |
if(is_numeric($option[0]))
|
819 |
{
|
@@ -827,66 +862,76 @@ abstract class mtekk_adminKit
|
|
827 |
function import_form()
|
828 |
{
|
829 |
$form = '<div id="mtekk_admin_import_export_relocate">';
|
830 |
-
$form .= sprintf('<form action="options-general.php?page=%s" method="post" enctype="multipart/form-data" id="%s_admin_upload">', $this->identifier, $this->unique_prefix);
|
831 |
$form .= wp_nonce_field($this->unique_prefix . '_admin_import_export', '_wpnonce', true, false);
|
832 |
-
$form .= sprintf('<fieldset id="import_export" class="%s_options">', $this->unique_prefix);
|
833 |
-
$form .= '<p>' .
|
834 |
$form .= '<table class="form-table"><tr valign="top"><th scope="row">';
|
835 |
-
$form .= sprintf('<label for="%s_admin_import_file">', $this->unique_prefix);
|
836 |
-
$form .=
|
837 |
$form .= '</label></th><td>';
|
838 |
-
$form .= sprintf('<input type="file" name="%s_admin_import_file" id="%s_admin_import_file" size="32" /><p class="description">', $this->unique_prefix
|
839 |
-
$form .=
|
840 |
$form .= '</p></td></tr></table><p class="submit">';
|
841 |
-
$form .= sprintf('<input type="submit" class="button" name="%s_admin_import" value="
|
842 |
-
$form .= sprintf('<input type="submit" class="button" name="%s_admin_export" value="'
|
843 |
-
$form .= sprintf('<input type="submit" class="button" name="%s_admin_reset" value="
|
844 |
$form .= '</p></fieldset></form></div>';
|
845 |
return $form;
|
846 |
}
|
847 |
/**
|
848 |
* This will output a well formed hidden option
|
849 |
-
*
|
850 |
* @param string $option
|
851 |
-
* @return
|
852 |
*/
|
853 |
function input_hidden($option)
|
854 |
{
|
855 |
-
$
|
856 |
-
|
857 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
858 |
}
|
859 |
/**
|
860 |
* This will output a well formed table row for a text input
|
861 |
-
*
|
862 |
* @param string $label
|
863 |
* @param string $option
|
864 |
* @param string $class (optional)
|
865 |
* @param bool $disable (optional)
|
866 |
* @param string $description (optional)
|
867 |
-
* @return
|
868 |
*/
|
869 |
function input_text($label, $option, $class = 'regular-text', $disable = false, $description = '')
|
870 |
{
|
871 |
-
$
|
|
|
872 |
if($disable)
|
873 |
-
{
|
874 |
-
|
875 |
-
|
|
|
876 |
<tr valign="top">
|
877 |
<th scope="row">
|
878 |
-
|
879 |
</th>
|
880 |
<td>
|
881 |
-
<input type="text" name="
|
882 |
-
|
883 |
</td>
|
884 |
</tr>
|
885 |
<?php
|
886 |
}
|
887 |
/**
|
888 |
* This will output a well formed table row for a HTML5 number input
|
889 |
-
*
|
890 |
* @param string $label
|
891 |
* @param string $option
|
892 |
* @param string $class (optional)
|
@@ -895,61 +940,65 @@ abstract class mtekk_adminKit
|
|
895 |
* @param int|string $min (optional)
|
896 |
* @param int|string $max (optional)
|
897 |
* @param int|string $step (optional)
|
898 |
-
* @return
|
899 |
*/
|
900 |
function input_number($label, $option, $class = 'small-text', $disable = false, $description = '', $min = '', $max = '', $step = '')
|
901 |
{
|
902 |
-
$
|
|
|
903 |
$extras = '';
|
904 |
if($min !== '')
|
905 |
{
|
906 |
-
$extras .= 'min="' . $min . '" ';
|
907 |
}
|
908 |
if($max !== '')
|
909 |
{
|
910 |
-
$extras .= 'max="' . $max . '" ';
|
911 |
}
|
912 |
if($step !== '')
|
913 |
{
|
914 |
-
$extras .= 'step="' . $step . '" ';
|
915 |
}
|
916 |
if($disable)
|
917 |
-
{
|
918 |
-
|
919 |
-
|
|
|
920 |
<tr valign="top">
|
921 |
<th scope="row">
|
922 |
-
|
923 |
</th>
|
924 |
<td>
|
925 |
-
<input type="number" name="
|
926 |
-
|
927 |
</td>
|
928 |
</tr>
|
929 |
<?php
|
930 |
}
|
931 |
/**
|
932 |
* This will output a well formed textbox
|
933 |
-
*
|
934 |
* @param string $label
|
935 |
* @param string $option
|
936 |
* @param string $rows (optional)
|
937 |
* @param bool $disable (optional)
|
938 |
* @param string $description (optional)
|
939 |
*/
|
940 |
-
function textbox($label, $option, $height = '3', $disable = false, $description = '')
|
941 |
{
|
942 |
-
$
|
|
|
|
|
943 |
if($disable)
|
944 |
-
{
|
945 |
-
|
946 |
-
|
|
|
947 |
<tr valign="top">
|
948 |
<th scope="row">
|
949 |
-
|
950 |
</th>
|
951 |
<td>
|
952 |
-
<textarea rows="
|
953 |
<?php if($description !== ''){?><p class="description"><?php echo $description;?></p><?php }?>
|
954 |
</td>
|
955 |
</tr>
|
@@ -957,7 +1006,7 @@ abstract class mtekk_adminKit
|
|
957 |
}
|
958 |
/**
|
959 |
* This will output a well formed tiny mce ready textbox
|
960 |
-
*
|
961 |
* @param string $label
|
962 |
* @param string $option
|
963 |
* @param string $rows (optional)
|
@@ -966,17 +1015,19 @@ abstract class mtekk_adminKit
|
|
966 |
*/
|
967 |
function tinymce($label, $option, $height = '3', $disable = false, $description = '')
|
968 |
{
|
969 |
-
$
|
|
|
970 |
if($disable)
|
971 |
-
{
|
972 |
-
|
973 |
-
|
|
|
974 |
<tr valign="top">
|
975 |
<th scope="row">
|
976 |
-
|
977 |
</th>
|
978 |
<td>
|
979 |
-
<textarea rows="
|
980 |
<?php if($description !== ''){?><p class="description"><?php echo $description;?></p><?php }?>
|
981 |
</td>
|
982 |
</tr>
|
@@ -984,26 +1035,31 @@ abstract class mtekk_adminKit
|
|
984 |
}
|
985 |
/**
|
986 |
* This will output a well formed table row for a checkbox input
|
987 |
-
*
|
988 |
* @param string $label
|
989 |
* @param string $option
|
990 |
* @param string $instruction
|
991 |
* @param bool $disable (optional)
|
992 |
* @param string $description (optional)
|
993 |
* @param string $class (optional)
|
994 |
-
* @return
|
995 |
*/
|
996 |
function input_check($label, $option, $instruction, $disable = false, $description = '', $class = '')
|
997 |
{
|
998 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
999 |
<tr valign="top">
|
1000 |
<th scope="row">
|
1001 |
-
|
1002 |
</th>
|
1003 |
<td>
|
1004 |
<label>
|
1005 |
-
<input type="checkbox" name="
|
1006 |
-
|
1007 |
</label><br />
|
1008 |
<?php if($description !== ''){?><p class="description"><?php echo $description;?></p><?php }?>
|
1009 |
</td>
|
@@ -1012,25 +1068,32 @@ abstract class mtekk_adminKit
|
|
1012 |
}
|
1013 |
/**
|
1014 |
* This will output a singular radio type form input field
|
1015 |
-
*
|
1016 |
* @param string $option
|
1017 |
* @param string $value
|
1018 |
* @param string $instruction
|
1019 |
* @param object $disable (optional)
|
1020 |
* @param string $class (optional)
|
1021 |
-
* @return
|
1022 |
*/
|
1023 |
function input_radio($option, $value, $instruction, $disable = false, $class = '')
|
1024 |
-
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1025 |
<label>
|
1026 |
-
|
1027 |
<?php echo $instruction; ?>
|
1028 |
</label><br/>
|
1029 |
<?php
|
1030 |
}
|
1031 |
/**
|
1032 |
* This will output a well formed table row for a select input
|
1033 |
-
*
|
1034 |
* @param string $label
|
1035 |
* @param string $option
|
1036 |
* @param array $values
|
@@ -1038,7 +1101,6 @@ abstract class mtekk_adminKit
|
|
1038 |
* @param string $description (optional)
|
1039 |
* @param array $titles (optional) The array of titiles for the options, if they should be different from the values
|
1040 |
* @param string $class (optional) Extra class to apply to the elements
|
1041 |
-
* @return
|
1042 |
*/
|
1043 |
function input_select($label, $option, $values, $disable = false, $description = '', $titles = false, $class = '')
|
1044 |
{
|
@@ -1047,15 +1109,19 @@ abstract class mtekk_adminKit
|
|
1047 |
{
|
1048 |
$titles = $values;
|
1049 |
}
|
1050 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
1051 |
<tr valign="top">
|
1052 |
<th scope="row">
|
1053 |
-
|
1054 |
</th>
|
1055 |
<td>
|
1056 |
-
<select name="
|
1057 |
-
<?php $this->select_options($option, $titles, $values); ?>
|
1058 |
-
</select><br />
|
1059 |
<?php if($description !== ''){?><p class="description"><?php echo $description;?></p><?php }?>
|
1060 |
</td>
|
1061 |
</tr>
|
@@ -1068,22 +1134,26 @@ abstract class mtekk_adminKit
|
|
1068 |
* @param array $options array of names of options that can be selected
|
1069 |
* @param array $values array of the values of the options that can be selected
|
1070 |
* @param array $exclude(optional) array of names in $options array to be excluded
|
|
|
|
|
1071 |
*/
|
1072 |
function select_options($optionname, $options, $values, $exclude = array())
|
1073 |
{
|
|
|
1074 |
$value = $this->opt[$optionname];
|
1075 |
//Now do the rest
|
1076 |
foreach($options as $key => $option)
|
1077 |
{
|
1078 |
if(!in_array($option, $exclude))
|
1079 |
{
|
1080 |
-
|
1081 |
}
|
1082 |
}
|
|
|
1083 |
}
|
1084 |
/**
|
1085 |
* A local pass through for get_option so that we can hook in and pick the correct method if needed
|
1086 |
-
*
|
1087 |
* @param string $option The name of the option to retrieve
|
1088 |
* @return mixed The value of the option
|
1089 |
*/
|
@@ -1093,10 +1163,9 @@ abstract class mtekk_adminKit
|
|
1093 |
}
|
1094 |
/**
|
1095 |
* A local pass through for update_option so that we can hook in and pick the correct method if needed
|
1096 |
-
*
|
1097 |
* @param string $option The name of the option to update
|
1098 |
* @param mixed $newvalue The new value to set the option to
|
1099 |
-
*
|
1100 |
*/
|
1101 |
function update_option($option, $newvalue)
|
1102 |
{
|
@@ -1104,12 +1173,11 @@ abstract class mtekk_adminKit
|
|
1104 |
}
|
1105 |
/**
|
1106 |
* A local pass through for add_option so that we can hook in and pick the correct method if needed
|
1107 |
-
*
|
1108 |
* @param string $option The name of the option to update
|
1109 |
* @param mixed $value The new value to set the option to
|
1110 |
* @param null $deprecated Deprecated parameter
|
1111 |
* @param string $autoload Whether or not to autoload the option, it's a string because WP is special
|
1112 |
-
*
|
1113 |
*/
|
1114 |
function add_option($option, $value = '', $deprecated = '', $autoload = 'yes')
|
1115 |
{
|
@@ -1117,7 +1185,7 @@ abstract class mtekk_adminKit
|
|
1117 |
}
|
1118 |
/**
|
1119 |
* A local pass through for delete_option so that we can hook in and pick the correct method if needed
|
1120 |
-
*
|
1121 |
* @param string $option The name of the option to delete
|
1122 |
*/
|
1123 |
function delete_option($option)
|
1 |
<?php
|
2 |
+
/*
|
3 |
+
Copyright 2015-2017 John Havlik (email : john.havlik@mtekk.us)
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
6 |
it under the terms of the GNU General Public License as published by
|
17 |
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
*/
|
19 |
require_once(dirname(__FILE__) . '/block_direct_access.php');
|
20 |
+
//Include admin base class
|
21 |
+
if(!class_exists('mtekk_adminKit_message'))
|
22 |
+
{
|
23 |
+
require_once(dirname(__FILE__) . '/class.mtekk_adminkit_message.php');
|
24 |
+
}
|
25 |
abstract class mtekk_adminKit
|
26 |
{
|
27 |
+
const version = '2.0.0';
|
28 |
protected $full_name;
|
29 |
protected $short_name;
|
30 |
protected $plugin_basename;
|
32 |
protected $identifier;
|
33 |
protected $unique_prefix;
|
34 |
protected $opt = array();
|
35 |
+
protected $messages;
|
36 |
protected $message;
|
37 |
protected $support_url;
|
38 |
protected $allowed_html;
|
39 |
function __construct()
|
40 |
{
|
41 |
+
$this->message = array();
|
42 |
+
$this->messages = array();
|
43 |
//Admin Init Hook
|
44 |
add_action('admin_init', array($this, 'init'));
|
45 |
//WordPress Admin interface hook
|
99 |
//Assemble our url, nonce and all
|
100 |
$url = wp_nonce_url(add_query_arg($this->unique_prefix . '_' . $mode, $value, $uri), $this->unique_prefix . '_' . $mode);
|
101 |
//Return a valid anchor
|
102 |
+
return ' <a title="' . esc_attr($title) . '" href="' . $url . '" '. $anchor_extras . '>' . esc_html($text) . '</a>';
|
103 |
}
|
104 |
/**
|
105 |
* Abstracts the check_admin_referer so that all the end user has to supply is the mode
|
175 |
{
|
176 |
$suffix = '.min';
|
177 |
}
|
178 |
+
//Register JS for more permanently dismissing messages
|
179 |
+
wp_register_script('mtekk_adminkit_messages', plugins_url('/mtekk_adminkit_messages' . $suffix . '.js', dirname(__FILE__) . '/mtekk_adminkit_messages' . $suffix . '.js'), array('jquery'), self::version, true);
|
180 |
//Register JS for enable/disable settings groups
|
181 |
wp_register_script('mtekk_adminkit_engroups', plugins_url('/mtekk_adminkit_engroups' . $suffix . '.js', dirname(__FILE__) . '/mtekk_adminkit_engroups' . $suffix . '.js'), array('jquery'), self::version, true);
|
182 |
//Register JS for tabs
|
189 |
$this->opt = $this::parse_args($this->get_option($this->unique_prefix . '_options'), $this->opt);
|
190 |
//Run the opts fix filter
|
191 |
$this->opts_fix($this->opt);
|
192 |
+
add_action('wp_ajax_mtekk_admin_message_dismiss', array($this, 'dismiss_message'));
|
193 |
}
|
194 |
/**
|
195 |
* Adds the adminpage the menu and the nice little settings link
|
244 |
if($file == $this->plugin_basename)
|
245 |
{
|
246 |
//Add our link to the end of the array to better integrate into the WP 2.8 plugins page
|
247 |
+
$links[] = '<a href="' . $this->admin_url() . '">' . esc_html__('Settings') . '</a>';
|
248 |
}
|
249 |
return $links;
|
250 |
}
|
320 |
if($version && version_compare($version, $this::version, '<') && is_array($this->opt))
|
321 |
{
|
322 |
//Throw an error since the DB version is out of date
|
323 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Your settings are for an older version of this plugin and need to be migrated.', $this->identifier)
|
324 |
+
. $this->admin_anchor('upgrade', __('Migrate the settings now.', $this->identifier), __('Migrate now.', $this->identifier)), 'warning');
|
325 |
//Output any messages that there may be
|
326 |
$this->messages();
|
327 |
return false;
|
330 |
else if($version && version_compare($version, $this::version, '>') && is_array($this->opt))
|
331 |
{
|
332 |
//Let the user know that their settings are for a newer version
|
333 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Your settings are for a newer version of this plugin.', $this->identifier)
|
334 |
+
. $this->admin_anchor('upgrade', __('Migrate the settings now.', $this->identifier), __('Attempt back migration now.', $this->identifier)), 'warning');
|
335 |
//Output any messages that there may be
|
336 |
$this->messages();
|
337 |
return true;
|
339 |
else if(!is_array($this->opt))
|
340 |
{
|
341 |
//Throw an error since it appears the options were never registered
|
342 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Your plugin install is incomplete.', $this->identifier)
|
343 |
+
. $this->admin_anchor('upgrade', __('Load default settings now.', $this->identifier), __('Complete now.', $this->identifier)), 'error');
|
344 |
//Output any messages that there may be
|
345 |
$this->messages();
|
346 |
return false;
|
348 |
else if(!$this->opts_validate($this->opt))
|
349 |
{
|
350 |
//Throw an error since it appears the options contain invalid data
|
351 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('One or more of your plugin settings are invalid.', $this->identifier)
|
352 |
+
. $this->admin_anchor('fix', __('Attempt to fix settings now.', $this->identifier), __('Fix now.', $this->identifier)), 'error');
|
353 |
//Output any messages that there may be
|
354 |
$this->messages();
|
355 |
return false;
|
411 |
break;
|
412 |
//Handle the absolute integer options
|
413 |
case 'a':
|
414 |
+
$opts[$option] = (int) abs($input[$option]);
|
415 |
break;
|
416 |
//Handle the floating point options
|
417 |
case 'f':
|
419 |
break;
|
420 |
//Handle the HTML options
|
421 |
case 'h':
|
|
|
422 |
$opts[$option] = wp_kses(stripslashes($input[$option]), $this->allowed_html);
|
423 |
break;
|
424 |
//Handle the HTML options that must not be null
|
547 |
if($updated && count(array_diff_key($input, $this->opt)) == 0)
|
548 |
{
|
549 |
//Let the user know everything went ok
|
550 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Settings successfully saved.', $this->identifier)
|
551 |
+
. $this->admin_anchor('undo', __('Undo the options save.', $this->identifier), __('Undo', $this->identifier)), 'success');
|
552 |
}
|
553 |
else if(!$updated && count(array_diff_key($opt_prev, $this->opt)) == 0)
|
554 |
{
|
555 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Settings did not change, nothing to save.', $this->identifier), 'info');
|
556 |
}
|
557 |
else if(!$updated)
|
558 |
{
|
559 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Settings were not saved.', $this->identifier), 'error');
|
560 |
}
|
561 |
else
|
562 |
{
|
563 |
//Let the user know the following were not saved
|
564 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Some settings were not saved.', $this->identifier)
|
565 |
+
. $this->admin_anchor('undo', __('Undo the options save.', $this->identifier), __('Undo', $this->identifier)), 'warning');
|
566 |
+
$temp = esc_html__('The following settings were not saved:', $this->identifier);
|
567 |
foreach(array_diff_key($input, $this->opt) as $setting => $value)
|
568 |
{
|
569 |
$temp .= '<br />' . $setting;
|
570 |
}
|
571 |
+
$this->messages[] = new mtekk_adminKit_message($temp . '<br />' . sprintf(esc_html__('Please include this message in your %sbug report%s.', $this->identifier), '<a title="' . sprintf(esc_attr__('Go to the %s support post for your version.', $this->identifier), $this->short_name) . '" href="' . $this->support_url . $this::version . '/#respond">', '</a>'), 'info');
|
572 |
}
|
573 |
add_action('admin_notices', array($this, 'messages'));
|
574 |
}
|
667 |
//Commit the loaded options to the database
|
668 |
$this->update_option($this->unique_prefix . '_options', $this->opt);
|
669 |
//Everything was successful, let the user know
|
670 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Settings successfully imported from the uploaded file.', $this->identifier)
|
671 |
+
. $this->admin_anchor('undo', __('Undo the options import.', $this->identifier), __('Undo', $this->identifier)), 'success');
|
672 |
}
|
673 |
else
|
674 |
{
|
675 |
//Throw an error since we could not load the file for various reasons
|
676 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Importing settings from file failed.', $this->identifier), 'error');
|
677 |
}
|
678 |
//Reset to the default error handler after we're done
|
679 |
restore_error_handler();
|
692 |
//Load in the hard coded default option values
|
693 |
$this->update_option($this->unique_prefix . '_options', $this->opt);
|
694 |
//Reset successful, let the user know
|
695 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Settings successfully reset to the default values.', $this->identifier)
|
696 |
+
. $this->admin_anchor('undo', __('Undo the options reset.', $this->identifier), __('Undo', $this->identifier)), 'success');
|
697 |
add_action('admin_notices', array($this, 'messages'));
|
698 |
}
|
699 |
/**
|
710 |
//Set the backup options to the undone options
|
711 |
$this->update_option($this->unique_prefix . '_options_bk', $opt);
|
712 |
//Send the success/undo message
|
713 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Settings successfully undid the last operation.', $this->identifier)
|
714 |
+
. $this->admin_anchor('undo', __('Undo the last undo operation.', $this->identifier), __('Undo', $this->identifier)), 'success');
|
715 |
add_action('admin_notices', array($this, 'messages'));
|
716 |
}
|
717 |
/**
|
746 |
//Store the options
|
747 |
$this->update_option($this->unique_prefix . '_options', $this->opt);
|
748 |
//Send the success message
|
749 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Settings successfully migrated.', $this->identifier), 'success');
|
750 |
}
|
751 |
else
|
752 |
{
|
753 |
//Run the install script
|
754 |
$this->install();
|
755 |
//Send the success message
|
756 |
+
$this->messages[] = new mtekk_adminKit_message(esc_html__('Default settings successfully installed.', $this->identifier), 'success');
|
757 |
}
|
758 |
add_action('admin_notices', array($this, 'messages'));
|
759 |
}
|
772 |
|
773 |
}
|
774 |
}
|
775 |
+
function dismiss_message()
|
776 |
+
{
|
777 |
+
//Grab the submitted UID
|
778 |
+
$uid = esc_attr($_POST['uid']);
|
779 |
+
//Create a dummy message, with the discovered UID
|
780 |
+
$message = new mtekk_adminKit_message('', '', true, $uid);
|
781 |
+
//Dismiss the message
|
782 |
+
$message->dismiss();
|
783 |
+
wp_die();
|
784 |
+
}
|
785 |
/**
|
786 |
* Prints to screen all of the messages stored in the message member variable
|
787 |
*/
|
788 |
function messages()
|
789 |
{
|
790 |
+
foreach($this->messages as $message)
|
791 |
+
{
|
792 |
+
$message->render();
|
793 |
+
}
|
794 |
+
//Old deprecated messages
|
795 |
if(count($this->message))
|
796 |
{
|
797 |
+
_deprecated_function( __FUNCTION__, '2.0.0', __('adminKit::message is deprecated, use new adminkit_messages instead.', $this->identifier) );
|
798 |
//Loop through our message classes
|
799 |
foreach($this->message as $key => $class)
|
800 |
{
|
801 |
//Loop through the messages in the current class
|
802 |
foreach($class as $message)
|
803 |
{
|
804 |
+
printf('<div class="%s"><p>%s</p></div>', esc_attr($key), $message);
|
805 |
}
|
806 |
}
|
807 |
+
$this->message = array();
|
808 |
}
|
809 |
+
$this->messages = array();
|
810 |
}
|
811 |
/**
|
812 |
* Function prototype to prevent errors
|
820 |
*/
|
821 |
function admin_scripts()
|
822 |
{
|
823 |
+
|
824 |
}
|
825 |
/**
|
826 |
* Function prototype to prevent errors
|
827 |
*/
|
828 |
function admin_head()
|
829 |
{
|
830 |
+
|
831 |
}
|
832 |
/**
|
833 |
* Function prototype to prevent errors
|
834 |
*/
|
835 |
function admin_page()
|
836 |
{
|
837 |
+
|
838 |
}
|
839 |
/**
|
840 |
* Function prototype to prevent errors
|
845 |
}
|
846 |
/**
|
847 |
* Returns a valid xHTML element ID
|
848 |
+
*
|
849 |
* @param object $option
|
|
|
850 |
*/
|
851 |
+
static public function get_valid_id($option)
|
852 |
{
|
853 |
if(is_numeric($option[0]))
|
854 |
{
|
862 |
function import_form()
|
863 |
{
|
864 |
$form = '<div id="mtekk_admin_import_export_relocate">';
|
865 |
+
$form .= sprintf('<form action="options-general.php?page=%s" method="post" enctype="multipart/form-data" id="%s_admin_upload">', esc_attr($this->identifier), esc_attr($this->unique_prefix));
|
866 |
$form .= wp_nonce_field($this->unique_prefix . '_admin_import_export', '_wpnonce', true, false);
|
867 |
+
$form .= sprintf('<fieldset id="import_export" class="%s_options">', esc_attr($this->unique_prefix));
|
868 |
+
$form .= '<p>' . esc_html__('Import settings from a XML file, export the current settings to a XML file, or reset to the default settings.', $this->identifier) . '</p>';
|
869 |
$form .= '<table class="form-table"><tr valign="top"><th scope="row">';
|
870 |
+
$form .= sprintf('<label for="%s_admin_import_file">', esc_attr($this->unique_prefix));
|
871 |
+
$form .= esc_html__('Settings File', $this->identifier);
|
872 |
$form .= '</label></th><td>';
|
873 |
+
$form .= sprintf('<input type="file" name="%1$s_admin_import_file" id="%1$s_admin_import_file" size="32" /><p class="description">', esc_attr($this->unique_prefix));
|
874 |
+
$form .= esc_html__('Select a XML settings file to upload and import settings from.', 'breadcrumb_navxt');
|
875 |
$form .= '</p></td></tr></table><p class="submit">';
|
876 |
+
$form .= sprintf('<input type="submit" class="button" name="%1$s_admin_import" value="%2$s"/>', $this->unique_prefix, esc_attr__('Import', $this->identifier));
|
877 |
+
$form .= sprintf('<input type="submit" class="button" name="%1$s_admin_export" value="%2$s"/>', $this->unique_prefix, esc_attr__('Export', $this->identifier));
|
878 |
+
$form .= sprintf('<input type="submit" class="button" name="%1$s_admin_reset" value="%2$s"/>', $this->unique_prefix, esc_attr__('Reset', $this->identifier));
|
879 |
$form .= '</p></fieldset></form></div>';
|
880 |
return $form;
|
881 |
}
|
882 |
/**
|
883 |
* This will output a well formed hidden option
|
884 |
+
*
|
885 |
* @param string $option
|
|
|
886 |
*/
|
887 |
function input_hidden($option)
|
888 |
{
|
889 |
+
$opt_id = mtekk_adminKit::get_valid_id($option);
|
890 |
+
$opt_name = $this->unique_prefix . '_options[' . $option . ']';
|
891 |
+
printf('<input type="hidden" name="%1$s" id="%2$s" value="%3$s" />', esc_attr($opt_name), esc_attr($opt_id), esc_attr($this->opt[$option]));
|
892 |
+
}
|
893 |
+
/**
|
894 |
+
* This will output a well formed option label
|
895 |
+
*
|
896 |
+
* @param string $opt_id
|
897 |
+
* @param string $label
|
898 |
+
*/
|
899 |
+
function label($opt_id, $label)
|
900 |
+
{
|
901 |
+
printf('<label for="%1$s">%2$s</label>', esc_attr($opt_id), $label);
|
902 |
}
|
903 |
/**
|
904 |
* This will output a well formed table row for a text input
|
905 |
+
*
|
906 |
* @param string $label
|
907 |
* @param string $option
|
908 |
* @param string $class (optional)
|
909 |
* @param bool $disable (optional)
|
910 |
* @param string $description (optional)
|
|
|
911 |
*/
|
912 |
function input_text($label, $option, $class = 'regular-text', $disable = false, $description = '')
|
913 |
{
|
914 |
+
$opt_id = mtekk_adminKit::get_valid_id($option);
|
915 |
+
$opt_name = $this->unique_prefix . '_options[' . $option . ']';
|
916 |
if($disable)
|
917 |
+
{
|
918 |
+
$this->input_hidden($option);
|
919 |
+
$class .= ' disabled';
|
920 |
+
}?>
|
921 |
<tr valign="top">
|
922 |
<th scope="row">
|
923 |
+
<?php $this->label($opt_id, $label);?>
|
924 |
</th>
|
925 |
<td>
|
926 |
+
<?php printf('<input type="text" name="%1$s" id="%2$s" value="%3$s" class="%4$s" %5$s/><br />', esc_attr($opt_name), esc_attr($opt_id), esc_attr($this->opt[$option]), esc_attr($class), disabled($disable, true, false));?>
|
927 |
+
<?php if($description !== ''){?><p class="description"><?php echo $description;?></p><?php }?>
|
928 |
</td>
|
929 |
</tr>
|
930 |
<?php
|
931 |
}
|
932 |
/**
|
933 |
* This will output a well formed table row for a HTML5 number input
|
934 |
+
*
|
935 |
* @param string $label
|
936 |
* @param string $option
|
937 |
* @param string $class (optional)
|
940 |
* @param int|string $min (optional)
|
941 |
* @param int|string $max (optional)
|
942 |
* @param int|string $step (optional)
|
|
|
943 |
*/
|
944 |
function input_number($label, $option, $class = 'small-text', $disable = false, $description = '', $min = '', $max = '', $step = '')
|
945 |
{
|
946 |
+
$opt_id = mtekk_adminKit::get_valid_id($option);
|
947 |
+
$opt_name = $this->unique_prefix . '_options[' . $option . ']';
|
948 |
$extras = '';
|
949 |
if($min !== '')
|
950 |
{
|
951 |
+
$extras .= 'min="' . esc_attr($min) . '" ';
|
952 |
}
|
953 |
if($max !== '')
|
954 |
{
|
955 |
+
$extras .= 'max="' . esc_attr($max) . '" ';
|
956 |
}
|
957 |
if($step !== '')
|
958 |
{
|
959 |
+
$extras .= 'step="' . esc_attr($step) . '" ';
|
960 |
}
|
961 |
if($disable)
|
962 |
+
{
|
963 |
+
$this->input_hidden($option);
|
964 |
+
$class .= ' disabled';
|
965 |
+
}?>
|
966 |
<tr valign="top">
|
967 |
<th scope="row">
|
968 |
+
<?php $this->label($opt_id, $label);?>
|
969 |
</th>
|
970 |
<td>
|
971 |
+
<?php printf('<input type="number" name="%1$s" id="%2$s" value="%3$s" class="%4$s" %6$s%5$s/><br />', esc_attr($opt_name), esc_attr($opt_id), esc_attr($this->opt[$option]), esc_attr($class), disabled($disable, true, false), $extras);?>
|
972 |
+
<?php if($description !== ''){?><p class="description"><?php echo $description;?></p><?php }?>
|
973 |
</td>
|
974 |
</tr>
|
975 |
<?php
|
976 |
}
|
977 |
/**
|
978 |
* This will output a well formed textbox
|
979 |
+
*
|
980 |
* @param string $label
|
981 |
* @param string $option
|
982 |
* @param string $rows (optional)
|
983 |
* @param bool $disable (optional)
|
984 |
* @param string $description (optional)
|
985 |
*/
|
986 |
+
function textbox($label, $option, $height = '3', $disable = false, $description = '', $class = '')
|
987 |
{
|
988 |
+
$opt_id = mtekk_adminKit::get_valid_id($option);
|
989 |
+
$opt_name = $this->unique_prefix . '_options[' . $option . ']';
|
990 |
+
$class .= ' large-text';
|
991 |
if($disable)
|
992 |
+
{
|
993 |
+
$this->input_hidden($option);
|
994 |
+
$class .= ' disabled';
|
995 |
+
}?>
|
996 |
<tr valign="top">
|
997 |
<th scope="row">
|
998 |
+
<?php $this->label($opt_id, $label);?>
|
999 |
</th>
|
1000 |
<td>
|
1001 |
+
<?php printf('<textarea rows="%6$s" name="%1$s" id="%2$s" class="%4$s" %5$s/>%3$s</textarea><br />', esc_attr($opt_name), esc_attr($opt_id), esc_textarea($this->opt[$option]), esc_attr($class), disabled($disable, true, false), esc_attr($height));?>
|
1002 |
<?php if($description !== ''){?><p class="description"><?php echo $description;?></p><?php }?>
|
1003 |
</td>
|
1004 |
</tr>
|
1006 |
}
|
1007 |
/**
|
1008 |
* This will output a well formed tiny mce ready textbox
|
1009 |
+
*
|
1010 |
* @param string $label
|
1011 |
* @param string $option
|
1012 |
* @param string $rows (optional)
|
1015 |
*/
|
1016 |
function tinymce($label, $option, $height = '3', $disable = false, $description = '')
|
1017 |
{
|
1018 |
+
$opt_id = mtekk_adminKit::get_valid_id($option);
|
1019 |
+
$class = 'mtekk_mce';
|
1020 |
if($disable)
|
1021 |
+
{
|
1022 |
+
$this->input_hidden($option);
|
1023 |
+
$class .= ' disabled';
|
1024 |
+
}?>
|
1025 |
<tr valign="top">
|
1026 |
<th scope="row">
|
1027 |
+
<?php $this->label($opt_id, $label);?>
|
1028 |
</th>
|
1029 |
<td>
|
1030 |
+
<?php printf('<textarea rows="%6$s" name="%1$s" id="%2$s" class="%4$s" %5$s/>%3$s</textarea><br />', esc_attr($opt_name), esc_attr($opt_id), esc_textarea($this->opt[$option]), esc_attr($class), disabled($disable, true, false), esc_attr($height));?>
|
1031 |
<?php if($description !== ''){?><p class="description"><?php echo $description;?></p><?php }?>
|
1032 |
</td>
|
1033 |
</tr>
|
1035 |
}
|
1036 |
/**
|
1037 |
* This will output a well formed table row for a checkbox input
|
1038 |
+
*
|
1039 |
* @param string $label
|
1040 |
* @param string $option
|
1041 |
* @param string $instruction
|
1042 |
* @param bool $disable (optional)
|
1043 |
* @param string $description (optional)
|
1044 |
* @param string $class (optional)
|
|
|
1045 |
*/
|
1046 |
function input_check($label, $option, $instruction, $disable = false, $description = '', $class = '')
|
1047 |
{
|
1048 |
+
$opt_id = mtekk_adminKit::get_valid_id($option);
|
1049 |
+
$opt_name = $this->unique_prefix . '_options[' . $option . ']';
|
1050 |
+
if($disable)
|
1051 |
+
{
|
1052 |
+
$this->input_hidden($option);
|
1053 |
+
$class .= ' disabled';
|
1054 |
+
}?>
|
1055 |
<tr valign="top">
|
1056 |
<th scope="row">
|
1057 |
+
<?php $this->label($opt_id, $label);?>
|
1058 |
</th>
|
1059 |
<td>
|
1060 |
<label>
|
1061 |
+
<?php printf('<input type="checkbox" name="%1$s" id="%2$s" value="%3$s" class="%4$s" %5$s %6$s/>', esc_attr($opt_name), esc_attr($opt_id), esc_attr($this->opt[$option]), esc_attr($class), disabled($disable, true, false), checked($this->opt[$option], true, false));?>
|
1062 |
+
<?php echo $instruction; ?>
|
1063 |
</label><br />
|
1064 |
<?php if($description !== ''){?><p class="description"><?php echo $description;?></p><?php }?>
|
1065 |
</td>
|
1068 |
}
|
1069 |
/**
|
1070 |
* This will output a singular radio type form input field
|
1071 |
+
*
|
1072 |
* @param string $option
|
1073 |
* @param string $value
|
1074 |
* @param string $instruction
|
1075 |
* @param object $disable (optional)
|
1076 |
* @param string $class (optional)
|
|
|
1077 |
*/
|
1078 |
function input_radio($option, $value, $instruction, $disable = false, $class = '')
|
1079 |
+
{
|
1080 |
+
$opt_id = mtekk_adminKit::get_valid_id($option);
|
1081 |
+
$opt_name = $this->unique_prefix . '_options[' . $option . ']';
|
1082 |
+
$class .= ' togx';
|
1083 |
+
if($disable)
|
1084 |
+
{
|
1085 |
+
$this->input_hidden($option);
|
1086 |
+
$class .= ' disabled';
|
1087 |
+
}?>
|
1088 |
<label>
|
1089 |
+
<?php printf('<input type="radio" name="%1$s" id="%2$s" value="%3$s" class="%4$s" %5$s %6$s/>', esc_attr($opt_name), esc_attr($opt_id), esc_attr($this->opt[$option]), esc_attr($class), disabled($disable, true, false), checked($value, $this->opt[$option], false));?>
|
1090 |
<?php echo $instruction; ?>
|
1091 |
</label><br/>
|
1092 |
<?php
|
1093 |
}
|
1094 |
/**
|
1095 |
* This will output a well formed table row for a select input
|
1096 |
+
*
|
1097 |
* @param string $label
|
1098 |
* @param string $option
|
1099 |
* @param array $values
|
1101 |
* @param string $description (optional)
|
1102 |
* @param array $titles (optional) The array of titiles for the options, if they should be different from the values
|
1103 |
* @param string $class (optional) Extra class to apply to the elements
|
|
|
1104 |
*/
|
1105 |
function input_select($label, $option, $values, $disable = false, $description = '', $titles = false, $class = '')
|
1106 |
{
|
1109 |
{
|
1110 |
$titles = $values;
|
1111 |
}
|
1112 |
+
$opt_id = mtekk_adminKit::get_valid_id($option);
|
1113 |
+
$opt_name = $this->unique_prefix . '_options[' . $option . ']';
|
1114 |
+
if($disable)
|
1115 |
+
{
|
1116 |
+
$this->input_hidden($option);
|
1117 |
+
$class .= ' disabled';
|
1118 |
+
}?>
|
1119 |
<tr valign="top">
|
1120 |
<th scope="row">
|
1121 |
+
<?php $this->label($opt_id, $label);?>
|
1122 |
</th>
|
1123 |
<td>
|
1124 |
+
<?php printf('<select name="%1$s" id="%2$s" class="%4$s" %5$s>%3$s</select><br />', esc_attr($opt_name), esc_attr($opt_id), $this->select_options($option, $titles, $values), esc_attr($class), disabled($disable, true, false));?>
|
|
|
|
|
1125 |
<?php if($description !== ''){?><p class="description"><?php echo $description;?></p><?php }?>
|
1126 |
</td>
|
1127 |
</tr>
|
1134 |
* @param array $options array of names of options that can be selected
|
1135 |
* @param array $values array of the values of the options that can be selected
|
1136 |
* @param array $exclude(optional) array of names in $options array to be excluded
|
1137 |
+
*
|
1138 |
+
* @return string The assembled HTML for the select options
|
1139 |
*/
|
1140 |
function select_options($optionname, $options, $values, $exclude = array())
|
1141 |
{
|
1142 |
+
$options_html = '';
|
1143 |
$value = $this->opt[$optionname];
|
1144 |
//Now do the rest
|
1145 |
foreach($options as $key => $option)
|
1146 |
{
|
1147 |
if(!in_array($option, $exclude))
|
1148 |
{
|
1149 |
+
$options_html .= sprintf('<option value="%1$s" %2$s>%3$s</option>', esc_attr($values[$key]), selected($value, $values[$key], false), $option);
|
1150 |
}
|
1151 |
}
|
1152 |
+
return $options_html;
|
1153 |
}
|
1154 |
/**
|
1155 |
* A local pass through for get_option so that we can hook in and pick the correct method if needed
|
1156 |
+
*
|
1157 |
* @param string $option The name of the option to retrieve
|
1158 |
* @return mixed The value of the option
|
1159 |
*/
|
1163 |
}
|
1164 |
/**
|
1165 |
* A local pass through for update_option so that we can hook in and pick the correct method if needed
|
1166 |
+
*
|
1167 |
* @param string $option The name of the option to update
|
1168 |
* @param mixed $newvalue The new value to set the option to
|
|
|
1169 |
*/
|
1170 |
function update_option($option, $newvalue)
|
1171 |
{
|
1173 |
}
|
1174 |
/**
|
1175 |
* A local pass through for add_option so that we can hook in and pick the correct method if needed
|
1176 |
+
*
|
1177 |
* @param string $option The name of the option to update
|
1178 |
* @param mixed $value The new value to set the option to
|
1179 |
* @param null $deprecated Deprecated parameter
|
1180 |
* @param string $autoload Whether or not to autoload the option, it's a string because WP is special
|
|
|
1181 |
*/
|
1182 |
function add_option($option, $value = '', $deprecated = '', $autoload = 'yes')
|
1183 |
{
|
1185 |
}
|
1186 |
/**
|
1187 |
* A local pass through for delete_option so that we can hook in and pick the correct method if needed
|
1188 |
+
*
|
1189 |
* @param string $option The name of the option to delete
|
1190 |
*/
|
1191 |
function delete_option($option)
|
includes/class.mtekk_adminkit_message.php
ADDED
@@ -0,0 +1,99 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Copyright 2015-2017 John Havlik (email : john.havlik@mtekk.us)
|
4 |
+
|
5 |
+
This program is free software; you can redistribute it and/or modify
|
6 |
+
it under the terms of the GNU General Public License as published by
|
7 |
+
the Free Software Foundation; either version 2 of the License, or
|
8 |
+
(at your option) any later version.
|
9 |
+
|
10 |
+
This program is distributed in the hope that it will be useful,
|
11 |
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
+
GNU General Public License for more details.
|
14 |
+
|
15 |
+
You should have received a copy of the GNU General Public License
|
16 |
+
along with this program; if not, write to the Free Software
|
17 |
+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
18 |
+
*/
|
19 |
+
require_once(dirname(__FILE__) . '/block_direct_access.php');
|
20 |
+
class mtekk_adminKit_message
|
21 |
+
{
|
22 |
+
const version = '1.0.0';
|
23 |
+
protected $type = '';
|
24 |
+
protected $contents = '';
|
25 |
+
protected $dismissed = false;
|
26 |
+
protected $dismissible = false;
|
27 |
+
protected $uid;
|
28 |
+
/**
|
29 |
+
* Default constructor function
|
30 |
+
*
|
31 |
+
* @param string $contents The string to display in the message
|
32 |
+
* @param string $type The message type, 'error', 'warning', 'success', or 'info'
|
33 |
+
* @param bool $dismissible Whether or not the message is dismissable
|
34 |
+
* @param string $uid The message unique ID, only necessary if the message is dismissable
|
35 |
+
*/
|
36 |
+
public function __construct($contents, $type = 'info', $dismissible = false, $uid = '')
|
37 |
+
{
|
38 |
+
$uid = sanitize_html_class($uid);
|
39 |
+
//If the message is dismissable, the UID better not be null/empty
|
40 |
+
if($dismissible === true && $uid === '')
|
41 |
+
{
|
42 |
+
//Let the user know they're doing it wrong
|
43 |
+
_doing_it_wrong(__CLASS__ . '::' . __FUNCTION__, __('$uid must not be null if message is dismissible', 'mtekk_adminKit'), '1.0.0');
|
44 |
+
//Treat the message as non-dismissible
|
45 |
+
$dismissible = false;
|
46 |
+
}
|
47 |
+
$this->contents = $contents;
|
48 |
+
$this->type = $type;
|
49 |
+
$this->dismissible = $dismissible;
|
50 |
+
$this->uid = $uid;
|
51 |
+
if($this->dismissible)
|
52 |
+
{
|
53 |
+
$this->dismissed = $this->was_dismissed();
|
54 |
+
}
|
55 |
+
}
|
56 |
+
/**
|
57 |
+
* Attempts to retrieve the dismissal transient for this message
|
58 |
+
*
|
59 |
+
* @return bool Whether or not the message has been dismissed
|
60 |
+
*/
|
61 |
+
public function was_dismissed()
|
62 |
+
{
|
63 |
+
$this->dismissed = get_transient($this->uid);
|
64 |
+
return $this->dismissed;
|
65 |
+
}
|
66 |
+
/**
|
67 |
+
* Dismisses the message, preventing it from being rendered
|
68 |
+
*/
|
69 |
+
public function dismiss()
|
70 |
+
{
|
71 |
+
if($this->dismissible && isset($_POST['uid']) && esc_attr($_POST['uid']) === $this->uid)
|
72 |
+
{
|
73 |
+
check_ajax_referer($this->uid . '_dismiss', 'nonce');
|
74 |
+
$this->dismissed = true;
|
75 |
+
//If the message was dismissed, update the transient for 30 days
|
76 |
+
$result = set_transient($this->uid, $this->dismissed, 2592000);
|
77 |
+
}
|
78 |
+
}
|
79 |
+
/**
|
80 |
+
* Function that prints out the message if not already dismissed
|
81 |
+
*/
|
82 |
+
public function render()
|
83 |
+
{
|
84 |
+
if($this->dismissible)
|
85 |
+
{
|
86 |
+
//Don't render dismissed messages
|
87 |
+
if($this->was_dismissed())
|
88 |
+
{
|
89 |
+
return;
|
90 |
+
}
|
91 |
+
wp_enqueue_script('mtekk_adminkit_messages');
|
92 |
+
printf('<div class="notice notice-%1$s is-dismissible"><p>%2$s</p><meta property="uid" content="%3$s"><meta property="nonce" content="%4$s"></div>', esc_attr($this->type), $this->contents, esc_attr($this->uid), wp_create_nonce($this->uid . '_dismiss'));
|
93 |
+
}
|
94 |
+
else
|
95 |
+
{
|
96 |
+
printf('<div class="notice notice-%1$s"><p>%2$s</p></div>', esc_attr($this->type), $this->contents);
|
97 |
+
}
|
98 |
+
}
|
99 |
+
}
|
includes/class.mtekk_adminkit_uninstaller.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
Copyright 2015-2017 John Havlik (email : john.havlik@mtekk.us)
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
1 |
<?php
|
2 |
+
/*
|
3 |
Copyright 2015-2017 John Havlik (email : john.havlik@mtekk.us)
|
4 |
|
5 |
This program is free software; you can redistribute it and/or modify
|
includes/mtekk_adminkit_engroups.js
CHANGED
@@ -5,7 +5,7 @@ jQuery(function()
|
|
5 |
});
|
6 |
function mtekk_admin_enable_group(){
|
7 |
var setting = this;
|
8 |
-
jQuery(this).parents(".adminkit-engroup").find("input").each(function(){
|
9 |
if(this != setting){
|
10 |
if(jQuery(setting).prop("checked")){
|
11 |
jQuery(this).prop("disabled", false);
|
@@ -20,7 +20,7 @@ function mtekk_admin_enable_group(){
|
|
20 |
}
|
21 |
function mtekk_admin_enable_set(){
|
22 |
var setting = this;
|
23 |
-
jQuery(this).parents(".adminkit-enset-top").find("input.adminkit-enset").each(function(){
|
24 |
if(this != setting){
|
25 |
if(jQuery(setting).prop("checked")){
|
26 |
jQuery(this).prop("disabled", false);
|
5 |
});
|
6 |
function mtekk_admin_enable_group(){
|
7 |
var setting = this;
|
8 |
+
jQuery(this).parents(".adminkit-engroup").find("input, textarea").each(function(){
|
9 |
if(this != setting){
|
10 |
if(jQuery(setting).prop("checked")){
|
11 |
jQuery(this).prop("disabled", false);
|
20 |
}
|
21 |
function mtekk_admin_enable_set(){
|
22 |
var setting = this;
|
23 |
+
jQuery(this).parents(".adminkit-enset-top").find("input.adminkit-enset, textarea.adminkit-enset").each(function(){
|
24 |
if(this != setting){
|
25 |
if(jQuery(setting).prop("checked")){
|
26 |
jQuery(this).prop("disabled", false);
|
includes/mtekk_adminkit_engroups.min.js
CHANGED
@@ -1 +1 @@
|
|
1 |
-
jQuery(function(){jQuery(".adminkit-engroup input:checkbox.adminkit-enset-ctrl").each(mtekk_admin_enable_group);jQuery("input:checkbox.adminkit-enset-ctrl").each(mtekk_admin_enable_set)});function mtekk_admin_enable_group(){var a=this;jQuery(this).parents(".adminkit-engroup").find("input").each(function(){if(this!=a){if(jQuery(a).prop("checked")){jQuery(this).prop("disabled",false);jQuery(this).removeClass("disabled")}else{jQuery(this).prop("disabled",true);jQuery(this).addClass("disabled")}}})}function mtekk_admin_enable_set(){var a=this;jQuery(this).parents(".adminkit-enset-top").find("input.adminkit-enset").each(function(){if(this!=a){if(jQuery(a).prop("checked")){jQuery(this).prop("disabled",false);jQuery(this).removeClass("disabled")}else{jQuery(this).prop("disabled",true);jQuery(this).addClass("disabled")}}})}jQuery(".adminkit-engroup input:checkbox.adminkit-enset-ctrl").change(mtekk_admin_enable_group);jQuery("input:checkbox.adminkit-enset-ctrl").change(mtekk_admin_enable_set);
|
1 |
+
jQuery(function(){jQuery(".adminkit-engroup input:checkbox.adminkit-enset-ctrl").each(mtekk_admin_enable_group);jQuery("input:checkbox.adminkit-enset-ctrl").each(mtekk_admin_enable_set)});function mtekk_admin_enable_group(){var a=this;jQuery(this).parents(".adminkit-engroup").find("input, textarea").each(function(){if(this!=a){if(jQuery(a).prop("checked")){jQuery(this).prop("disabled",false);jQuery(this).removeClass("disabled")}else{jQuery(this).prop("disabled",true);jQuery(this).addClass("disabled")}}})}function mtekk_admin_enable_set(){var a=this;jQuery(this).parents(".adminkit-enset-top").find("input.adminkit-enset, textarea.adminkit-enset").each(function(){if(this!=a){if(jQuery(a).prop("checked")){jQuery(this).prop("disabled",false);jQuery(this).removeClass("disabled")}else{jQuery(this).prop("disabled",true);jQuery(this).addClass("disabled")}}})}jQuery(".adminkit-engroup input:checkbox.adminkit-enset-ctrl").change(mtekk_admin_enable_group);jQuery("input:checkbox.adminkit-enset-ctrl").change(mtekk_admin_enable_set);
|
includes/mtekk_adminkit_messages.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function()
|
2 |
+
{
|
3 |
+
jQuery("div.notice button.notice-dismiss").click(function (event){
|
4 |
+
data = {
|
5 |
+
'action': 'mtekk_admin_message_dismiss',
|
6 |
+
'uid': jQuery(this).parent().children("meta[property='uid']").attr("content"),
|
7 |
+
'nonce': jQuery(this).parent().children("meta[property='nonce']").attr("content")
|
8 |
+
};
|
9 |
+
jQuery.post(ajaxurl, data);
|
10 |
+
});
|
11 |
+
});
|
includes/mtekk_adminkit_messages.min.js
ADDED
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
jQuery(function()
|
2 |
+
{
|
3 |
+
jQuery("div.notice button.notice-dismiss").click(function (event){
|
4 |
+
data = {
|
5 |
+
'action': 'mtekk_admin_message_dismiss',
|
6 |
+
'uid': jQuery(this).parent().children("meta[property='uid']").attr("content"),
|
7 |
+
'nonce': jQuery(this).parent().children("meta[property='nonce']").attr("content")
|
8 |
+
};
|
9 |
+
jQuery.post(ajaxurl, data);
|
10 |
+
});
|
11 |
+
});
|
includes/multibyte_supplicant.php
CHANGED
@@ -1,5 +1,5 @@
|
|
1 |
<?php
|
2 |
-
/*
|
3 |
A small library that adds in fallbacks for some of the PHP multibyte string
|
4 |
functions. Mainly inteneded to be used with Breadcrumb NavXT
|
5 |
|
1 |
<?php
|
2 |
+
/*
|
3 |
A small library that adds in fallbacks for some of the PHP multibyte string
|
4 |
functions. Mainly inteneded to be used with Breadcrumb NavXT
|
5 |
|
readme.txt
CHANGED
@@ -2,9 +2,10 @@
|
|
2 |
Contributors: mtekk, hakre
|
3 |
Donate link: 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
|
4 |
Tags: breadcrumb, breadcrumbs, trail, navigation, menu, widget
|
5 |
-
Requires at least: 4.
|
6 |
-
Tested up to: 4.
|
7 |
-
Stable tag:
|
|
|
8 |
License: GPLv2 or later
|
9 |
Adds breadcrumb navigation showing the visitor's path to their current location.
|
10 |
|
@@ -33,13 +34,11 @@ Breadcrumb NavXT now supports WordPress.org language packs. Want to translate Br
|
|
33 |
|
34 |
== Installation ==
|
35 |
Open the appropriate file for your theme (typically header.php). This can be done within WordPress’ administration panel through Presentation > Theme Editor or through your favorite text editor. Place the following code where you want the breadcrumb trail to appear.
|
36 |
-
|
37 |
-
<?php if(function_exists('bcn_display'))
|
38 |
{
|
39 |
bcn_display();
|
40 |
-
}
|
41 |
-
|
42 |
-
Save the file (upload if applicable). Now you should have a breadcrumb trail on your WordPress powered site. To customize the breadcrumb trail you may edit the default values for the options in the administrative interface. This is located in your administration panel under Settings > Breadcrumb NavXT.
|
43 |
|
44 |
Please visit [Breadcrumb NavXT's Documentation](http://mtekk.us/code/breadcrumb-navxt/breadcrumb-navxt-doc/ "Go to Breadcrumb NavXT's Documentation.") page for more information.
|
45 |
|
@@ -53,6 +52,24 @@ Please visit [Breadcrumb NavXT's Documentation](http://mtekk.us/code/breadcrumb-
|
|
53 |
|
54 |
== Changelog ==
|
55 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
= 5.7.1 =
|
57 |
Release date: June 30th, 2017
|
58 |
|
2 |
Contributors: mtekk, hakre
|
3 |
Donate link: 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
|
4 |
Tags: breadcrumb, breadcrumbs, trail, navigation, menu, widget
|
5 |
+
Requires at least: 4.7
|
6 |
+
Tested up to: 4.9
|
7 |
+
Stable tag: 6.0.0
|
8 |
+
Requires PHP: 5.3
|
9 |
License: GPLv2 or later
|
10 |
Adds breadcrumb navigation showing the visitor's path to their current location.
|
11 |
|
34 |
|
35 |
== Installation ==
|
36 |
Open the appropriate file for your theme (typically header.php). This can be done within WordPress’ administration panel through Presentation > Theme Editor or through your favorite text editor. Place the following code where you want the breadcrumb trail to appear.
|
37 |
+
`if(function_exists('bcn_display'))
|
|
|
38 |
{
|
39 |
bcn_display();
|
40 |
+
}`
|
41 |
+
Save the file (upload if applicable). Now you should have a breadcrumb trail on your WordPress powered site. To customize the breadcrumb trail you may edit the default values for the options in the administrative interface. This is located in your administration panel under Settings > Breadcrumb NavXT. See the [Calling the Breadcrumb Trail](http://mtekk.us/archives/guides/calling-the-breadcrumb-trail "Read more on calling the breadcrumb trail") article for more information on calling the breadcrumb trail.
|
|
|
42 |
|
43 |
Please visit [Breadcrumb NavXT's Documentation](http://mtekk.us/code/breadcrumb-navxt/breadcrumb-navxt-doc/ "Go to Breadcrumb NavXT's Documentation.") page for more information.
|
44 |
|
52 |
|
53 |
== Changelog ==
|
54 |
|
55 |
+
= 6.0.0 =
|
56 |
+
Release date: December, 26th 2017
|
57 |
+
|
58 |
+
* Behavior change: `bcn_breadcrumb_trail::display_list()` deprecated in favor of using the `$template` parameter in `bcn_breadcrumb_trail::display()`.
|
59 |
+
* Behavior change: `bcn_breadcrumb_trail::do_attachment()` deprecated in favor of calling `bcn_breadcrumb_trail::do_post()`.
|
60 |
+
* Behavior change: `bcn_breadcrumb_trail::do_front_page()` deprecated in favor of calling `bcn_breadcrumb_trail::do_home()`.
|
61 |
+
* Behavior change: `bcn_li_attributes` filter was deprecated in favor of `bcn_display_attributes`.
|
62 |
+
* Behavior change: `bcn_breadcrumb_trail::do_archive_by_date()` deprecated in favor of calling bcn_breadcrumb_trail::do_day()`, `bcn_breadcrumb_trail::do_month()`, and/or `bcn_breadcrumb_trail::do_year()`.
|
63 |
+
* Behavior change: `bcn_breadcrumb_trail::find_type()` deprecated and removed from bcn_breadcrumb_trail.
|
64 |
+
* Behavior change: Breadcrumb for 404 error pages changed to be a child of the front page.
|
65 |
+
* New feature: Added support for various HTML tags in the widget's pretext field.
|
66 |
+
* New feature: Added `bcn_default_hierarchy_display` filter.
|
67 |
+
* New feature: Added `bcn_default_hierarchy_type` filter.
|
68 |
+
* New feature: Added `$posttype_name` as the third parameter to `bcn_show_tax_private`.
|
69 |
+
* Bug fix: Fixed UI/UX issue in the settings screen where enabling/disabling settings groups for the Home, Blog, and Mainsite breadcrumb settings did not work.
|
70 |
+
* Bug fix: Fixed UI/UX issue in the settings screen where not including the paged breadcrumb still allowed the paged breadcrumb template to be edited.
|
71 |
+
* Bug fix: Removed use of `create_function` in registering the widget as it was deprecated in PHP 7.2.
|
72 |
+
|
73 |
= 5.7.1 =
|
74 |
Release date: June 30th, 2017
|
75 |
|