Breadcrumb NavXT - Version 6.2.0

Version Description

Release date: September, 24th 2018

  • Behavior change: Cleaned up translations for default templates, simplifying and clarifying the translatable content.
  • Behavior change: Default unlinked breadcrumb templates no longer contain Schema.org BreadcrumbList markup.
  • Behavior change: Breadcrumb NavXT REST API endpoints are no longer enabled by default.
  • New feature: Added bcn_register_rest_endpoint filter.
  • New feature: Added bcn_breadcrumb_assemble_json_ld_array filter.
  • New feature: Added support for following the post parent hierarchy first then falling back to a secondary hierarchy.
  • Bug fix: Fixed issue where on loading the settings page immediately after migrating settings causes PHP warnings on CPT and custom taxonomy settings.
  • Bug fix: Fixed issue that caused the settings reset option under the help drop down to not work.
Download this release

Release Info

Developer mtekk
Plugin Icon 128x128 Breadcrumb NavXT
Version 6.2.0
Comparing to
See all releases

Code changes from version 6.1.0 to 6.2.0

breadcrumb-navxt.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Breadcrumb NavXT
4
  Plugin URI: http://mtekk.us/code/breadcrumb-navxt/
5
  Description: Adds a breadcrumb navigation showing the visitor&#39;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.1.0
7
  Author: John Havlik
8
  Author URI: http://mtekk.us/
9
  License: GPL2
@@ -61,7 +61,7 @@ $breadcrumb_navxt = null;
61
  //TODO change to extends mtekk_plugKit
62
  class breadcrumb_navxt
63
  {
64
- const version = '6.1.0';
65
  protected $name = 'Breadcrumb NavXT';
66
  protected $identifier = 'breadcrumb-navxt';
67
  protected $unique_prefix = 'bcn';
@@ -106,7 +106,10 @@ class breadcrumb_navxt
106
  public function init()
107
  {
108
  breadcrumb_navxt::setup_options($this->opt);
109
- $this->get_settings();
 
 
 
110
  add_filter('bcn_allowed_html', array($this, 'allowed_html'), 1, 1);
111
  //We want to run late for using our breadcrumbs
112
  add_filter('tha_breadcrumb_navigation', array($this, 'tha_compat'), 99);
@@ -291,11 +294,14 @@ class breadcrumb_navxt
291
  $opts['bpost_' . $post_type->name . '_taxonomy_referer'] = false;
292
  }
293
  //If the post type does not have settings in the options array yet, we need to load some defaults
294
- if(!isset($opts['Hpost_' . $post_type->name . '_template']) || !$post_type->hierarchical && !isset($opts['Spost_' . $post_type->name . '_hierarchy_type']))
295
  {
296
  //Add the necessary option array members
297
  $opts['Hpost_' . $post_type->name . '_template'] = bcn_breadcrumb::get_default_template();
298
  $opts['Hpost_' . $post_type->name . '_template_no_anchor'] = bcn_breadcrumb::default_template_no_anchor;
 
 
 
299
  if($post_type->has_archive == true || is_string($post_type->has_archive))
300
  {
301
  $opts['bpost_' . $post_type->name . '_archive_display'] = true;
@@ -333,6 +339,12 @@ class breadcrumb_navxt
333
  $opts['Spost_' . $post_type->name . '_hierarchy_type'] = apply_filters('bcn_default_hierarchy_type', $opts['Spost_' . $post_type->name . '_hierarchy_type'], $post_type->name);
334
  $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']);
335
  }
 
 
 
 
 
 
336
  }
337
  }
338
  }
3
  Plugin Name: Breadcrumb NavXT
4
  Plugin URI: http://mtekk.us/code/breadcrumb-navxt/
5
  Description: Adds a breadcrumb navigation showing the visitor&#39;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.2.0
7
  Author: John Havlik
8
  Author URI: http://mtekk.us/
9
  License: GPL2
61
  //TODO change to extends mtekk_plugKit
62
  class breadcrumb_navxt
63
  {
64
+ const version = '6.2.0';
65
  protected $name = 'Breadcrumb NavXT';
66
  protected $identifier = 'breadcrumb-navxt';
67
  protected $unique_prefix = 'bcn';
106
  public function init()
107
  {
108
  breadcrumb_navxt::setup_options($this->opt);
109
+ if(!is_admin() || !isset($_POST[$this->unique_prefix . '_admin_reset']))
110
+ {
111
+ $this->get_settings(); //This breaks the reset options script, so only do it if we're not trying to reset the settings
112
+ }
113
  add_filter('bcn_allowed_html', array($this, 'allowed_html'), 1, 1);
114
  //We want to run late for using our breadcrumbs
115
  add_filter('tha_breadcrumb_navigation', array($this, 'tha_compat'), 99);
294
  $opts['bpost_' . $post_type->name . '_taxonomy_referer'] = false;
295
  }
296
  //If the post type does not have settings in the options array yet, we need to load some defaults
297
+ if(!isset($opts['Hpost_' . $post_type->name . '_template']))
298
  {
299
  //Add the necessary option array members
300
  $opts['Hpost_' . $post_type->name . '_template'] = bcn_breadcrumb::get_default_template();
301
  $opts['Hpost_' . $post_type->name . '_template_no_anchor'] = bcn_breadcrumb::default_template_no_anchor;
302
+ }
303
+ if(!$post_type->hierarchical && !isset($opts['Spost_' . $post_type->name . '_hierarchy_type']))
304
+ {
305
  if($post_type->has_archive == true || is_string($post_type->has_archive))
306
  {
307
  $opts['bpost_' . $post_type->name . '_archive_display'] = true;
339
  $opts['Spost_' . $post_type->name . '_hierarchy_type'] = apply_filters('bcn_default_hierarchy_type', $opts['Spost_' . $post_type->name . '_hierarchy_type'], $post_type->name);
340
  $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']);
341
  }
342
+ //New for 6.2
343
+ if(!isset($opts['bpost_' . $post_type->name . '_hierarchy_parent_first']))
344
+ {
345
+ $opts['bpost_' . $post_type->name . '_hierarchy_parent_first'] = false;
346
+ $opts['bpost_' . $post_type->name . '_hierarchy_parent_first'] = apply_filters('bcn_default_hierarchy_parent_first', $opts['bpost_' . $post_type->name . '_hierarchy_parent_first'], $post_type->name);
347
+ }
348
  }
349
  }
350
  }
class.bcn_admin.php CHANGED
@@ -43,7 +43,7 @@ if(!class_exists('mtekk_adminKit'))
43
  */
44
  class bcn_admin extends mtekk_adminKit
45
  {
46
- const version = '6.1.0';
47
  protected $full_name = 'Breadcrumb NavXT Settings';
48
  protected $short_name = 'Breadcrumb NavXT';
49
  protected $access_level = 'manage_options';
@@ -295,7 +295,7 @@ class bcn_admin extends mtekk_adminKit
295
  }
296
  }
297
  //Save the passed in opts to the object's option array
298
- $this->opt = $opts;
299
  //End with resetting up the options
300
  breadcrumb_navxt::setup_options($this->opt);
301
  }
@@ -543,6 +543,7 @@ class bcn_admin extends mtekk_adminKit
543
  $this->textbox(__('Post Template', 'breadcrumb-navxt'), 'Hpost_post_template', '6', false, __('The template for post breadcrumbs.', 'breadcrumb-navxt'));
544
  $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'));
545
  $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');
 
546
  $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');
547
  ?>
548
  <tr valign="top">
@@ -581,6 +582,7 @@ class bcn_admin extends mtekk_adminKit
581
  $this->textbox(__('Page Template', 'breadcrumb-navxt'), 'Hpost_page_template', '6', false, __('The template for page breadcrumbs.', 'breadcrumb-navxt'));
582
  $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'));
583
  $this->input_hidden('bpost_page_hierarchy_display');
 
584
  $this->input_hidden('Spost_page_hierarchy_type');
585
  ?>
586
  </table>
@@ -623,6 +625,7 @@ class bcn_admin extends mtekk_adminKit
623
  <?php
624
  $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);
625
  $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');
 
626
  $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');
627
  ?>
628
  <tr valign="top">
43
  */
44
  class bcn_admin extends mtekk_adminKit
45
  {
46
+ const version = '6.2.0';
47
  protected $full_name = 'Breadcrumb NavXT Settings';
48
  protected $short_name = 'Breadcrumb NavXT';
49
  protected $access_level = 'manage_options';
295
  }
296
  }
297
  //Save the passed in opts to the object's option array
298
+ $this->opt = mtekk_adminKit::parse_args($opts, $this->opt);
299
  //End with resetting up the options
300
  breadcrumb_navxt::setup_options($this->opt);
301
  }
543
  $this->textbox(__('Post Template', 'breadcrumb-navxt'), 'Hpost_post_template', '6', false, __('The template for post breadcrumbs.', 'breadcrumb-navxt'));
544
  $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'));
545
  $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');
546
+ $this->input_check(__('Post Hierarchy Use Parent First', 'breadcrumb-navxt'), 'bpost_post_hierarchy_parent_first', __('Use the parent of the post as the primary hierarchy, falling back to the hierarchy selected below when the parent hierarchy is exhausted.', 'breadcrumb-navxt'), false, '', 'adminkit-enset');
547
  $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');
548
  ?>
549
  <tr valign="top">
582
  $this->textbox(__('Page Template', 'breadcrumb-navxt'), 'Hpost_page_template', '6', false, __('The template for page breadcrumbs.', 'breadcrumb-navxt'));
583
  $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'));
584
  $this->input_hidden('bpost_page_hierarchy_display');
585
+ $this->input_hidden('bpost_page_hierarchy_parent_first');
586
  $this->input_hidden('Spost_page_hierarchy_type');
587
  ?>
588
  </table>
625
  <?php
626
  $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);
627
  $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');
628
+ $this->input_check(sprintf(__('%s Hierarchy Use Parent First', 'breadcrumb-navxt'), $post_type->labels->singular_name), 'bpost_' . $post_type->name . '_hierarchy_parent_first', sprintf(__('Use the parent of the %s as the primary hierarchy, falling back to the hierarchy selected below when the parent hierarchy is exhausted.', 'breadcrumb-navxt'), $singular_name_lc), false, '', 'adminkit-enset');
629
  $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');
630
  ?>
631
  <tr valign="top">
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 = '6.1.0';
25
  //The main text that will be shown
26
  protected $title;
27
  //The breadcrumb's template, used durring assembly
@@ -38,7 +38,7 @@ class bcn_breadcrumb
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
  *
@@ -88,7 +88,7 @@ class bcn_breadcrumb
88
  */
89
  static public function get_default_template()
90
  {
91
- return __('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to %title%." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>', 'breadcrumb-navxt');
92
  }
93
  /**
94
  * Function to set the protected title member
@@ -261,12 +261,12 @@ class bcn_breadcrumb
261
  */
262
  public function assemble_json_ld($position)
263
  {
264
- return (object)array(
265
  '@type' => 'ListItem',
266
  'position' => $position,
267
  'item' => (object)array(
268
  '@id' => esc_url($this->url),
269
  'name' => esc_attr($this->title))
270
- );
271
  }
272
  }
21
  class bcn_breadcrumb
22
  {
23
  //Our member variables
24
+ const version = '6.2.0';
25
  //The main text that will be shown
26
  protected $title;
27
  //The breadcrumb's template, used durring assembly
38
  //The type of this breadcrumb
39
  protected $type;
40
  protected $allowed_html = array();
41
+ const default_template_no_anchor = '%htitle%';
42
  /**
43
  * The enhanced default constructor, ends up setting all parameters via the set_ functions
44
  *
88
  */
89
  static public function get_default_template()
90
  {
91
+ return sprintf('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="%1$s" href="%%link%%" class="%%type%%"><span property="name">%%htitle%%</span></a><meta property="position" content="%%position%%"></span>', esc_attr__('Go to %title%.','breadcrumb-navxt'));
92
  }
93
  /**
94
  * Function to set the protected title member
261
  */
262
  public function assemble_json_ld($position)
263
  {
264
+ return (object) apply_filters('bcn_breadcrumb_assembled_json_ld_array', array(
265
  '@type' => 'ListItem',
266
  'position' => $position,
267
  'item' => (object)array(
268
  '@id' => esc_url($this->url),
269
  'name' => esc_attr($this->title))
270
+ ), $this->type, $this->id);
271
  }
272
  }
class.bcn_breadcrumb_trail.php CHANGED
@@ -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 = '6.1.0';
25
  //An array of breadcrumbs
26
  public $breadcrumbs = array();
27
  public $trail = array();
@@ -64,6 +64,8 @@ class bcn_breadcrumb_trail
64
  //Static page options
65
  //Should the trail include the hierarchy of the page
66
  'bpost_page_hierarchy_display' => true,
 
 
67
  //What hierarchy should be shown leading to the page
68
  'Spost_page_hierarchy_type' => 'BCN_POST_PARENT',
69
  //The anchor template for page breadcrumbs
@@ -74,7 +76,7 @@ class bcn_breadcrumb_trail
74
  'apost_page_root' => get_option('page_on_front'),
75
  //Paged options
76
  //The template for paged breadcrumb
77
- 'Hpaged_template' => __('<span property="itemListElement" typeof="ListItem"><span property="name">Page %htitle%</span><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'),
78
  //Should we try filling out paged information
79
  'bpaged_display' => false,
80
  //The post options previously singleblogpost
@@ -86,12 +88,16 @@ class bcn_breadcrumb_trail
86
  'apost_post_root' => get_option('page_for_posts'),
87
  //Should the trail include the hierarchy of the post
88
  'bpost_post_hierarchy_display' => true,
 
 
89
  //Should the trail reflect the referer taxonomy or not
90
  'bpost_post_taxonomy_referer' => false,
91
  //What hierarchy should be shown leading to the post, tag or category
92
  'Spost_post_hierarchy_type' => 'category',
93
  //Attachment settings
94
  'bpost_attachment_hierarchy_display' => true,
 
 
95
  //What hierarchy should be shown leading to the attachment
96
  'Spost_attachment_hierarchy_type' => 'BCN_POST_PARENT',
97
  //Give an invlaid page ID for the attachement root
@@ -107,35 +113,41 @@ class bcn_breadcrumb_trail
107
  'S404_title' => __('404', 'breadcrumb-navxt'),
108
  //Search page options
109
  //The breadcrumb template for search breadcrumbs
110
- 'Hsearch_template' => __('<span property="itemListElement" typeof="ListItem"><span property="name">Search results for &#39;<a property="item" typeof="WebPage" title="Go to the first page of search results for %title%." href="%link%" class="%type%">%htitle%</a>&#39;</span><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'),
 
 
111
  //The breadcrumb template for search breadcrumbs, used when an anchor is not necessary
112
- 'Hsearch_template_no_anchor' => __('<span property="itemListElement" typeof="ListItem"><span property="name">Search results for &#39;%htitle%&#39;</span><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'),
 
113
  //Tag related stuff
114
  //The breadcrumb template for tag breadcrumbs
115
- 'Htax_post_tag_template' => __('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to the %title% tag archives." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'),
116
  //The breadcrumb template for tag breadcrumbs, used when an anchor is not necessary
117
  'Htax_post_tag_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor,
118
  //Post format related stuff
119
  //The breadcrumb template for post format breadcrumbs, used when an anchor is not necessary
120
- 'Htax_post_format_template' => __('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to the %title% archives." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'),
121
  //The breadcrumb template for post format breadcrumbs
122
  'Htax_post_format_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor,
123
  //Author page stuff
124
  //The anchor template for author breadcrumbs
125
- 'Hauthor_template' => __('<span property="itemListElement" typeof="ListItem"><span property="name">Articles by: <a title="Go to the first page of posts by %title%." href="%link%" class="%type%">%htitle%</a>', 'breadcrumb-navxt'),
 
 
126
  //The anchor template for author breadcrumbs, used when anchors are not needed
127
- 'Hauthor_template_no_anchor' => __('<span property="itemListElement" typeof="ListItem"><span property="name">Articles by: %htitle%</span><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'),
 
128
  //Which of the various WordPress display types should the author breadcrumb display
129
  'Sauthor_name' => 'display_name',
130
  //Give an invlaid page ID for the author root
131
  'aauthor_root' => 0,
132
  //Category stuff
133
  //The breadcrumb template for category breadcrumbs
134
- 'Htax_category_template' => __('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to the %title% category archives." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'),
135
  //The breadcrumb template for category breadcrumbs, used when anchors are not needed
136
  'Htax_category_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor,
137
  //The breadcrumb template for date breadcrumbs
138
- 'Hdate_template' => __('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="Go to the %title% archives." href="%link%" class="%type%"><span property="name">%htitle%</span></a><meta property="position" content="%position%"></span>', 'breadcrumb-navxt'),
139
  //The breadcrumb template for date breadcrumbs, used when anchors are not needed
140
  'Hdate_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor
141
  );
@@ -508,19 +520,15 @@ class bcn_breadcrumb_trail
508
  //Add the link
509
  $breadcrumb->set_url(get_permalink($post));
510
  }
511
- //If we have an attachment, run through the post again
512
- if($post->post_type === 'attachment')
 
 
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->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, true, false, false);
523
- }
524
  }
525
  //Otherwise we need the follow the hiearchy tree
526
  else
@@ -1103,7 +1111,7 @@ class bcn_breadcrumb_trail
1103
  {
1104
  $type_str = 'post';
1105
  }
1106
- if(isset($this->opt['apost_' . $type_str . '_root']))
1107
  {
1108
  $this->do_root($type_str, $this->opt['apost_' . $type_str . '_root'], is_paged(), $this->treat_as_root_page($type_str));
1109
  }
21
  class bcn_breadcrumb_trail
22
  {
23
  //Our member variables
24
+ const version = '6.2.0';
25
  //An array of breadcrumbs
26
  public $breadcrumbs = array();
27
  public $trail = array();
64
  //Static page options
65
  //Should the trail include the hierarchy of the page
66
  'bpost_page_hierarchy_display' => true,
67
+ //Should the post parent be followed first for this type, then fallback to the hierarchy type
68
+ 'bpost_page_hierarchy_parent_first' => false,
69
  //What hierarchy should be shown leading to the page
70
  'Spost_page_hierarchy_type' => 'BCN_POST_PARENT',
71
  //The anchor template for page breadcrumbs
76
  'apost_page_root' => get_option('page_on_front'),
77
  //Paged options
78
  //The template for paged breadcrumb
79
+ 'Hpaged_template' => sprintf('<span property="itemListElement" typeof="ListItem"><span property="name">%1$s</span><meta property="position" content="%%position%%"></span>', esc_attr__('Page %htitle%', 'breadcrumb-navxt')),
80
  //Should we try filling out paged information
81
  'bpaged_display' => false,
82
  //The post options previously singleblogpost
88
  'apost_post_root' => get_option('page_for_posts'),
89
  //Should the trail include the hierarchy of the post
90
  'bpost_post_hierarchy_display' => true,
91
+ //Should the post parent be followed first for this type, then fallback to the hierarchy type
92
+ 'bpost_post_hierarchy_parent_first' => false,
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
  'bpost_attachment_hierarchy_display' => true,
99
+ //Should the post parent be followed first for this type, then fallback to the hierarchy type
100
+ 'bpost_attachment_hierarchy_parent_first' => true,
101
  //What hierarchy should be shown leading to the attachment
102
  'Spost_attachment_hierarchy_type' => 'BCN_POST_PARENT',
103
  //Give an invlaid page ID for the attachement root
113
  'S404_title' => __('404', 'breadcrumb-navxt'),
114
  //Search page options
115
  //The breadcrumb template for search breadcrumbs
116
+ 'Hsearch_template' => sprintf('<span property="itemListElement" typeof="ListItem"><span property="name">%1$s</span><meta property="position" content="%%position%%"></span>',
117
+ sprintf(esc_attr__('Search results for &#39;%1$s&#39;', 'breadcrumb-navxt'),
118
+ sprintf('<a property="item" typeof="WebPage" title="%1$s" href="%%link%%" class="%%type%%">%%htitle%%</a>', esc_attr__('Go to the first page of search results for %title%.', 'breadcrumb-navxt')))),
119
  //The breadcrumb template for search breadcrumbs, used when an anchor is not necessary
120
+ 'Hsearch_template_no_anchor' => sprintf('<span property="itemListElement" typeof="ListItem"><span property="name">%1$s</span><meta property="position" content="%%position%%"></span>',
121
+ sprintf(esc_attr__('Search results for &#39;%1$s&#39;', 'breadcrumb-navxt'), '%htitle%')),
122
  //Tag related stuff
123
  //The breadcrumb template for tag breadcrumbs
124
+ 'Htax_post_tag_template' => sprintf('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="%1$s" href="%%link%%" class="%%type%%"><span property="name">%%htitle%%</span></a><meta property="position" content="%%position%%"></span>', esc_attr__('Go to the %title% tag archives.', 'breadcrumb-navxt')),
125
  //The breadcrumb template for tag breadcrumbs, used when an anchor is not necessary
126
  'Htax_post_tag_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor,
127
  //Post format related stuff
128
  //The breadcrumb template for post format breadcrumbs, used when an anchor is not necessary
129
+ 'Htax_post_format_template' => sprintf('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="%1$s" href="%%link%%" class="%%type%%"><span property="name">%%htitle%%</span></a><meta property="position" content="%%position%%"></span>', esc_attr__('Go to the %title% archives.', 'breadcrumb-navxt')),
130
  //The breadcrumb template for post format breadcrumbs
131
  'Htax_post_format_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor,
132
  //Author page stuff
133
  //The anchor template for author breadcrumbs
134
+ 'Hauthor_template' => sprintf('<span property="itemListElement" typeof="ListItem"><span property="name">%1$s</span><meta property="position" content="%%position%%"></span>',
135
+ sprintf(esc_attr__('Articles by: %1$s', 'breacrumb-navxt'),
136
+ sprintf('<a title="%1$s" href="%%link%%" class="%%type%%">%%htitle%%</a>', esc_attr__('Go to the first page of posts by %title%.', 'breadcrumb-navxt')))),
137
  //The anchor template for author breadcrumbs, used when anchors are not needed
138
+ 'Hauthor_template_no_anchor' => sprintf('<span property="itemListElement" typeof="ListItem"><span property="name">%1$s</span><meta property="position" content="%%position%%"></span>',
139
+ sprintf(esc_attr__('Articles by: %1$s', 'breacrumb-navxt'), '%htitle%')),
140
  //Which of the various WordPress display types should the author breadcrumb display
141
  'Sauthor_name' => 'display_name',
142
  //Give an invlaid page ID for the author root
143
  'aauthor_root' => 0,
144
  //Category stuff
145
  //The breadcrumb template for category breadcrumbs
146
+ 'Htax_category_template' => sprintf('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="%1$s" href="%%link%%" class="%%type%%"><span property="name">%%htitle%%</span></a><meta property="position" content="%%position%%"></span>', esc_attr__('Go to the %title% category archives.', 'breadcrumb-navxt')),
147
  //The breadcrumb template for category breadcrumbs, used when anchors are not needed
148
  'Htax_category_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor,
149
  //The breadcrumb template for date breadcrumbs
150
+ 'Hdate_template' => sprintf('<span property="itemListElement" typeof="ListItem"><a property="item" typeof="WebPage" title="%1$s" href="%%link%%" class="%%type%%"><span property="name">%%htitle%%</span></a><meta property="position" content="%%position%%"></span>', esc_attr__('Go to the %title% archives.', 'breadcrumb-navxt')),
151
  //The breadcrumb template for date breadcrumbs, used when anchors are not needed
152
  'Hdate_template_no_anchor' => bcn_breadcrumb::default_template_no_anchor
153
  );
520
  //Add the link
521
  $breadcrumb->set_url(get_permalink($post));
522
  }
523
+ //Done with the current item, now on to the parents
524
+ $frontpage = get_option('page_on_front');
525
+ //If we are to follow the hierarchy first (with hierarchy type backup), run through the post again
526
+ if($this->opt['bpost_' . $post->post_type. '_hierarchy_parent_first'] && $post->post_parent > 0 && $post->ID != $post->post_parent && $frontpage != $post->post_parent)
527
  {
528
+ //Get the parent's information
529
+ $parent = get_post($post->post_parent);
530
+ //Take care of the parent's breadcrumb
531
+ $this->do_post($parent, true, false, false);
 
 
 
 
 
 
532
  }
533
  //Otherwise we need the follow the hiearchy tree
534
  else
1111
  {
1112
  $type_str = 'post';
1113
  }
1114
+ if(isset($type_str) && isset($this->opt['apost_' . $type_str . '_root']))
1115
  {
1116
  $this->do_root($type_str, $this->opt['apost_' . $type_str . '_root'], is_paged(), $this->treat_as_root_page($type_str));
1117
  }
class.bcn_network_admin.php CHANGED
@@ -28,7 +28,7 @@ if(!class_exists('bcn_admin'))
28
  */
29
  class bcn_network_admin extends bcn_admin
30
  {
31
- const version = '6.1.0';
32
  protected $full_name = 'Breadcrumb NavXT Network Settings';
33
  protected $access_level = 'manage_network_options';
34
  /**
28
  */
29
  class bcn_network_admin extends bcn_admin
30
  {
31
+ const version = '6.2.0';
32
  protected $full_name = 'Breadcrumb NavXT Network Settings';
33
  protected $access_level = 'manage_network_options';
34
  /**
class.bcn_rest_controller.php CHANGED
@@ -50,9 +50,28 @@ class bcn_rest_controller
50
  $this->unique_prefix = $unique_prefix;
51
  add_action('rest_api_init', array($this, 'register_routes'));
52
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
  public function register_routes()
54
  {
55
- register_rest_route( $this->unique_prefix . '/v' . $this::version, '/post/(?P<id>[\d]+)', array(
56
  'args' => array(
57
  'id' => array(
58
  'description' => __('The ID of the post (any type) to retrieve the breadcrumb trail for.', 'breadcrumb-navxt'),
@@ -64,9 +83,9 @@ class bcn_rest_controller
64
  'methods' => $this->methods,
65
  'callback' => array($this, 'display_rest_post'),
66
  'permission_callback' => array($this, 'display_rest_post_permissions_check')
67
- )
68
  );
69
- register_rest_route( $this->unique_prefix . '/v' . $this::version, '/term/(?P<taxonomy>[\w-]+)/(?P<id>[\d]+)', array(
70
  'args' => array(
71
  'id' => array(
72
  'description' => __('The ID of the term to retrieve the breadcrumb trail for.', 'breadcrumb-navxt'),
@@ -83,9 +102,9 @@ class bcn_rest_controller
83
  ),
84
  'methods' => $this->methods,
85
  'callback' => array($this, 'display_rest_term')
86
- )
87
  );
88
- register_rest_route( $this->unique_prefix . '/v' . $this::version, '/author/(?P<id>\d+)', array(
89
  'args' => array(
90
  'id' => array(
91
  'description' => __('The ID of the author to retrieve the breadcrumb trail for.', 'breadcrumb-navxt'),
@@ -96,7 +115,7 @@ class bcn_rest_controller
96
  ),
97
  'methods' => $this->methods,
98
  'callback' => array($this, 'display_rest_author')
99
- )
100
  );
101
  }
102
  /**
50
  $this->unique_prefix = $unique_prefix;
51
  add_action('rest_api_init', array($this, 'register_routes'));
52
  }
53
+ /**
54
+ * A quick wrapper for register_rest_route to add our inclusion filter
55
+ *
56
+ * @param string $namespace The first URL segment after core prefix. Should be unique
57
+ * @param string $route The base URL for route being added
58
+ * @param array $args Optional. Either an array of options for the endpoint, or an array of arrays for
59
+ * multiple methods. Default empty array.
60
+ * @param bool $override Optional. If the route already exists, should we override it?
61
+ * @param string $endpoint The endpoint name passed into the bcn_register_rest_endpoint filter
62
+ * @return boolean True on success, false on error.
63
+ */
64
+ protected function register_rest_route($namespace, $route, $args = array(), $override = false, $endpoint)
65
+ {
66
+ if(apply_filters('bcn_register_rest_endpoint', false, $endpoint, $this::version, $this->methods))
67
+ {
68
+ return register_rest_route($namespace, $route, $args, $override);
69
+ }
70
+ return false;
71
+ }
72
  public function register_routes()
73
  {
74
+ $this->register_rest_route( $this->unique_prefix . '/v' . $this::version, '/post/(?P<id>[\d]+)', array(
75
  'args' => array(
76
  'id' => array(
77
  'description' => __('The ID of the post (any type) to retrieve the breadcrumb trail for.', 'breadcrumb-navxt'),
83
  'methods' => $this->methods,
84
  'callback' => array($this, 'display_rest_post'),
85
  'permission_callback' => array($this, 'display_rest_post_permissions_check')
86
+ ), false, 'post'
87
  );
88
+ $this->register_rest_route( $this->unique_prefix . '/v' . $this::version, '/term/(?P<taxonomy>[\w-]+)/(?P<id>[\d]+)', array(
89
  'args' => array(
90
  'id' => array(
91
  'description' => __('The ID of the term to retrieve the breadcrumb trail for.', 'breadcrumb-navxt'),
102
  ),
103
  'methods' => $this->methods,
104
  'callback' => array($this, 'display_rest_term')
105
+ ), false, 'term'
106
  );
107
+ $this->register_rest_route( $this->unique_prefix . '/v' . $this::version, '/author/(?P<id>\d+)', array(
108
  'args' => array(
109
  'id' => array(
110
  'description' => __('The ID of the author to retrieve the breadcrumb trail for.', 'breadcrumb-navxt'),
115
  ),
116
  'methods' => $this->methods,
117
  'callback' => array($this, 'display_rest_author')
118
+ ), false, 'author'
119
  );
120
  }
121
  /**
class.bcn_widget.php CHANGED
@@ -19,7 +19,7 @@
19
  require_once(dirname(__FILE__) . '/includes/block_direct_access.php');
20
  class bcn_widget extends WP_Widget
21
  {
22
- const version = '6.1.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
19
  require_once(dirname(__FILE__) . '/includes/block_direct_access.php');
20
  class bcn_widget extends WP_Widget
21
  {
22
+ const version = '6.2.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
includes/class.mtekk_adminkit.php CHANGED
@@ -24,7 +24,7 @@ if(!class_exists('mtekk_adminKit_message'))
24
  }
25
  abstract class mtekk_adminKit
26
  {
27
- const version = '2.0.1';
28
  protected $full_name;
29
  protected $short_name;
30
  protected $plugin_basename;
@@ -275,7 +275,7 @@ abstract class mtekk_adminKit
275
  $this->add_option($this->unique_prefix . '_options', $opts);
276
  $this->add_option($this->unique_prefix . '_options_bk', $opts, '', 'no');
277
  //Add the version, no need to autoload the db version
278
- $this->add_option($this->unique_prefix . '_version', $this::version, '', 'no');
279
  }
280
  else
281
  {
24
  }
25
  abstract class mtekk_adminKit
26
  {
27
+ const version = '2.0.2';
28
  protected $full_name;
29
  protected $short_name;
30
  protected $plugin_basename;
275
  $this->add_option($this->unique_prefix . '_options', $opts);
276
  $this->add_option($this->unique_prefix . '_options_bk', $opts, '', 'no');
277
  //Add the version, no need to autoload the db version
278
+ $this->update_option($this->unique_prefix . '_version', $this::version, 'no');
279
  }
280
  else
281
  {
readme.txt CHANGED
@@ -3,8 +3,8 @@ Contributors: mtekk, hakre
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=FD5XEU783BR8U&lc=US&item_name=Breadcrumb%20NavXT%20Donation&currency_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.1.0
8
  Requires PHP: 5.3
9
  License: GPLv2 or later
10
  Adds breadcrumb navigation showing the visitor's path to their current location.
@@ -49,6 +49,18 @@ Please visit [Breadcrumb NavXT's Documentation](http://mtekk.us/code/breadcrumb-
49
 
50
  == Changelog ==
51
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  = 6.1.0 =
53
  Release date: June, 1st 2018
54
 
3
  Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=FD5XEU783BR8U&lc=US&item_name=Breadcrumb%20NavXT%20Donation&currency_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.8
7
+ Stable tag: 6.2.0
8
  Requires PHP: 5.3
9
  License: GPLv2 or later
10
  Adds breadcrumb navigation showing the visitor's path to their current location.
49
 
50
  == Changelog ==
51
 
52
+ = 6.2.0 =
53
+ Release date: September, 24th 2018
54
+
55
+ * Behavior change: Cleaned up translations for default templates, simplifying and clarifying the translatable content.
56
+ * Behavior change: Default unlinked breadcrumb templates no longer contain Schema.org BreadcrumbList markup.
57
+ * Behavior change: Breadcrumb NavXT REST API endpoints are no longer enabled by default.
58
+ * New feature: Added `bcn_register_rest_endpoint` filter.
59
+ * New feature: Added `bcn_breadcrumb_assemble_json_ld_array` filter.
60
+ * New feature: Added support for following the post parent hierarchy first then falling back to a secondary hierarchy.
61
+ * Bug fix: Fixed issue where on loading the settings page immediately after migrating settings causes PHP warnings on CPT and custom taxonomy settings.
62
+ * Bug fix: Fixed issue that caused the settings reset option under the help drop down to not work.
63
+
64
  = 6.1.0 =
65
  Release date: June, 1st 2018
66