Breadcrumb Trail - Version 1.0.0

Version Description

Version 1.0.0+

If upgrading to a version earlier than 1.0.0, your custom styles may need to be adjusted. The HTML markup has changed to a better HTML5 structure.

Download this release

Release Info

Developer greenshady
Plugin Icon 128x128 Breadcrumb Trail
Version 1.0.0
Comparing to
See all releases

Code changes from version 0.6.1 to 1.0.0

breadcrumb-trail.php CHANGED
@@ -3,16 +3,77 @@
3
  * Plugin Name: Breadcrumb Trail
4
  * Plugin URI: http://themehybrid.com/plugins/breadcrumb-trail
5
  * Description: A smart breadcrumb menu plugin embedded with <a href="http://schema.org">Schema.org</a> microdata that can handle variations in site structure more accurately than any other breadcrumb plugin for WordPress. Insert into your theme with the <code>breadcrumb_trail()</code> template tag.
6
- * Version: 0.6.1
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
9
  * Text Domain: breadcrumb-trail
10
  * Domain Path: /languages
11
  */
12
 
13
- /* Extra check in case the script is being loaded by a theme. */
14
  if ( !function_exists( 'breadcrumb_trail' ) )
15
  require_once( 'inc/breadcrumbs.php' );
16
 
17
- /* Load translation files. Note: Remove this line if packaging with a theme. */
18
  load_plugin_textdomain( 'breadcrumb-trail', false, 'breadcrumb-trail/languages' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  * Plugin Name: Breadcrumb Trail
4
  * Plugin URI: http://themehybrid.com/plugins/breadcrumb-trail
5
  * Description: A smart breadcrumb menu plugin embedded with <a href="http://schema.org">Schema.org</a> microdata that can handle variations in site structure more accurately than any other breadcrumb plugin for WordPress. Insert into your theme with the <code>breadcrumb_trail()</code> template tag.
6
+ * Version: 1.0.0
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
9
  * Text Domain: breadcrumb-trail
10
  * Domain Path: /languages
11
  */
12
 
13
+ # Extra check in case the script is being loaded by a theme.
14
  if ( !function_exists( 'breadcrumb_trail' ) )
15
  require_once( 'inc/breadcrumbs.php' );
16
 
17
+ # Load translation files. Note: Remove this line if packaging with a theme.
18
  load_plugin_textdomain( 'breadcrumb-trail', false, 'breadcrumb-trail/languages' );
19
+
20
+ # Check theme support. */
21
+ add_action( 'after_setup_theme', 'breadcrumb_trail_theme_setup', 12 );
22
+
23
+ /**
24
+ * Checks if the theme supports the Breadcrumb Trail script. If it doesn't, we'll hook some styles
25
+ * into the header.
26
+ *
27
+ * @since 1.0.0
28
+ * @access public
29
+ * @return void
30
+ */
31
+ function breadcrumb_trail_theme_setup() {
32
+
33
+ if ( !current_theme_supports( 'breadcrumb-trail' ) )
34
+ add_action( 'wp_head', 'breadcrumb_trail_print_styles' );
35
+ }
36
+
37
+ /**
38
+ * Prints CSS styles in the header for themes that don't support Breadcrumb Trail.
39
+ *
40
+ * @since 1.0.0
41
+ * @access public
42
+ * @return void
43
+ */
44
+ function breadcrumb_trail_print_styles() {
45
+
46
+ $style = '
47
+ .breadcrumbs .trail-browse,
48
+ .breadcrumbs .trail-items,
49
+ .breadcrumbs .trail-items li {
50
+ display: inline-block;
51
+ margin: 0;
52
+ padding: 0;
53
+ border: none;
54
+ background: transparent;
55
+ text-indent: 0;
56
+ }
57
+
58
+ .breadcrumbs .trail-browse {
59
+ font-size: inherit;
60
+ font-style: inherit;
61
+ font-weight: inherit;
62
+ color: inherit;
63
+ }
64
+
65
+ .breadcrumbs .trail-items {
66
+ list-style: none;
67
+ }
68
+
69
+ .trail-items li::after {
70
+ content: "\002F";
71
+ padding: 0 0.5em;
72
+ }
73
+
74
+ .trail-items li:last-of-type::after {
75
+ display: none;
76
+ }';
77
+
78
+ echo "\n" . '<style type="text/css" id="breadcrumb-trail-css">' . trim( str_replace( array( "\r", "\n", "\t", " " ), '', $style ) ) . '</style>' . "\n";
79
+ }
changelog.md ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Change Log
2
+
3
+ ## [1.0.0] - 2015-07-07
4
+
5
+ ### Added
6
+
7
+ * Plugins and themes can now filter the `breadcrumb_trail_object` to use their own sub-classes of `Breadcrumb_Trail`.
8
+ * Adds the `role` and `aria-label` attributes to improve accessibility.
9
+ * Changed from a flat HTML structure to a proper HTML5 `<nav>` > header > list structure.
10
+ * Added basic CSS output for themes that don't support the plugin. This was needed for backwards compatibility with the new HTML structure.
11
+ * Added additional classes for styling in themes such as `.trail-items` (items wrapper) and `.trail-item` (single item).
12
+ * Improved [Schema.org](http://schema.org) support for the newer [BreadcrumbList](http://schema.org/BreadcrumbList) type.
13
+ * The category will now be shown by default on sites with a `%postname%` permalink structure for single post views.
14
+ * Better support for finding related custom post types and taxonomies.
15
+ * Added French translation files.
16
+
17
+ ### Fixed
18
+
19
+ * Accounts for `is_paged()` on single post views, which is needed for custom post types like forums that are paged.
20
+ * Always makes sure taxonomy terms exist before adding them as breadcrumb items.
21
+ * Uses `get_post()` instead of the deprecated `get_page()` function.
22
+ * Don't show parent page item if it's set as the front page and we're viewing a child page.
23
+
24
+ ### Changed
25
+
26
+ * Removed the `title` attribute for links. This is far better for accessibility.
27
+
28
+ ### Security
29
+
30
+ * Hardening security by making sure all URLs are passed through `esc_url()`.
31
+ * Hardening security by running translations through `esc_html_e()` and `esc_html__()`.
32
+
33
+ ### Removed
34
+
35
+ * bbPress support was dropped. If needed, developers should sub-class `Breadcrumb_Trail`.
36
+
37
+ ## [0.6.1]
38
+
39
+ * Make sure `breadcrumb_trail()` can return the HTML.
40
+ * Add `rel="home"` to the home page link. This got removed at some point.
41
+ * Do network and site home links in bbPress.
42
+ * Slight fix to stop bbPress from putting double "Forums" in the breadcrumb trail.
43
+ * The `show_on_front` argument should only work if the front page is not paginated.
44
+ * Better handling of the text strings, particularly when displaying date/time.
45
+ * Updated `breadcrumb-trail.pot` file for better translating.
46
+
47
+ ## [0.6.0]
48
+
49
+ * [Schema.org](http://schema.org) support.
50
+ * Completely overhauled the entire plugin, rewriting large swathes of code from the ground up. This version takes an object-oriented approach.
51
+ * Blew every other breadcrumb menu script out of the water.
52
+
53
+ ## [0.5.3]
54
+
55
+ ### Added
56
+
57
+ * Use `post_type_archive_title()` on post type archives in the trail.
58
+ * Add support for taxonomies that have a `$rewrite->slug` that matches a string value for a custom post type's `has_archive` argument.
59
+ * Added support for an `archive_title` label for custom post types because we can't use the `post_type_archive_title()` function on single posts views for the post type.
60
+ * Loads of pagination support on both archive-type pages and paged single posts.
61
+ * Added support for hierarchical custom post types (get parent posts).
62
+ * Added the `network` argument to allow multisite owners to run the trail all the way back to the main site.
63
+
64
+ ### Fixed
65
+
66
+ * Only check attachment trail if the attachment has a parent.
67
+ * Fixed the issue where the wrong post type archive link matches with a term archive page.
68
+
69
+ ## [0.5.2]
70
+
71
+ * No friggin' clue. I think I actually skipped version numbers somehow. :)
72
+
73
+ ## [0.5.1]
74
+
75
+ * Changed license from GPL 2-only to GPL 2+.
76
+ * Smarter handling of the `trail-begin` and `trail-end` classes.
77
+ * Added `container` argument for wrapping breadcrumbs in a custom HTML element.
78
+ * Changed `bbp_get_forum_parent()` to `bbp_get_forum_parent_id()`.
79
+
80
+ ## [0.5.0]
81
+
82
+ * Use hardcoded strings for the textdomain, not a variable.
83
+ * Inline doc updates.
84
+ * Added bbPress support.
85
+ * Use `single_post_title()` instead of `get_the_title()` for post titles.
86
+
87
+ ## [0.4.1]
88
+
89
+ * Use `get_queried_object()` and `get_queried_object_id()` instead of accessing `$wp_query` directly.
90
+ * Pass `$args` as second parameter in `breadcrumb_trail` hook.
91
+
92
+ ## [0.4.0]
93
+
94
+ * New function: `breadcrumb_trail_get_items()`, which grabs a list of all the trail items. This separates the items from the main `breadcrumb_trail()` function.
95
+ * New filter hook: `breadcrumb_trail_items`, which allows devs to filter just the items.
96
+ * New function: `breadcrumb_trail_map_rewrite_tags()`, which maps the permalink structure tags set under Permalink Settings in the admin to make for a much more accurate breadcrumb trail.
97
+ * New function: `breadcrumb_trail_textdomain()`, which can be filtered when integrating the plugin into a theme to match the theme's textdomain.
98
+ * Added functionality to handle WP 3.1 post type enhancements.
99
+
100
+ ## [0.3.2]
101
+
102
+ * Smarter logic in certain areas.
103
+ * Removed localization for things that shouldn't be localized with time formats.
104
+ * `single_tax` set to `null` instead of `false`.
105
+ * Better escaping of element attributes.
106
+ * Use `$wp_query->get_queried_object()` and `$wp_query->get_queried_object_id()`.
107
+ * Add in initial support of WordPress 3.1's post type archives.
108
+ * Better formatting and organization of the output late in the function.
109
+ * Added `trail-before` and `trail-after` CSS classes if `$before` or `$after` is set.
110
+
111
+ ## [0.3.1]
112
+
113
+ * Undefined index error fixes.
114
+ * Fixes for trying to get a property of a non-object.
115
+
116
+ ## [0.3.0]
117
+
118
+ * Added more support for custom post types and taxonomies.
119
+ * Added more support for more complex hierarchies.
120
+ * The breadcrumb trail now recognizes more patterns with pages as part of the permalink structure of other objects.
121
+ * All post types can have any taxonomy as the leading part of the trail.
122
+ * Cleaned up the code.
123
+
124
+ ## [0.2.1]
125
+
126
+ * Removed and/or added (depending on the case) the extra separator item on sub-categories and date-/time-based breadcrumbs.
127
+
128
+ ## [0.2.0]
129
+
130
+ * The title of the "home" page (i.e. posts page) when not the front page is now properly recognized.
131
+ * Cleaned up the code and logic behind the plugin.
132
+
133
+ ## [0.1.0]
134
+
135
+ * Launch of the new plugin.
inc/breadcrumbs.php CHANGED
@@ -2,28 +2,28 @@
2
  /**
3
  * Breadcrumb Trail - A breadcrumb menu script for WordPress.
4
  *
5
- * Breadcrumb Trail is a script for showing a breadcrumb trail for any type of page. It tries to
6
- * anticipate any type of structure and display the best possible trail that matches your site's
7
- * permalink structure. While not perfect, it attempts to fill in the gaps left by many other
8
  * breadcrumb scripts.
9
  *
10
- * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
11
- * General Public License as published by the Free Software Foundation; either version 2 of the License,
12
  * or (at your option) any later version.
13
  *
14
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
15
  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
  *
17
  * @package BreadcrumbTrail
18
- * @version 0.6.1
19
  * @author Justin Tadlock <justin@justintadlock.com>
20
- * @copyright Copyright (c) 2008 - 2013, Justin Tadlock
21
  * @link http://themehybrid.com/plugins/breadcrumb-trail
22
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23
  */
24
 
25
  /**
26
- * Shows a breadcrumb for all types of pages. This is a wrapper function for the Breadcrumb_Trail class,
27
  * which should be used in theme templates.
28
  *
29
  * @since 0.1.0
@@ -33,9 +33,9 @@
33
  */
34
  function breadcrumb_trail( $args = array() ) {
35
 
36
- if ( function_exists( 'is_bbpress' ) && is_bbpress() )
37
- $breadcrumb = new bbPress_Breadcrumb_Trail( $args );
38
- else
39
  $breadcrumb = new Breadcrumb_Trail( $args );
40
 
41
  return $breadcrumb->trail();
@@ -44,7 +44,8 @@ function breadcrumb_trail( $args = array() ) {
44
  /**
45
  * Creates a breadcrumbs menu for the site based on the current page that's being viewed by the user.
46
  *
47
- * @since 0.6.0
 
48
  */
49
  class Breadcrumb_Trail {
50
 
@@ -67,50 +68,87 @@ class Breadcrumb_Trail {
67
  public $args = array();
68
 
69
  /**
70
- * Sets up the breadcrumb trail.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71
  *
72
  * @since 0.6.0
73
  * @access public
74
- * @param array $args The arguments for how to build the breadcrumb trail.
 
 
 
 
 
 
 
 
 
 
 
75
  * @return void
76
  */
77
  public function __construct( $args = array() ) {
78
 
79
- /* Remove the bbPress breadcrumbs. */
80
- add_filter( 'bbp_get_breadcrumb', '__return_false' );
81
-
82
  $defaults = array(
83
- 'container' => 'div',
84
- 'separator' => '&#47;',
85
  'before' => '',
86
  'after' => '',
87
  'show_on_front' => true,
88
  'network' => false,
89
- //'show_edit_link' => false,
90
  'show_title' => true,
91
  'show_browse' => true,
92
- 'echo' => true,
93
-
94
- /* Post taxonomy (examples follow). */
95
- 'post_taxonomy' => array(
96
- // 'post' => 'post_tag',
97
- // 'book' => 'genre',
98
- ),
99
-
100
- /* Labels for text used (see Breadcrumb_Trail::default_labels). */
101
- 'labels' => array()
102
  );
103
 
 
104
  $this->args = apply_filters( 'breadcrumb_trail_args', wp_parse_args( $args, $defaults ) );
105
 
106
- /* Merge the user-added labels with the defaults. */
107
- $this->args['labels'] = wp_parse_args( $this->args['labels'], $this->default_labels() );
 
108
 
109
- $this->do_trail_items();
 
110
  }
111
 
 
 
112
  /**
113
- * Formats and outputs the breadcrumb trail.
114
  *
115
  * @since 0.6.0
116
  * @access public
@@ -118,77 +156,106 @@ class Breadcrumb_Trail {
118
  */
119
  public function trail() {
120
 
121
- $breadcrumb = '';
 
 
 
122
 
123
- /* Connect the breadcrumb trail if there are items in the trail. */
124
- if ( !empty( $this->items ) && is_array( $this->items ) ) {
125
 
126
- /* Make sure we have a unique array of items. */
127
- $this->items = array_unique( $this->items );
 
128
 
129
- /* Open the breadcrumb trail containers. */
130
- $breadcrumb = "\n\t\t" . '<' . tag_escape( $this->args['container'] ) . ' class="breadcrumb-trail breadcrumbs" itemprop="breadcrumb">';
131
 
132
- /* If $before was set, wrap it in a container. */
133
- $breadcrumb .= ( !empty( $this->args['before'] ) ? "\n\t\t\t" . '<span class="trail-before">' . $this->args['before'] . '</span> ' . "\n\t\t\t" : '' );
 
134
 
135
- /* Add 'browse' label if it should be shown. */
136
- if ( true === $this->args['show_browse'] )
137
- $breadcrumb .= "\n\t\t\t" . '<span class="trail-browse">' . $this->args['labels']['browse'] . '</span> ';
138
 
139
- /* Adds the 'trail-begin' class around first item if there's more than one item. */
140
- if ( 1 < count( $this->items ) )
141
- array_unshift( $this->items, '<span class="trail-begin">' . array_shift( $this->items ) . '</span>' );
142
 
143
- /* Adds the 'trail-end' class around last item. */
144
- array_push( $this->items, '<span class="trail-end">' . array_pop( $this->items ) . '</span>' );
145
 
146
- /* Format the separator. */
147
- $separator = ( !empty( $this->args['separator'] ) ? '<span class="sep">' . $this->args['separator'] . '</span>' : '<span class="sep">/</span>' );
148
 
149
- /* Join the individual trail items into a single string. */
150
- $breadcrumb .= join( "\n\t\t\t {$separator} ", $this->items );
151
 
152
- /* If $after was set, wrap it in a container. */
153
- $breadcrumb .= ( !empty( $this->args['after'] ) ? "\n\t\t\t" . ' <span class="trail-after">' . $this->args['after'] . '</span>' : '' );
154
 
155
- /* Close the breadcrumb trail containers. */
156
- $breadcrumb .= "\n\t\t" . '</' . tag_escape( $this->args['container'] ) . '>';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
157
  }
158
 
159
- /* Allow developers to filter the breadcrumb trail HTML. */
160
  $breadcrumb = apply_filters( 'breadcrumb_trail', $breadcrumb, $this->args );
161
 
162
- if ( true === $this->args['echo'] )
163
- echo $breadcrumb;
164
- else
165
  return $breadcrumb;
 
 
166
  }
167
 
 
 
168
  /**
169
- * Returns an array of the default labels.
170
  *
171
- * @since 0.6.0
172
- * @access public
173
- * @return array
174
  */
175
- public function default_labels() {
176
-
177
- $labels = array(
178
- 'browse' => __( 'Browse:', 'breadcrumb-trail' ),
179
- 'home' => __( 'Home', 'breadcrumb-trail' ),
180
- 'error_404' => __( '404 Not Found', 'breadcrumb-trail' ),
181
- 'archives' => __( 'Archives', 'breadcrumb-trail' ),
182
- /* Translators: %s is the search query. The HTML entities are opening and closing curly quotes. */
183
- 'search' => __( 'Search results for &#8220;%s&#8221;', 'breadcrumb-trail' ),
184
- /* Translators: %s is the page number. */
185
- 'paged' => __( 'Page %s', 'breadcrumb-trail' ),
186
- /* Translators: Minute archive title. %s is the minute time format. */
187
- 'archive_minute' => __( 'Minute %s', 'breadcrumb-trail' ),
188
- /* Translators: Weekly archive title. %s is the week date format. */
189
- 'archive_week' => __( 'Week %s', 'breadcrumb-trail' ),
190
-
191
- /* "%s" is replaced with the translated date/time format. */
 
192
  'archive_minute_hour' => '%s',
193
  'archive_hour' => '%s',
194
  'archive_day' => '%s',
@@ -196,205 +263,224 @@ class Breadcrumb_Trail {
196
  'archive_year' => '%s',
197
  );
198
 
199
- return $labels;
200
  }
201
 
202
  /**
203
- * Runs through the various WordPress conditional tags to check the current page being viewed. Once
204
- * a condition is met, a specific method is launched to add items to the $items array.
205
  *
206
- * @since 0.6.0
207
- * @access public
208
  * @return void
209
  */
210
- public function do_trail_items() {
 
 
211
 
212
- /* If viewing the front page. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
213
  if ( is_front_page() ) {
214
- $this->do_front_page_items();
215
  }
216
 
217
- /* If not viewing the front page. */
218
  else {
219
 
220
- /* Add the network and site home links. */
221
- $this->do_network_home_link();
222
- $this->do_site_home_link();
223
 
224
- /* If viewing the home/blog page. */
225
  if ( is_home() ) {
226
- $this->do_posts_page_items();
227
  }
228
 
229
- /* If viewing a single post. */
230
  elseif ( is_singular() ) {
231
- $this->do_singular_items();
232
  }
233
 
234
- /* If viewing an archive page. */
235
  elseif ( is_archive() ) {
236
 
237
  if ( is_post_type_archive() )
238
- $this->do_post_type_archive_items();
239
 
240
  elseif ( is_category() || is_tag() || is_tax() )
241
- $this->do_term_archive_items();
242
 
243
  elseif ( is_author() )
244
- $this->do_user_archive_items();
245
 
246
  elseif ( get_query_var( 'minute' ) && get_query_var( 'hour' ) )
247
- $this->do_minute_hour_archive_items();
248
 
249
  elseif ( get_query_var( 'minute' ) )
250
- $this->do_minute_archive_items();
251
 
252
  elseif ( get_query_var( 'hour' ) )
253
- $this->do_hour_archive_items();
254
 
255
  elseif ( is_day() )
256
- $this->do_day_archive_items();
257
 
258
  elseif ( get_query_var( 'w' ) )
259
- $this->do_week_archive_items();
260
 
261
  elseif ( is_month() )
262
- $this->do_month_archive_items();
263
 
264
  elseif ( is_year() )
265
- $this->do_year_archive_items();
266
 
267
  else
268
- $this->do_default_archive_items();
269
  }
270
 
271
- /* If viewing a search results page. */
272
  elseif ( is_search() ) {
273
- $this->do_search_items();
274
  }
275
 
276
- /* If viewing the 404 page. */
277
  elseif ( is_404() ) {
278
- $this->do_404_items();
279
  }
280
  }
281
 
282
- /* Add paged items if they exist. */
283
- $this->do_paged_items();
284
 
285
- /* Allow developers to overwrite the items for the breadcrumb trail. */
286
- $this->items = apply_filters( 'breadcrumb_trail_items', $this->items, $this->args );
287
  }
288
 
289
  /**
290
  * Gets front items based on $wp_rewrite->front.
291
  *
292
- * @since 0.6.0
293
- * @access public
294
  * @return void
295
  */
296
- public function do_rewrite_front_items() {
297
  global $wp_rewrite;
298
 
299
  if ( $wp_rewrite->front )
300
- $this->do_path_parents( $wp_rewrite->front );
301
  }
302
 
303
  /**
304
  * Adds the page/paged number to the items array.
305
  *
306
- * @since 0.6.0
307
- * @access public
308
  * @return void
309
  */
310
- public function do_paged_items() {
311
 
312
- /* If viewing a paged singular post. */
313
  if ( is_singular() && 1 < get_query_var( 'page' ) && true === $this->args['show_title'] )
314
- $this->items[] = sprintf( $this->args['labels']['paged'], number_format_i18n( absint( get_query_var( 'page' ) ) ) );
315
 
316
- /* If viewing a paged archive-type page. */
317
  elseif ( is_paged() && true === $this->args['show_title'] )
318
- $this->items[] = sprintf( $this->args['labels']['paged'], number_format_i18n( absint( get_query_var( 'paged' ) ) ) );
319
-
320
  }
321
 
322
  /**
323
  * Adds the network (all sites) home page link to the items array.
324
  *
325
- * @since 0.6.0
326
- * @access public
327
  * @return void
328
  */
329
- public function do_network_home_link() {
 
330
  if ( is_multisite() && !is_main_site() && true === $this->args['network'] )
331
- $this->items[] = '<a href="' . network_home_url() . '" title="' . esc_attr( $this->args['labels']['home'] ) . '" rel="home">' . $this->args['labels']['home'] . '</a>';
332
  }
333
 
334
  /**
335
  * Adds the current site's home page link to the items array.
336
  *
337
- * @since 0.6.0
338
- * @access public
339
  * @return void
340
  */
341
- public function do_site_home_link() {
342
- $label = ( is_multisite() && !is_main_site() && true === $this->args['network'] ) ? get_bloginfo( 'name' ) : $this->args['labels']['home'];
343
- $rel = ( is_multisite() && !is_main_site() && true === $this->args['network'] ) ? '' : ' rel="home"';
344
- $this->items[] = '<a href="' . home_url() . '" title="' . esc_attr( get_bloginfo( 'name' ) ) . '"' . $rel .'>' . $label . '</a>';
 
 
 
345
  }
346
 
347
  /**
348
  * Adds items for the front page to the items array.
349
  *
350
- * @since 0.6.0
351
- * @access public
352
  * @return void
353
  */
354
- public function do_front_page_items() {
355
 
356
- /* Only show front items if the 'show_on_front' argument is set to 'true'. */
357
  if ( true === $this->args['show_on_front'] || is_paged() || ( is_singular() && 1 < get_query_var( 'page' ) ) ) {
358
 
359
- /* If on a paged view, add the home link items. */
360
- if ( is_paged() ) {
361
- $this->do_network_home_link();
362
- $this->do_site_home_link();
363
- }
364
 
365
- /* If on the main front page, add the network home link item and the home item. */
366
- else {
367
- $this->do_network_home_link();
368
 
369
- if ( true === $this->args['show_title'] )
370
- $this->items[] = ( is_multisite() && true === $this->args['network'] ) ? get_bloginfo( 'name' ) : $this->args['labels']['home'];
371
- }
372
  }
373
  }
374
 
375
  /**
376
  * Adds items for the posts page (i.e., is_home()) to the items array.
377
  *
378
- * @since 0.6.0
379
- * @access public
380
  * @return void
381
  */
382
- public function do_posts_page_items() {
383
 
384
- /* Get the post ID and post. */
385
  $post_id = get_queried_object_id();
386
- $post = get_page( $post_id );
387
 
388
- /* If the post has parents, add them to the trail. */
389
  if ( 0 < $post->post_parent )
390
- $this->do_post_parents( $post->post_parent );
391
 
392
- /* Get the page title. */
393
  $title = get_the_title( $post_id );
394
 
395
- /* Add the posts page item. */
396
  if ( is_paged() )
397
- $this->items[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( $title ) . '">' . $title . '</a>';
398
 
399
  elseif ( $title && true === $this->args['show_title'] )
400
  $this->items[] = $title;
@@ -403,223 +489,106 @@ class Breadcrumb_Trail {
403
  /**
404
  * Adds singular post items to the items array.
405
  *
406
- * @since 0.6.0
407
- * @access public
408
  * @return void
409
  */
410
- public function do_singular_items() {
411
 
412
- /* Get the queried post. */
413
  $post = get_queried_object();
414
  $post_id = get_queried_object_id();
415
 
416
- /* If the post has a parent, follow the parent trail. */
417
  if ( 0 < $post->post_parent )
418
- $this->do_post_parents( $post->post_parent );
419
 
420
- /* If the post doesn't have a parent, get its hierarchy based off the post type. */
421
  else
422
- $this->do_post_hierarchy( $post_id );
423
 
424
- /* Display terms for specific post type taxonomy if requested. */
425
- $this->do_post_terms( $post_id );
 
426
 
427
- /* End with the post title. */
428
  if ( $post_title = single_post_title( '', false ) ) {
429
 
430
- if ( 1 < get_query_var( 'page' ) )
431
- $this->items[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( $post_title ) . '">' . $post_title . '</a>';
432
 
433
  elseif ( true === $this->args['show_title'] )
434
  $this->items[] = $post_title;
435
  }
436
  }
437
 
438
- /**
439
- * Adds a specific post's parents to the items array.
440
- *
441
- * @since 0.6.0
442
- * @access public
443
- * @param int $post_id The ID of the post to get the parents of.
444
- * @return void
445
- */
446
- public function do_post_parents( $post_id ) {
447
- $parents = array();
448
-
449
- while ( $post_id ) {
450
-
451
- /* Get the post by ID. */
452
- $post = get_post( $post_id );
453
-
454
- /* Add the formatted post link to the array of parents. */
455
- $parents[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . get_the_title( $post_id ) . '</a>';
456
-
457
- /* If there's no longer a post parent, brea out of the loop. */
458
- if ( 0 >= $post->post_parent )
459
- break;
460
-
461
- /* Change the post ID to the parent post to continue looping. */
462
- $post_id = $post->post_parent;
463
- }
464
-
465
- /* Get the post hierarchy based off the final parent post. */
466
- $this->do_post_hierarchy( $post_id );
467
-
468
- /* Merge the parent items into the items array. */
469
- $this->items = array_merge( $this->items, array_reverse( $parents ) );
470
- }
471
-
472
- /**
473
- * Adds a post's terms from a specific taxonomy to the items array.
474
- *
475
- * @since 0.6.0
476
- * @access public
477
- * @param int $post_id The ID of the post to get the terms for.
478
- * @return void
479
- */
480
- public function do_post_terms( $post_id ) {
481
-
482
- /* Get the post type. */
483
- $post_type = get_post_type( $post_id );
484
-
485
- /* Add the terms of the taxonomy for this post. */
486
- if ( !empty( $this->args['post_taxonomy'][ $post_type ] ) )
487
- $this->items[] = get_the_term_list( $post_id, $this->args['post_taxonomy'][ $post_type ], '', ', ', '' );
488
- }
489
-
490
- /**
491
- * Adds a specific post's hierarchy to the items array. The hierarchy is determined by post type's
492
- * rewrite arguments and whether it has an archive page.
493
- *
494
- * @since 0.6.0
495
- * @access public
496
- * @param int $post_id The ID of the post to get the hierarchy for.
497
- * @return void
498
- */
499
- public function do_post_hierarchy( $post_id ) {
500
-
501
- /* Get the post type. */
502
- $post_type = get_post_type( $post_id );
503
- $post_type_object = get_post_type_object( $post_type );
504
-
505
- /* If this is the 'post' post type, get the rewrite front items and map the rewrite tags. */
506
- if ( 'post' === $post_type ) {
507
-
508
- /* Add $wp_rewrite->front to the trail. */
509
- $this->do_rewrite_front_items();
510
-
511
- /* Map the rewrite tags. */
512
- $this->map_rewrite_tags( $post_id, get_option( 'permalink_structure' ) );
513
- }
514
-
515
- /* If the post type has rewrite rules. */
516
- elseif ( false !== $post_type_object->rewrite ) {
517
-
518
- /* If 'with_front' is true, add $wp_rewrite->front to the trail. */
519
- if ( $post_type_object->rewrite['with_front'] )
520
- $this->do_rewrite_front_items();
521
-
522
- /* If there's a path, check for parents. */
523
- if ( !empty( $post_type_object->rewrite['slug'] ) )
524
- $this->do_path_parents( $post_type_object->rewrite['slug'] );
525
- }
526
-
527
- /* If there's an archive page, add it to the trail. */
528
- if ( !empty( $post_type_object->has_archive ) ) {
529
-
530
- /* Add support for a non-standard label of 'archive_title' (special use case). */
531
- $label = !empty( $post_type_object->labels->archive_title ) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
532
-
533
- $this->items[] = '<a href="' . get_post_type_archive_link( $post_type ) . '">' . $label . '</a>';
534
- }
535
- }
536
-
537
- /**
538
- * Gets post types by slug. This is needed because the get_post_types() function doesn't exactly
539
- * match the 'has_archive' argument when it's set as a string instead of a boolean.
540
- *
541
- * @since 0.6.0
542
- * @access public
543
- * @param int $slug The post type archive slug to search for.
544
- * @return void
545
- */
546
- public function get_post_types_by_slug( $slug ) {
547
-
548
- $return = array();
549
-
550
- $post_types = get_post_types( array(), 'objects' );
551
-
552
- foreach ( $post_types as $type ) {
553
-
554
- if ( $slug === $type->has_archive || ( true === $type->has_archive && $slug === $type->rewrite['slug'] ) )
555
- $return[] = $type;
556
- }
557
-
558
- return $return;
559
- }
560
-
561
  /**
562
  * Adds the items to the trail items array for taxonomy term archives.
563
  *
564
- * @since 0.6.0
565
- * @access public
566
  * @global object $wp_rewrite
567
  * @return void
568
  */
569
- public function do_term_archive_items() {
570
  global $wp_rewrite;
571
 
572
- /* Get some taxonomy and term variables. */
573
- $term = get_queried_object();
574
- $taxonomy = get_taxonomy( $term->taxonomy );
 
575
 
576
- /* If there are rewrite rules for the taxonomy. */
577
  if ( false !== $taxonomy->rewrite ) {
578
 
579
- /* If 'with_front' is true, dd $wp_rewrite->front to the trail. */
580
  if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front )
581
- $this->do_rewrite_front_items();
582
 
583
- /* Get parent pages by path if they exist. */
584
- $this->do_path_parents( $taxonomy->rewrite['slug'] );
585
 
586
- /* Add post type archive if its 'has_archive' matches the taxonomy rewrite 'slug'. */
587
  if ( $taxonomy->rewrite['slug'] ) {
588
 
589
  $slug = trim( $taxonomy->rewrite['slug'], '/' );
590
 
591
- /**
592
- * Deals with the situation if the slug has a '/' between multiple strings. For
593
- * example, "movies/genres" where "movies" is the post type archive.
594
- */
595
  $matches = explode( '/', $slug );
596
 
597
- /* If matches are found for the path. */
598
  if ( isset( $matches ) ) {
599
 
600
- /* Reverse the array of matches to search for posts in the proper order. */
601
  $matches = array_reverse( $matches );
602
 
603
- /* Loop through each of the path matches. */
604
  foreach ( $matches as $match ) {
605
 
606
- /* If a match is found. */
607
  $slug = $match;
608
 
609
- /* Get public post types that match the rewrite slug. */
610
  $post_types = $this->get_post_types_by_slug( $match );
611
 
612
  if ( !empty( $post_types ) ) {
613
 
614
  $post_type_object = $post_types[0];
615
 
616
- /* Add support for a non-standard label of 'archive_title' (special use case). */
617
  $label = !empty( $post_type_object->labels->archive_title ) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
618
 
619
- /* Add the post type archive link to the trail. */
620
- $this->items[] = '<a href="' . get_post_type_archive_link( $post_type_object->name ) . '" title="' . esc_attr( $label ) . '">' . $label . '</a>';
 
 
 
621
 
622
- /* Break out of the loop. */
 
 
623
  break;
624
  }
625
  }
@@ -627,13 +596,36 @@ class Breadcrumb_Trail {
627
  }
628
  }
629
 
630
- /* If the taxonomy is hierarchical, list its parent terms. */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
631
  if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent )
632
- $this->do_term_parents( $term->parent, $term->taxonomy );
633
 
634
- /* Add the term name to the trail end. */
635
  if ( is_paged() )
636
- $this->items[] = '<a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '" title="' . esc_attr( single_term_title( '', false ) ) . '">' . single_term_title( '', false ) . '</a>';
637
 
638
  elseif ( true === $this->args['show_title'] )
639
  $this->items[] = single_term_title( '', false );
@@ -642,29 +634,29 @@ class Breadcrumb_Trail {
642
  /**
643
  * Adds the items to the trail items array for post type archives.
644
  *
645
- * @since 0.6.0
646
- * @access public
647
  * @return void
648
  */
649
- public function do_post_type_archive_items() {
650
 
651
- /* Get the post type object. */
652
  $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
653
 
654
  if ( false !== $post_type_object->rewrite ) {
655
 
656
- /* If 'with_front' is true, add $wp_rewrite->front to the trail. */
657
  if ( $post_type_object->rewrite['with_front'] )
658
- $this->do_rewrite_front_items();
659
 
660
- /* If there's a rewrite slug, check for parents. */
661
  if ( !empty( $post_type_object->rewrite['slug'] ) )
662
- $this->do_path_parents( $post_type_object->rewrite['slug'] );
663
  }
664
 
665
- /* Add the post type [plural] name to the trail end. */
666
  if ( is_paged() )
667
- $this->items[] = '<a href="' . esc_url( get_post_type_archive_link( $post_type_object->name ) ) . '" title="' . esc_attr( post_type_archive_title( '', false ) ) . '">' . post_type_archive_title( '', false ) . '</a>';
668
 
669
  elseif ( true === $this->args['show_title'] )
670
  $this->items[] = post_type_archive_title( '', false );
@@ -673,27 +665,27 @@ class Breadcrumb_Trail {
673
  /**
674
  * Adds the items to the trail items array for user (author) archives.
675
  *
676
- * @since 0.6.0
677
- * @access public
678
  * @global object $wp_rewrite
679
  * @return void
680
  */
681
- public function do_user_archive_items() {
682
  global $wp_rewrite;
683
 
684
- /* Add $wp_rewrite->front to the trail. */
685
- $this->do_rewrite_front_items();
686
 
687
- /* Get the user ID. */
688
  $user_id = get_query_var( 'author' );
689
 
690
- /* If $author_base exists, check for parent pages. */
691
  if ( !empty( $wp_rewrite->author_base ) )
692
- $this->do_path_parents( $wp_rewrite->author_base );
693
 
694
- /* Add the author's display name to the trail end. */
695
  if ( is_paged() )
696
- $this->items[] = '<a href="'. esc_url( get_author_posts_url( $user_id ) ) . '" title="' . esc_attr( get_the_author_meta( 'display_name', $user_id ) ) . '">' . get_the_author_meta( 'display_name', $user_id ) . '</a>';
697
 
698
  elseif ( true === $this->args['show_title'] )
699
  $this->items[] = get_the_author_meta( 'display_name', $user_id );
@@ -702,78 +694,78 @@ class Breadcrumb_Trail {
702
  /**
703
  * Adds the items to the trail items array for minute + hour archives.
704
  *
705
- * @since 0.6.0
706
- * @access public
707
  * @return void
708
  */
709
- public function do_minute_hour_archive_items() {
710
 
711
- /* Add $wp_rewrite->front to the trail. */
712
- $this->do_rewrite_front_items();
713
 
714
- /* Add the minute + hour item. */
715
  if ( true === $this->args['show_title'] )
716
- $this->items[] = sprintf( $this->args['labels']['archive_minute_hour'], get_the_time( _x( 'g:i a', 'minute and hour archives time format', 'breadcrumb-trail' ) ) );
717
  }
718
 
719
  /**
720
  * Adds the items to the trail items array for minute archives.
721
  *
722
- * @since 0.6.0
723
- * @access public
724
  * @return void
725
  */
726
- public function do_minute_archive_items() {
727
 
728
- /* Add $wp_rewrite->front to the trail. */
729
- $this->do_rewrite_front_items();
730
 
731
- /* Add the minute item. */
732
  if ( true === $this->args['show_title'] )
733
- $this->items[] = sprintf( $this->args['labels']['archive_minute'], get_the_time( _x( 'i', 'minute archives time format', 'breadcrumb-trail' ) ) );
734
  }
735
 
736
  /**
737
  * Adds the items to the trail items array for hour archives.
738
  *
739
- * @since 0.6.0
740
- * @access public
741
  * @return void
742
  */
743
- public function do_hour_archive_items() {
744
 
745
- /* Add $wp_rewrite->front to the trail. */
746
- $this->do_rewrite_front_items();
747
 
748
- /* Add the hour item. */
749
  if ( true === $this->args['show_title'] )
750
- $this->items[] = sprintf( $this->args['labels']['archive_hour'], get_the_time( _x( 'g a', 'hour archives time format', 'breadcrumb-trail' ) ) );
751
  }
752
 
753
  /**
754
  * Adds the items to the trail items array for day archives.
755
  *
756
- * @since 0.6.0
757
- * @access public
758
  * @return void
759
  */
760
- public function do_day_archive_items() {
761
 
762
- /* Add $wp_rewrite->front to the trail. */
763
- $this->do_rewrite_front_items();
764
 
765
- /* Get year, month, and day. */
766
- $year = sprintf( $this->args['labels']['archive_year'], get_the_time( _x( 'Y', 'yearly archives date format', 'breadcrumb-trail' ) ) );
767
- $month = sprintf( $this->args['labels']['archive_month'], get_the_time( _x( 'F', 'monthly archives date format', 'breadcrumb-trail' ) ) );
768
- $day = sprintf( $this->args['labels']['archive_day'], get_the_time( _x( 'j', 'daily archives date format', 'breadcrumb-trail' ) ) );
769
 
770
- /* Add the year and month items. */
771
- $this->items[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . esc_attr( $year ) . '">' . $year . '</a>';
772
- $this->items[] = '<a href="' . get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) . '" title="' . esc_attr( $month ) . '">' . $month . '</a>';
773
 
774
- /* Add the day item. */
775
  if ( is_paged() )
776
- $this->items[] = '<a href="' . get_day_link( get_the_time( 'Y' ), get_the_time( 'm' ), get_the_time( 'd' ) ) . '" title="' . esc_attr( $day ) . '">' . $day . '</a>';
777
 
778
  elseif ( true === $this->args['show_title'] )
779
  $this->items[] = $day;
@@ -782,25 +774,25 @@ class Breadcrumb_Trail {
782
  /**
783
  * Adds the items to the trail items array for week archives.
784
  *
785
- * @since 0.6.0
786
- * @access public
787
  * @return void
788
  */
789
- public function do_week_archive_items() {
790
 
791
- /* Add $wp_rewrite->front to the trail. */
792
- $this->do_rewrite_front_items();
793
 
794
- /* Get the year and week. */
795
- $year = sprintf( $this->args['labels']['archive_year'], get_the_time( _x( 'Y', 'yearly archives date format', 'breadcrumb-trail' ) ) );
796
- $week = sprintf( $this->args['labels']['archive_week'], get_the_time( _x( 'W', 'weekly archives date format', 'breadcrumb-trail' ) ) );
797
 
798
- /* Add the year item. */
799
- $this->items[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . esc_attr( $year ) . '">' . $year . '</a>';
800
 
801
- /* Add the week item. */
802
  if ( is_paged() )
803
- $this->items[] = get_archives_link( add_query_arg( array( 'm' => get_the_time( 'Y' ), 'w' => get_the_time( 'W' ) ), home_url() ), $week, false );
804
 
805
  elseif ( true === $this->args['show_title'] )
806
  $this->items[] = $week;
@@ -809,25 +801,25 @@ class Breadcrumb_Trail {
809
  /**
810
  * Adds the items to the trail items array for month archives.
811
  *
812
- * @since 0.6.0
813
- * @access public
814
  * @return void
815
  */
816
- public function do_month_archive_items() {
817
 
818
- /* Add $wp_rewrite->front to the trail. */
819
- $this->do_rewrite_front_items();
820
 
821
- /* Get the year and month. */
822
- $year = sprintf( $this->args['labels']['archive_year'], get_the_time( _x( 'Y', 'yearly archives date format', 'breadcrumb-trail' ) ) );
823
- $month = sprintf( $this->args['labels']['archive_month'], get_the_time( _x( 'F', 'monthly archives date format', 'breadcrumb-trail' ) ) );
824
 
825
- /* Add the year item. */
826
- $this->items[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . esc_attr( $year ) . '">' . $year . '</a>';
827
 
828
- /* Add the month item. */
829
  if ( is_paged() )
830
- $this->items[] = '<a href="' . get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) . '" title="' . esc_attr( $month ) . '">' . $month . '</a>';
831
 
832
  elseif ( true === $this->args['show_title'] )
833
  $this->items[] = $month;
@@ -836,21 +828,21 @@ class Breadcrumb_Trail {
836
  /**
837
  * Adds the items to the trail items array for year archives.
838
  *
839
- * @since 0.6.0
840
- * @access public
841
  * @return void
842
  */
843
- public function do_year_archive_items() {
844
 
845
- /* Add $wp_rewrite->front to the trail. */
846
- $this->do_rewrite_front_items();
847
 
848
- /* Get the year. */
849
- $year = sprintf( $this->args['labels']['archive_year'], get_the_time( _x( 'Y', 'yearly archives date format', 'breadcrumb-trail' ) ) );
850
 
851
- /* Add the year item. */
852
  if ( is_paged() )
853
- $this->items[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . esc_attr( $year ) . '">' . $year . '</a>';
854
 
855
  elseif ( true === $this->args['show_title'] )
856
  $this->items[] = $year;
@@ -860,100 +852,249 @@ class Breadcrumb_Trail {
860
  * Adds the items to the trail items array for archives that don't have a more specific method
861
  * defined in this class.
862
  *
863
- * @since 0.6.0
864
- * @access public
865
  * @return void
866
  */
867
- public function do_default_archive_items() {
868
 
869
- /* If this is a date-/time-based archive, add $wp_rewrite->front to the trail. */
870
  if ( is_date() || is_time() )
871
- $this->do_rewrite_front_items();
872
 
873
  if ( true === $this->args['show_title'] )
874
- $this->items[] = $this->args['labels']['archives'];
875
  }
876
 
877
  /**
878
  * Adds the items to the trail items array for search results.
879
  *
880
- * @since 0.6.0
881
- * @access public
882
  * @return void
883
  */
884
- public function do_search_items() {
885
 
886
  if ( is_paged() )
887
- $this->items[] = '<a href="' . get_search_link() . '" title="' . esc_attr( sprintf( $this->args['labels']['search'], get_search_query() ) ) . '">' . sprintf( $this->args['labels']['search'], get_search_query() ) . '</a>';
888
 
889
  elseif ( true === $this->args['show_title'] )
890
- $this->items[] = sprintf( $this->args['labels']['search'], get_search_query() );
891
  }
892
 
893
  /**
894
  * Adds the items to the trail items array for 404 pages.
895
  *
896
- * @since 0.6.0
897
- * @access public
898
  * @return void
899
  */
900
- public function do_404_items() {
901
 
902
  if ( true === $this->args['show_title'] )
903
- $this->items[] = $this->args['labels']['error_404'];
904
  }
905
 
906
  /**
907
- * Get parent posts by path. Currently, this method only supports getting parents of the 'page'
908
- * post type. The goal of this function is to create a clear path back to home given what would
909
- * normally be a "ghost" directory. If any page matches the given path, it'll be added.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
910
  *
911
  * @since 0.6.0
912
- * @access public
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
913
  * @param string $path The path (slug) to search for posts by.
914
  * @return void
915
  */
916
- function do_path_parents( $path ) {
917
 
918
- /* Trim '/' off $path in case we just got a simple '/' instead of a real path. */
919
  $path = trim( $path, '/' );
920
 
921
- /* If there's no path, return. */
922
  if ( empty( $path ) )
923
  return;
924
 
925
- /* Get parent post by the path. */
926
  $post = get_page_by_path( $path );
927
 
928
  if ( !empty( $post ) ) {
929
- $this->do_post_parents( $post->ID );
930
  }
931
 
932
  elseif ( is_null( $post ) ) {
933
 
934
- /* Separate post names into separate paths by '/'. */
935
  $path = trim( $path, '/' );
936
  preg_match_all( "/\/.*?\z/", $path, $matches );
937
 
938
- /* If matches are found for the path. */
939
  if ( isset( $matches ) ) {
940
 
941
- /* Reverse the array of matches to search for posts in the proper order. */
942
  $matches = array_reverse( $matches );
943
 
944
- /* Loop through each of the path matches. */
945
  foreach ( $matches as $match ) {
946
 
947
- /* If a match is found. */
948
  if ( isset( $match[0] ) ) {
949
 
950
- /* Get the parent post by the given path. */
951
  $path = str_replace( $match[0], '', $path );
952
  $post = get_page_by_path( trim( $path, '/' ) );
953
 
954
- /* If a parent post is found, set the $post_id and break out of the loop. */
955
  if ( !empty( $post ) && 0 < $post->ID ) {
956
- $this->do_post_parents( $post->ID );
957
  break;
958
  }
959
  }
@@ -963,268 +1104,99 @@ class Breadcrumb_Trail {
963
  }
964
 
965
  /**
966
- * Searches for term parents of hierarchical taxonomies. This function is similar to the WordPress
967
  * function get_category_parents() but handles any type of taxonomy.
968
  *
969
- * @since 0.6.0
970
  * @param int $term_id ID of the term to get the parents of.
971
  * @param string $taxonomy Name of the taxonomy for the given term.
972
  * @return void
973
  */
974
- function do_term_parents( $term_id, $taxonomy ) {
975
 
976
- /* Set up some default arrays. */
977
  $parents = array();
978
 
979
- /* While there is a parent ID, add the parent term link to the $parents array. */
980
  while ( $term_id ) {
981
 
982
- /* Get the parent term. */
983
  $term = get_term( $term_id, $taxonomy );
984
 
985
- /* Add the formatted term link to the array of parent terms. */
986
- $parents[] = '<a href="' . get_term_link( $term, $taxonomy ) . '" title="' . esc_attr( $term->name ) . '">' . $term->name . '</a>';
987
 
988
- /* Set the parent term's parent as the parent ID. */
989
  $term_id = $term->parent;
990
  }
991
 
992
- /* If we have parent terms, reverse the array to put them in the proper order for the trail. */
993
  if ( !empty( $parents ) )
994
  $this->items = array_merge( $this->items, $parents );
995
  }
996
 
997
  /**
998
  * Turns %tag% from permalink structures into usable links for the breadcrumb trail. This feels kind of
999
- * hackish for now because we're checking for specific %tag% examples and only doing it for the 'post'
1000
  * post type. In the future, maybe it'll handle a wider variety of possibilities, especially for custom post
1001
  * types.
1002
  *
1003
  * @since 0.6.0
1004
- * @access public
1005
  * @param int $post_id ID of the post whose parents we want.
1006
  * @param string $path Path of a potential parent page.
1007
  * @param array $args Mixed arguments for the menu.
1008
  * @return array
1009
  */
1010
- public function map_rewrite_tags( $post_id, $path ) {
1011
 
1012
- /* Get the post based on the post ID. */
1013
  $post = get_post( $post_id );
1014
 
1015
- /* If no post is returned, an error is returned, or the post does not have a 'post' post type, return. */
1016
- if ( empty( $post ) || is_wp_error( $post ) || 'post' !== $post->post_type )
1017
- return $trail;
1018
 
1019
- /* Trim '/' from both sides of the $path. */
1020
  $path = trim( $path, '/' );
1021
 
1022
- /* Split the $path into an array of strings. */
1023
  $matches = explode( '/', $path );
1024
 
1025
- /* If matches are found for the path. */
1026
  if ( is_array( $matches ) ) {
1027
 
1028
- /* Loop through each of the matches, adding each to the $trail array. */
1029
  foreach ( $matches as $match ) {
1030
 
1031
- /* Trim any '/' from the $match. */
1032
  $tag = trim( $match, '/' );
1033
 
1034
- /* If using the %year% tag, add a link to the yearly archive. */
1035
  if ( '%year%' == $tag )
1036
- $this->items[] = '<a href="' . get_year_link( get_the_time( 'Y', $post_id ) ) . '">' . sprintf( $this->args['labels']['archive_year'], get_the_time( _x( 'Y', 'yearly archives date format', 'breadcrumb-trail' ) ) ) . '</a>';
1037
 
1038
- /* If using the %monthnum% tag, add a link to the monthly archive. */
1039
  elseif ( '%monthnum%' == $tag )
1040
- $this->items[] = '<a href="' . get_month_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ) ) . '">' . sprintf( $this->args['labels']['archive_month'], get_the_time( _x( 'F', 'monthly archives date format', 'breadcrumb-trail' ) ) ) . '</a>';
1041
 
1042
- /* If using the %day% tag, add a link to the daily archive. */
1043
  elseif ( '%day%' == $tag )
1044
- $this->items[] = '<a href="' . get_day_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ), get_the_time( 'd', $post_id ) ) . '">' . sprintf( $this->args['labels']['archive_day'], get_the_time( _x( 'j', 'daily archives date format', 'breadcrumb-trail' ) ) ) . '</a>';
1045
 
1046
- /* If using the %author% tag, add a link to the post author archive. */
1047
  elseif ( '%author%' == $tag )
1048
- $this->items[] = '<a href="' . get_author_posts_url( $post->post_author ) . '" title="' . esc_attr( get_the_author_meta( 'display_name', $post->post_author ) ) . '">' . get_the_author_meta( 'display_name', $post->post_author ) . '</a>';
1049
 
1050
- /* If using the %category% tag, add a link to the first category archive to match permalinks. */
1051
  elseif ( '%category%' == $tag ) {
1052
 
1053
- /* Force override terms in this post type. */
1054
- $this->args['post_taxonomy'][ $post->post_type ] = false;
1055
-
1056
- /* Get the post categories. */
1057
- $terms = get_the_category( $post_id );
1058
 
1059
- /* Check that categories were returned. */
1060
- if ( $terms ) {
1061
-
1062
- /* Sort the terms by ID and get the first category. */
1063
- usort( $terms, '_usort_terms_by_ID' );
1064
- $term = get_term( $terms[0], 'category' );
1065
-
1066
- /* If the category has a parent, add the hierarchy to the trail. */
1067
- if ( 0 < $term->parent )
1068
- $this->do_term_parents( $term->parent, 'category' );
1069
-
1070
- /* Add the category archive link to the trail. */
1071
- $this->items[] = '<a href="' . get_term_link( $term, 'category' ) . '" title="' . esc_attr( $term->name ) . '">' . $term->name . '</a>';
1072
- }
1073
  }
1074
  }
1075
  }
1076
  }
1077
  }
1078
-
1079
- /**
1080
- * Extends the Breadcrumb_Trail class for bbPress. Only use this if bbPress is in use. This should
1081
- * serve as an example for other plugin developers to build custom breadcrumb items.
1082
- *
1083
- * @since 0.6.0
1084
- * @access public
1085
- */
1086
- class bbPress_Breadcrumb_Trail extends Breadcrumb_Trail {
1087
-
1088
- /**
1089
- * Runs through the various bbPress conditional tags to check the current page being viewed. Once
1090
- * a condition is met, add items to the $items array.
1091
- *
1092
- * @since 0.6.0
1093
- * @access public
1094
- * @return void
1095
- */
1096
- public function do_trail_items() {
1097
-
1098
- /* Add the network and site home links. */
1099
- $this->do_network_home_link();
1100
- $this->do_site_home_link();
1101
-
1102
- /* Get the forum post type object. */
1103
- $post_type_object = get_post_type_object( bbp_get_forum_post_type() );
1104
-
1105
- /* If not viewing the forum root/archive page and a forum archive exists, add it. */
1106
- if ( !empty( $post_type_object->has_archive ) && !bbp_is_forum_archive() )
1107
- $this->items[] = '<a href="' . get_post_type_archive_link( bbp_get_forum_post_type() ) . '">' . bbp_get_forum_archive_title() . '</a>';
1108
-
1109
- /* If viewing the forum root/archive. */
1110
- if ( bbp_is_forum_archive() ) {
1111
-
1112
- if ( true === $this->args['show_title'] )
1113
- $this->items[] = bbp_get_forum_archive_title();
1114
- }
1115
-
1116
- /* If viewing the topics archive. */
1117
- elseif ( bbp_is_topic_archive() ) {
1118
-
1119
- if ( true === $this->args['show_title'] )
1120
- $this->items[] = bbp_get_topic_archive_title();
1121
- }
1122
-
1123
- /* If viewing a topic tag archive. */
1124
- elseif ( bbp_is_topic_tag() ) {
1125
-
1126
- if ( true === $this->args['show_title'] )
1127
- $this->items[] = bbp_get_topic_tag_name();
1128
- }
1129
-
1130
- /* If viewing a topic tag edit page. */
1131
- elseif ( bbp_is_topic_tag_edit() ) {
1132
- $this->items[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
1133
-
1134
- if ( true === $this->args['show_title'] )
1135
- $this->items[] = __( 'Edit', 'breadcrumb-trail' );
1136
- }
1137
-
1138
- /* If viewing a "view" page. */
1139
- elseif ( bbp_is_single_view() ) {
1140
-
1141
- if ( true === $this->args['show_title'] )
1142
- $this->items[] = bbp_get_view_title();
1143
- }
1144
-
1145
- /* If viewing a single topic page. */
1146
- elseif ( bbp_is_single_topic() ) {
1147
-
1148
- /* Get the queried topic. */
1149
- $topic_id = get_queried_object_id();
1150
-
1151
- /* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
1152
- $this->do_post_parents( bbp_get_topic_forum_id( $topic_id ) );
1153
-
1154
- /* If viewing a split, merge, or edit topic page, show the link back to the topic. Else, display topic title. */
1155
- if ( bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit() )
1156
- $this->items[] = '<a href="' . bbp_get_topic_permalink( $topic_id ) . '">' . bbp_get_topic_title( $topic_id ) . '</a>';
1157
-
1158
- elseif ( true === $this->args['show_title'] )
1159
- $this->items[] = bbp_get_topic_title( $topic_id );
1160
-
1161
- /* If viewing a topic split page. */
1162
- if ( bbp_is_topic_split() && true === $this->args['show_title'] )
1163
- $this->items[] = __( 'Split', 'breadcrumb-trail' );
1164
-
1165
- /* If viewing a topic merge page. */
1166
- elseif ( bbp_is_topic_merge() && true === $this->args['show_title'] )
1167
- $this->items[] = __( 'Merge', 'breadcrumb-trail' );
1168
-
1169
- /* If viewing a topic edit page. */
1170
- elseif ( bbp_is_topic_edit() && true === $this->args['show_title'] )
1171
- $this->items[] = __( 'Edit', 'breadcrumb-trail' );
1172
- }
1173
-
1174
- /* If viewing a single reply page. */
1175
- elseif ( bbp_is_single_reply() ) {
1176
-
1177
- /* Get the queried reply object ID. */
1178
- $reply_id = get_queried_object_id();
1179
-
1180
- /* Get the parent items for the reply, which should be its topic. */
1181
- $this->do_post_parents( bbp_get_reply_topic_id( $reply_id ) );
1182
-
1183
- /* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
1184
- if ( bbp_is_reply_edit() ) {
1185
- $this->items[] = '<a href="' . bbp_get_reply_url( $reply_id ) . '">' . bbp_get_reply_title( $reply_id ) . '</a>';
1186
-
1187
- if ( true === $this->args['show_title'] )
1188
- $this->items[] = __( 'Edit', 'breadcrumb-trail' );
1189
-
1190
- } elseif ( true === $this->args['show_title'] ) {
1191
- $this->items[] = bbp_get_reply_title( $reply_id );
1192
- }
1193
-
1194
- }
1195
-
1196
- /* If viewing a single forum. */
1197
- elseif ( bbp_is_single_forum() ) {
1198
-
1199
- /* Get the queried forum ID and its parent forum ID. */
1200
- $forum_id = get_queried_object_id();
1201
- $forum_parent_id = bbp_get_forum_parent_id( $forum_id );
1202
-
1203
- /* If the forum has a parent forum, get its parent(s). */
1204
- if ( 0 !== $forum_parent_id)
1205
- $this->do_post_parents( $forum_parent_id );
1206
-
1207
- /* Add the forum title to the end of the trail. */
1208
- if ( true === $this->args['show_title'] )
1209
- $this->items[] = bbp_get_forum_title( $forum_id );
1210
- }
1211
-
1212
- /* If viewing a user page or user edit page. */
1213
- elseif ( bbp_is_single_user() || bbp_is_single_user_edit() ) {
1214
-
1215
- if ( bbp_is_single_user_edit() ) {
1216
- $this->items[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field( 'display_name' ) . '</a>';
1217
-
1218
- if ( true === $this->args['show_title'] )
1219
- $this->items[] = __( 'Edit', 'breadcrumb-trail' );
1220
- } elseif ( true === $this->args['show_title'] ) {
1221
- $this->items[] = bbp_get_displayed_user_field( 'display_name' );
1222
- }
1223
- }
1224
-
1225
- /* Return the bbPress breadcrumb trail items. */
1226
- $this->items = apply_filters( 'breadcrumb_trail_get_bbpress_items', $this->items, $this->args );
1227
- }
1228
- }
1229
-
1230
- ?>
2
  /**
3
  * Breadcrumb Trail - A breadcrumb menu script for WordPress.
4
  *
5
+ * Breadcrumb Trail is a script for showing a breadcrumb trail for any type of page. It tries to
6
+ * anticipate any type of structure and display the best possible trail that matches your site's
7
+ * permalink structure. While not perfect, it attempts to fill in the gaps left by many other
8
  * breadcrumb scripts.
9
  *
10
+ * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
11
+ * General Public License as published by the Free Software Foundation; either version 2 of the License,
12
  * or (at your option) any later version.
13
  *
14
+ * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
15
  * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
  *
17
  * @package BreadcrumbTrail
18
+ * @version 1.0.0
19
  * @author Justin Tadlock <justin@justintadlock.com>
20
+ * @copyright Copyright (c) 2008 - 2015, Justin Tadlock
21
  * @link http://themehybrid.com/plugins/breadcrumb-trail
22
  * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
23
  */
24
 
25
  /**
26
+ * Shows a breadcrumb for all types of pages. This is a wrapper function for the Breadcrumb_Trail class,
27
  * which should be used in theme templates.
28
  *
29
  * @since 0.1.0
33
  */
34
  function breadcrumb_trail( $args = array() ) {
35
 
36
+ $breadcrumb = apply_filters( 'breadcrumb_trail_object', null, $args );
37
+
38
+ if ( !is_object( $breadcrumb ) )
39
  $breadcrumb = new Breadcrumb_Trail( $args );
40
 
41
  return $breadcrumb->trail();
44
  /**
45
  * Creates a breadcrumbs menu for the site based on the current page that's being viewed by the user.
46
  *
47
+ * @since 0.6.0
48
+ * @access public
49
  */
50
  class Breadcrumb_Trail {
51
 
68
  public $args = array();
69
 
70
  /**
71
+ * Array of text labels.
72
+ *
73
+ * @since 1.0.0
74
+ * @access public
75
+ * @var array
76
+ */
77
+ public $labels = array();
78
+
79
+ /**
80
+ * Array of post types (key) and taxonomies (value) to use for single post views.
81
+ *
82
+ * @since 1.0.0
83
+ * @access public
84
+ * @var array
85
+ */
86
+ public $post_taxonomy = array();
87
+
88
+ /* ====== Magic Methods ====== */
89
+
90
+ /**
91
+ * Magic method to use in case someone tries to output the layout object as a string.
92
+ * We'll just return the trail HTML.
93
+ *
94
+ * @since 1.0.0
95
+ * @access public
96
+ * @return string
97
+ */
98
+ public function __toString() {
99
+ return $this->trail();
100
+ }
101
+
102
+ /**
103
+ * Sets up the breadcrumb trail properties. Calls the `Breadcrumb_Trail::add_items()` method
104
+ * to creat the array of breadcrumb items.
105
  *
106
  * @since 0.6.0
107
  * @access public
108
+ * @param array $args {
109
+ * @type string $container Container HTML element. nav|div
110
+ * @type string $before String to output before breadcrumb menu.
111
+ * @type string $after String to output after breadcrumb menu.
112
+ * @type bool $show_on_front Whether to show when `is_front_page()`.
113
+ * @type bool $network Whether to link to the network main site (multisite only).
114
+ * @type bool $show_title Whether to show the title (last item) in the trail.
115
+ * @type bool $show_browse Whether to show the breadcrumb menu header.
116
+ * @type array $labels Text labels. @see Breadcrumb_Trail::set_labels()
117
+ * @type array $post_taxonomy Taxonomies to use for post types. @see Breadcrumb_Trail::set_post_taxonomy()
118
+ * @type bool $echo Whether to print or return the breadcrumbs.
119
+ * }
120
  * @return void
121
  */
122
  public function __construct( $args = array() ) {
123
 
 
 
 
124
  $defaults = array(
125
+ 'container' => 'nav',
 
126
  'before' => '',
127
  'after' => '',
128
  'show_on_front' => true,
129
  'network' => false,
 
130
  'show_title' => true,
131
  'show_browse' => true,
132
+ 'labels' => array(),
133
+ 'post_taxonomy' => array(),
134
+ 'echo' => true
 
 
 
 
 
 
 
135
  );
136
 
137
+ // Parse the arguments with the deaults.
138
  $this->args = apply_filters( 'breadcrumb_trail_args', wp_parse_args( $args, $defaults ) );
139
 
140
+ // Set the labels and post taxonomy properties.
141
+ $this->set_labels();
142
+ $this->set_post_taxonomy();
143
 
144
+ // Let's find some items to add to the trail!
145
+ $this->add_items();
146
  }
147
 
148
+ /* ====== Public Methods ====== */
149
+
150
  /**
151
+ * Formats the HTML output for the breadcrumb trail.
152
  *
153
  * @since 0.6.0
154
  * @access public
156
  */
157
  public function trail() {
158
 
159
+ // Set up variables that we'll need.
160
+ $breadcrumb = '';
161
+ $item_count = count( $this->items );
162
+ $item_position = 0;
163
 
164
+ // Connect the breadcrumb trail if there are items in the trail.
165
+ if ( 0 < $item_count ) {
166
 
167
+ // Add 'browse' label if it should be shown.
168
+ if ( true === $this->args['show_browse'] )
169
+ $breadcrumb .= sprintf( '<h2 class="trail-browse">%s</h2>', $this->labels['browse'] );
170
 
171
+ // Open the unordered list.
172
+ $breadcrumb .= '<ul class="trail-items" itemscope itemtype="http://schema.org/BreadcrumbList">';
173
 
174
+ // Add the number of items and item list order schema.
175
+ $breadcrumb .= sprintf( '<meta name="numberOfItems" content="%d" />', absint( $item_count ) );
176
+ $breadcrumb .= '<meta name="itemListOrder" content="Ascending" />';
177
 
178
+ // Loop through the items and add them to the list.
179
+ foreach ( $this->items as $item ) {
 
180
 
181
+ // Iterate the item position.
182
+ ++$item_position;
 
183
 
184
+ // Check if the item is linked.
185
+ preg_match( '/(<a.*?>)(.*?)(<\/a>)/i', $item, $matches );
186
 
187
+ // Wrap the item text with appropriate itemprop.
188
+ $item = !empty( $matches ) ? sprintf( '%s<span itemprop="name">%s</span>%s', $matches[1], $matches[2], $matches[3] ) : sprintf( '<span itemprop="name">%s</span>', $item );
189
 
190
+ // Add list item classes.
191
+ $item_class = 'trail-item';
192
 
193
+ if ( 1 === $item_position && 1 < $item_count )
194
+ $item_class .= ' trail-begin';
195
 
196
+ elseif ( $item_count === $item_position )
197
+ $item_class .= ' trail-end';
198
+
199
+ // Create list item attributes.
200
+ $attributes = 'itemprop="itemListElement" itemscope itemtype="http://schema.org/ListItem" class="' . $item_class . '"';
201
+
202
+ // Build the meta position HTML.
203
+ $meta = sprintf( '<meta itemprop="position" content="%s" />', absint( $item_position ) );
204
+
205
+ // Build the list item.
206
+ $breadcrumb .= sprintf( '<li %s>%s%s</li>', $attributes, $item, $meta );
207
+ }
208
+
209
+ // Close the unordered list.
210
+ $breadcrumb .= '</ul>';
211
+
212
+ // Wrap the breadcrumb trail.
213
+ $breadcrumb = sprintf(
214
+ '<%1$s role="navigation" aria-label="%2$s" class="breadcrumb-trail breadcrumbs" itemprop="breadcrumb">%3$s%4$s%5$s</%1$s>',
215
+ tag_escape( $this->args['container'] ),
216
+ esc_attr( $this->labels['aria_label'] ),
217
+ $this->args['before'],
218
+ $breadcrumb,
219
+ $this->args['after']
220
+ );
221
  }
222
 
223
+ // Allow developers to filter the breadcrumb trail HTML.
224
  $breadcrumb = apply_filters( 'breadcrumb_trail', $breadcrumb, $this->args );
225
 
226
+ if ( false === $this->args['echo'] )
 
 
227
  return $breadcrumb;
228
+
229
+ echo $breadcrumb;
230
  }
231
 
232
+ /* ====== Protected Methods ====== */
233
+
234
  /**
235
+ * Sets the labels property. Parses the inputted labels array with the defaults.
236
  *
237
+ * @since 1.0.0
238
+ * @access protected
239
+ * @return void
240
  */
241
+ protected function set_labels() {
242
+
243
+ $defaults = array(
244
+ 'browse' => esc_html__( 'Browse:', 'breadcrumb-trail' ),
245
+ 'aria_label' => esc_attr_x( 'Breadcrumbs', 'breadcrumbs aria label', 'breadcrumb-trail' ),
246
+ 'home' => esc_html__( 'Home', 'breadcrumb-trail' ),
247
+ 'error_404' => esc_html__( '404 Not Found', 'breadcrumb-trail' ),
248
+ 'archives' => esc_html__( 'Archives', 'breadcrumb-trail' ),
249
+ // Translators: %s is the search query. The HTML entities are opening and closing curly quotes.
250
+ 'search' => esc_html__( 'Search results for &#8220;%s&#8221;', 'breadcrumb-trail' ),
251
+ // Translators: %s is the page number.
252
+ 'paged' => esc_html__( 'Page %s', 'breadcrumb-trail' ),
253
+ // Translators: Minute archive title. %s is the minute time format.
254
+ 'archive_minute' => esc_html__( 'Minute %s', 'breadcrumb-trail' ),
255
+ // Translators: Weekly archive title. %s is the week date format.
256
+ 'archive_week' => esc_html__( 'Week %s', 'breadcrumb-trail' ),
257
+
258
+ // "%s" is replaced with the translated date/time format.
259
  'archive_minute_hour' => '%s',
260
  'archive_hour' => '%s',
261
  'archive_day' => '%s',
263
  'archive_year' => '%s',
264
  );
265
 
266
+ $this->labels = apply_filters( 'breadcrumb_trail_labels', wp_parse_args( $this->args['labels'], $defaults ) );
267
  }
268
 
269
  /**
270
+ * Sets the `$post_taxonomy` property. This is an array of post types (key) and taxonomies (value).
271
+ * The taxonomy's terms are shown on the singular post view if set.
272
  *
273
+ * @since 1.0.0
274
+ * @access protected
275
  * @return void
276
  */
277
+ protected function set_post_taxonomy() {
278
+
279
+ $defaults = array();
280
 
281
+ // If post permalink is set to `%postname%`, use the `category` taxonomy.
282
+ if ( '%postname%' === trim( get_option( 'permalink_structure' ), '/' ) )
283
+ $defaults['post'] = 'category';
284
+
285
+ $this->post_taxonomy = apply_filters( 'breadcrumb_trail_post_taxonomy', wp_parse_args( $this->args['post_taxonomy'], $defaults ) );
286
+ }
287
+
288
+ /**
289
+ * Runs through the various WordPress conditional tags to check the current page being viewed. Once
290
+ * a condition is met, a specific method is launched to add items to the `$items` array.
291
+ *
292
+ * @since 1.0.0
293
+ * @access protected
294
+ * @return void
295
+ */
296
+ protected function add_items() {
297
+
298
+ // If viewing the front page.
299
  if ( is_front_page() ) {
300
+ $this->add_front_page_items();
301
  }
302
 
303
+ // If not viewing the front page.
304
  else {
305
 
306
+ // Add the network and site home links.
307
+ $this->add_network_home_link();
308
+ $this->add_site_home_link();
309
 
310
+ // If viewing the home/blog page.
311
  if ( is_home() ) {
312
+ $this->add_posts_page_items();
313
  }
314
 
315
+ // If viewing a single post.
316
  elseif ( is_singular() ) {
317
+ $this->add_singular_items();
318
  }
319
 
320
+ // If viewing an archive page.
321
  elseif ( is_archive() ) {
322
 
323
  if ( is_post_type_archive() )
324
+ $this->add_post_type_archive_items();
325
 
326
  elseif ( is_category() || is_tag() || is_tax() )
327
+ $this->add_term_archive_items();
328
 
329
  elseif ( is_author() )
330
+ $this->add_user_archive_items();
331
 
332
  elseif ( get_query_var( 'minute' ) && get_query_var( 'hour' ) )
333
+ $this->add_minute_hour_archive_items();
334
 
335
  elseif ( get_query_var( 'minute' ) )
336
+ $this->add_minute_archive_items();
337
 
338
  elseif ( get_query_var( 'hour' ) )
339
+ $this->add_hour_archive_items();
340
 
341
  elseif ( is_day() )
342
+ $this->add_day_archive_items();
343
 
344
  elseif ( get_query_var( 'w' ) )
345
+ $this->add_week_archive_items();
346
 
347
  elseif ( is_month() )
348
+ $this->add_month_archive_items();
349
 
350
  elseif ( is_year() )
351
+ $this->add_year_archive_items();
352
 
353
  else
354
+ $this->add_default_archive_items();
355
  }
356
 
357
+ // If viewing a search results page.
358
  elseif ( is_search() ) {
359
+ $this->add_search_items();
360
  }
361
 
362
+ // If viewing the 404 page.
363
  elseif ( is_404() ) {
364
+ $this->add_404_items();
365
  }
366
  }
367
 
368
+ // Add paged items if they exist.
369
+ $this->add_paged_items();
370
 
371
+ // Allow developers to overwrite the items for the breadcrumb trail.
372
+ $this->items = array_unique( apply_filters( 'breadcrumb_trail_items', $this->items, $this->args ) );
373
  }
374
 
375
  /**
376
  * Gets front items based on $wp_rewrite->front.
377
  *
378
+ * @since 1.0.0
379
+ * @access protected
380
  * @return void
381
  */
382
+ protected function add_rewrite_front_items() {
383
  global $wp_rewrite;
384
 
385
  if ( $wp_rewrite->front )
386
+ $this->add_path_parents( $wp_rewrite->front );
387
  }
388
 
389
  /**
390
  * Adds the page/paged number to the items array.
391
  *
392
+ * @since 1.0.0
393
+ * @access protected
394
  * @return void
395
  */
396
+ protected function add_paged_items() {
397
 
398
+ // If viewing a paged singular post.
399
  if ( is_singular() && 1 < get_query_var( 'page' ) && true === $this->args['show_title'] )
400
+ $this->items[] = sprintf( $this->labels['paged'], number_format_i18n( absint( get_query_var( 'page' ) ) ) );
401
 
402
+ // If viewing a paged archive-type page.
403
  elseif ( is_paged() && true === $this->args['show_title'] )
404
+ $this->items[] = sprintf( $this->labels['paged'], number_format_i18n( absint( get_query_var( 'paged' ) ) ) );
 
405
  }
406
 
407
  /**
408
  * Adds the network (all sites) home page link to the items array.
409
  *
410
+ * @since 1.0.0
411
+ * @access protected
412
  * @return void
413
  */
414
+ protected function add_network_home_link() {
415
+
416
  if ( is_multisite() && !is_main_site() && true === $this->args['network'] )
417
+ $this->items[] = sprintf( '<a href="%s" rel="home">%s</a>', esc_url( network_home_url() ), $this->labels['home'] );
418
  }
419
 
420
  /**
421
  * Adds the current site's home page link to the items array.
422
  *
423
+ * @since 1.0.0
424
+ * @access protected
425
  * @return void
426
  */
427
+ protected function add_site_home_link() {
428
+
429
+ $network = is_multisite() && !is_main_site() && true === $this->args['network'];
430
+ $label = $network ? get_bloginfo( 'name' ) : $this->labels['home'];
431
+ $rel = $network ? '' : ' rel="home"';
432
+
433
+ $this->items[] = sprintf( '<a href="%s"%s>%s</a>', esc_url( home_url() ), $rel, $label );
434
  }
435
 
436
  /**
437
  * Adds items for the front page to the items array.
438
  *
439
+ * @since 1.0.0
440
+ * @access protected
441
  * @return void
442
  */
443
+ protected function add_front_page_items() {
444
 
445
+ // Only show front items if the 'show_on_front' argument is set to 'true'.
446
  if ( true === $this->args['show_on_front'] || is_paged() || ( is_singular() && 1 < get_query_var( 'page' ) ) ) {
447
 
448
+ // Add network home link.
449
+ $this->add_network_home_link();
 
 
 
450
 
451
+ // If on a paged view, add the site home link.
452
+ if ( is_paged() )
453
+ $this->add_site_home_link();
454
 
455
+ // If on the main front page, add the network home title.
456
+ elseif ( true === $this->args['show_title'] )
457
+ $this->items[] = is_multisite() && true === $this->args['network'] ? get_bloginfo( 'name' ) : $this->labels['home'];
458
  }
459
  }
460
 
461
  /**
462
  * Adds items for the posts page (i.e., is_home()) to the items array.
463
  *
464
+ * @since 1.0.0
465
+ * @access protected
466
  * @return void
467
  */
468
+ protected function add_posts_page_items() {
469
 
470
+ // Get the post ID and post.
471
  $post_id = get_queried_object_id();
472
+ $post = get_post( $post_id );
473
 
474
+ // If the post has parents, add them to the trail.
475
  if ( 0 < $post->post_parent )
476
+ $this->add_post_parents( $post->post_parent );
477
 
478
+ // Get the page title.
479
  $title = get_the_title( $post_id );
480
 
481
+ // Add the posts page item.
482
  if ( is_paged() )
483
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), $title );
484
 
485
  elseif ( $title && true === $this->args['show_title'] )
486
  $this->items[] = $title;
489
  /**
490
  * Adds singular post items to the items array.
491
  *
492
+ * @since 1.0.0
493
+ * @access protected
494
  * @return void
495
  */
496
+ protected function add_singular_items() {
497
 
498
+ // Get the queried post.
499
  $post = get_queried_object();
500
  $post_id = get_queried_object_id();
501
 
502
+ // If the post has a parent, follow the parent trail.
503
  if ( 0 < $post->post_parent )
504
+ $this->add_post_parents( $post->post_parent );
505
 
506
+ // If the post doesn't have a parent, get its hierarchy based off the post type.
507
  else
508
+ $this->add_post_hierarchy( $post_id );
509
 
510
+ // Display terms for specific post type taxonomy if requested.
511
+ if ( !empty( $this->post_taxonomy[ $post->post_type ] ) )
512
+ $this->add_post_terms( $post_id, $this->post_taxonomy[ $post->post_type ] );
513
 
514
+ // End with the post title.
515
  if ( $post_title = single_post_title( '', false ) ) {
516
 
517
+ if ( 1 < get_query_var( 'page' ) || is_paged() )
518
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), $post_title );
519
 
520
  elseif ( true === $this->args['show_title'] )
521
  $this->items[] = $post_title;
522
  }
523
  }
524
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
525
  /**
526
  * Adds the items to the trail items array for taxonomy term archives.
527
  *
528
+ * @since 1.0.0
529
+ * @access protected
530
  * @global object $wp_rewrite
531
  * @return void
532
  */
533
+ protected function add_term_archive_items() {
534
  global $wp_rewrite;
535
 
536
+ // Get some taxonomy and term variables.
537
+ $term = get_queried_object();
538
+ $taxonomy = get_taxonomy( $term->taxonomy );
539
+ $done_post_type = false;
540
 
541
+ // If there are rewrite rules for the taxonomy.
542
  if ( false !== $taxonomy->rewrite ) {
543
 
544
+ // If 'with_front' is true, dd $wp_rewrite->front to the trail.
545
  if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front )
546
+ $this->add_rewrite_front_items();
547
 
548
+ // Get parent pages by path if they exist.
549
+ $this->add_path_parents( $taxonomy->rewrite['slug'] );
550
 
551
+ // Add post type archive if its 'has_archive' matches the taxonomy rewrite 'slug'.
552
  if ( $taxonomy->rewrite['slug'] ) {
553
 
554
  $slug = trim( $taxonomy->rewrite['slug'], '/' );
555
 
556
+ // Deals with the situation if the slug has a '/' between multiple
557
+ // strings. For example, "movies/genres" where "movies" is the post
558
+ // type archive.
 
559
  $matches = explode( '/', $slug );
560
 
561
+ // If matches are found for the path.
562
  if ( isset( $matches ) ) {
563
 
564
+ // Reverse the array of matches to search for posts in the proper order.
565
  $matches = array_reverse( $matches );
566
 
567
+ // Loop through each of the path matches.
568
  foreach ( $matches as $match ) {
569
 
570
+ // If a match is found.
571
  $slug = $match;
572
 
573
+ // Get public post types that match the rewrite slug.
574
  $post_types = $this->get_post_types_by_slug( $match );
575
 
576
  if ( !empty( $post_types ) ) {
577
 
578
  $post_type_object = $post_types[0];
579
 
580
+ // Add support for a non-standard label of 'archive_title' (special use case).
581
  $label = !empty( $post_type_object->labels->archive_title ) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
582
 
583
+ // Core filter hook.
584
+ $label = apply_filters( 'post_type_archive_title', $label, $post_type_object->name );
585
+
586
+ // Add the post type archive link to the trail.
587
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_post_type_archive_link( $post_type_object->name ) ), $label );
588
 
589
+ $done_post_type = true;
590
+
591
+ // Break out of the loop.
592
  break;
593
  }
594
  }
596
  }
597
  }
598
 
599
+ // If there's a single post type for the taxonomy, use it.
600
+ if ( false === $done_post_type && 1 === count( $taxonomy->object_type ) && post_type_exists( $taxonomy->object_type[0] ) ) {
601
+
602
+ // If the post type is 'post'.
603
+ if ( 'post' === $taxonomy->object_type[0] ) {
604
+ $post_id = get_option( 'page_for_posts' );
605
+
606
+ if ( 'posts' !== get_option( 'show_on_front' ) && 0 < $post_id )
607
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), get_the_title( $post_id ) );
608
+
609
+ // If the post type is not 'post'.
610
+ } else {
611
+ $post_type_object = get_post_type_object( $taxonomy->object_type[0] );
612
+
613
+ $label = !empty( $post_type_object->labels->archive_title ) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
614
+
615
+ // Core filter hook.
616
+ $label = apply_filters( 'post_type_archive_title', $label, $post_type_object->name );
617
+
618
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_post_type_archive_link( $post_type_object->name ) ), $label );
619
+ }
620
+ }
621
+
622
+ // If the taxonomy is hierarchical, list its parent terms.
623
  if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent )
624
+ $this->add_term_parents( $term->parent, $term->taxonomy );
625
 
626
+ // Add the term name to the trail end.
627
  if ( is_paged() )
628
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_term_link( $term, $term->taxonomy ) ), single_term_title( '', false ) );
629
 
630
  elseif ( true === $this->args['show_title'] )
631
  $this->items[] = single_term_title( '', false );
634
  /**
635
  * Adds the items to the trail items array for post type archives.
636
  *
637
+ * @since 1.0.0
638
+ * @access protected
639
  * @return void
640
  */
641
+ protected function add_post_type_archive_items() {
642
 
643
+ // Get the post type object.
644
  $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
645
 
646
  if ( false !== $post_type_object->rewrite ) {
647
 
648
+ // If 'with_front' is true, add $wp_rewrite->front to the trail.
649
  if ( $post_type_object->rewrite['with_front'] )
650
+ $this->add_rewrite_front_items();
651
 
652
+ // If there's a rewrite slug, check for parents.
653
  if ( !empty( $post_type_object->rewrite['slug'] ) )
654
+ $this->add_path_parents( $post_type_object->rewrite['slug'] );
655
  }
656
 
657
+ // Add the post type [plural] name to the trail end.
658
  if ( is_paged() )
659
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_post_type_archive_link( $post_type_object->name ) ), post_type_archive_title( '', false ) );
660
 
661
  elseif ( true === $this->args['show_title'] )
662
  $this->items[] = post_type_archive_title( '', false );
665
  /**
666
  * Adds the items to the trail items array for user (author) archives.
667
  *
668
+ * @since 1.0.0
669
+ * @access protected
670
  * @global object $wp_rewrite
671
  * @return void
672
  */
673
+ protected function add_user_archive_items() {
674
  global $wp_rewrite;
675
 
676
+ // Add $wp_rewrite->front to the trail.
677
+ $this->add_rewrite_front_items();
678
 
679
+ // Get the user ID.
680
  $user_id = get_query_var( 'author' );
681
 
682
+ // If $author_base exists, check for parent pages.
683
  if ( !empty( $wp_rewrite->author_base ) )
684
+ $this->add_path_parents( $wp_rewrite->author_base );
685
 
686
+ // Add the author's display name to the trail end.
687
  if ( is_paged() )
688
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_author_posts_url( $user_id ) ), get_the_author_meta( 'display_name', $user_id ) );
689
 
690
  elseif ( true === $this->args['show_title'] )
691
  $this->items[] = get_the_author_meta( 'display_name', $user_id );
694
  /**
695
  * Adds the items to the trail items array for minute + hour archives.
696
  *
697
+ * @since 1.0.0
698
+ * @access protected
699
  * @return void
700
  */
701
+ protected function add_minute_hour_archive_items() {
702
 
703
+ // Add $wp_rewrite->front to the trail.
704
+ $this->add_rewrite_front_items();
705
 
706
+ // Add the minute + hour item.
707
  if ( true === $this->args['show_title'] )
708
+ $this->items[] = sprintf( $this->labels['archive_minute_hour'], get_the_time( esc_html_x( 'g:i a', 'minute and hour archives time format', 'breadcrumb-trail' ) ) );
709
  }
710
 
711
  /**
712
  * Adds the items to the trail items array for minute archives.
713
  *
714
+ * @since 1.0.0
715
+ * @access protected
716
  * @return void
717
  */
718
+ protected function add_minute_archive_items() {
719
 
720
+ // Add $wp_rewrite->front to the trail.
721
+ $this->add_rewrite_front_items();
722
 
723
+ // Add the minute item.
724
  if ( true === $this->args['show_title'] )
725
+ $this->items[] = sprintf( $this->labels['archive_minute'], get_the_time( esc_html_x( 'i', 'minute archives time format', 'breadcrumb-trail' ) ) );
726
  }
727
 
728
  /**
729
  * Adds the items to the trail items array for hour archives.
730
  *
731
+ * @since 1.0.0
732
+ * @access protected
733
  * @return void
734
  */
735
+ protected function add_hour_archive_items() {
736
 
737
+ // Add $wp_rewrite->front to the trail.
738
+ $this->add_rewrite_front_items();
739
 
740
+ // Add the hour item.
741
  if ( true === $this->args['show_title'] )
742
+ $this->items[] = sprintf( $this->labels['archive_hour'], get_the_time( esc_html_x( 'g a', 'hour archives time format', 'breadcrumb-trail' ) ) );
743
  }
744
 
745
  /**
746
  * Adds the items to the trail items array for day archives.
747
  *
748
+ * @since 1.0.0
749
+ * @access protected
750
  * @return void
751
  */
752
+ protected function add_day_archive_items() {
753
 
754
+ // Add $wp_rewrite->front to the trail.
755
+ $this->add_rewrite_front_items();
756
 
757
+ // Get year, month, and day.
758
+ $year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'breadcrumb-trail' ) ) );
759
+ $month = sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'breadcrumb-trail' ) ) );
760
+ $day = sprintf( $this->labels['archive_day'], get_the_time( esc_html_x( 'j', 'daily archives date format', 'breadcrumb-trail' ) ) );
761
 
762
+ // Add the year and month items.
763
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
764
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) ), $month );
765
 
766
+ // Add the day item.
767
  if ( is_paged() )
768
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_day_link( get_the_time( 'Y' ) ), get_the_time( 'm' ), get_the_time( 'd' ) ), $day );
769
 
770
  elseif ( true === $this->args['show_title'] )
771
  $this->items[] = $day;
774
  /**
775
  * Adds the items to the trail items array for week archives.
776
  *
777
+ * @since 1.0.0
778
+ * @access protected
779
  * @return void
780
  */
781
+ protected function add_week_archive_items() {
782
 
783
+ // Add $wp_rewrite->front to the trail.
784
+ $this->add_rewrite_front_items();
785
 
786
+ // Get the year and week.
787
+ $year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'breadcrumb-trail' ) ) );
788
+ $week = sprintf( $this->labels['archive_week'], get_the_time( esc_html_x( 'W', 'weekly archives date format', 'breadcrumb-trail' ) ) );
789
 
790
+ // Add the year item.
791
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
792
 
793
+ // Add the week item.
794
  if ( is_paged() )
795
+ $this->items[] = esc_url( get_archives_link( add_query_arg( array( 'm' => get_the_time( 'Y' ), 'w' => get_the_time( 'W' ) ), home_url() ), $week, false ) );
796
 
797
  elseif ( true === $this->args['show_title'] )
798
  $this->items[] = $week;
801
  /**
802
  * Adds the items to the trail items array for month archives.
803
  *
804
+ * @since 1.0.0
805
+ * @access protected
806
  * @return void
807
  */
808
+ protected function add_month_archive_items() {
809
 
810
+ // Add $wp_rewrite->front to the trail.
811
+ $this->add_rewrite_front_items();
812
 
813
+ // Get the year and month.
814
+ $year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'breadcrumb-trail' ) ) );
815
+ $month = sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'breadcrumb-trail' ) ) );
816
 
817
+ // Add the year item.
818
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
819
 
820
+ // Add the month item.
821
  if ( is_paged() )
822
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) ), $month );
823
 
824
  elseif ( true === $this->args['show_title'] )
825
  $this->items[] = $month;
828
  /**
829
  * Adds the items to the trail items array for year archives.
830
  *
831
+ * @since 1.0.0
832
+ * @access protected
833
  * @return void
834
  */
835
+ protected function add_year_archive_items() {
836
 
837
+ // Add $wp_rewrite->front to the trail.
838
+ $this->add_rewrite_front_items();
839
 
840
+ // Get the year.
841
+ $year = sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'breadcrumb-trail' ) ) );
842
 
843
+ // Add the year item.
844
  if ( is_paged() )
845
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y' ) ) ), $year );
846
 
847
  elseif ( true === $this->args['show_title'] )
848
  $this->items[] = $year;
852
  * Adds the items to the trail items array for archives that don't have a more specific method
853
  * defined in this class.
854
  *
855
+ * @since 1.0.0
856
+ * @access protected
857
  * @return void
858
  */
859
+ protected function add_default_archive_items() {
860
 
861
+ // If this is a date-/time-based archive, add $wp_rewrite->front to the trail.
862
  if ( is_date() || is_time() )
863
+ $this->add_rewrite_front_items();
864
 
865
  if ( true === $this->args['show_title'] )
866
+ $this->items[] = $this->labels['archives'];
867
  }
868
 
869
  /**
870
  * Adds the items to the trail items array for search results.
871
  *
872
+ * @since 1.0.0
873
+ * @access protected
874
  * @return void
875
  */
876
+ protected function add_search_items() {
877
 
878
  if ( is_paged() )
879
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_search_link() ), sprintf( $this->labels['search'], get_search_query() ) );
880
 
881
  elseif ( true === $this->args['show_title'] )
882
+ $this->items[] = sprintf( $this->labels['search'], get_search_query() );
883
  }
884
 
885
  /**
886
  * Adds the items to the trail items array for 404 pages.
887
  *
888
+ * @since 1.0.0
889
+ * @access protected
890
  * @return void
891
  */
892
+ protected function add_404_items() {
893
 
894
  if ( true === $this->args['show_title'] )
895
+ $this->items[] = $this->labels['error_404'];
896
  }
897
 
898
  /**
899
+ * Adds a specific post's parents to the items array.
900
+ *
901
+ * @since 1.0.0
902
+ * @access protected
903
+ * @param int $post_id
904
+ * @return void
905
+ */
906
+ protected function add_post_parents( $post_id ) {
907
+ $parents = array();
908
+
909
+ while ( $post_id ) {
910
+
911
+ // Get the post by ID.
912
+ $post = get_post( $post_id );
913
+
914
+ // If we hit a page that's set as the front page, bail.
915
+ if ( 'page' == $post->post_type && 'page' == get_option( 'show_on_front' ) && $post_id == get_option( 'page_on_front' ) )
916
+ break;
917
+
918
+ // Add the formatted post link to the array of parents.
919
+ $parents[] = sprintf( '<a href="%s">%s</a>', esc_url( get_permalink( $post_id ) ), get_the_title( $post_id ) );
920
+
921
+ // If there's no longer a post parent, break out of the loop.
922
+ if ( 0 >= $post->post_parent )
923
+ break;
924
+
925
+ // Change the post ID to the parent post to continue looping.
926
+ $post_id = $post->post_parent;
927
+ }
928
+
929
+ // Get the post hierarchy based off the final parent post.
930
+ $this->add_post_hierarchy( $post_id );
931
+
932
+ // Display terms for specific post type taxonomy if requested.
933
+ if ( !empty( $this->post_taxonomy[ $post->post_type ] ) )
934
+ $this->add_post_terms( $post_id, $this->post_taxonomy[ $post->post_type ] );
935
+
936
+ // Merge the parent items into the items array.
937
+ $this->items = array_merge( $this->items, array_reverse( $parents ) );
938
+ }
939
+
940
+ /**
941
+ * Adds a specific post's hierarchy to the items array. The hierarchy is determined by post type's
942
+ * rewrite arguments and whether it has an archive page.
943
+ *
944
+ * @since 1.0.0
945
+ * @access protected
946
+ * @param int $post_id
947
+ * @return void
948
+ */
949
+ protected function add_post_hierarchy( $post_id ) {
950
+
951
+ // Get the post type.
952
+ $post_type = get_post_type( $post_id );
953
+ $post_type_object = get_post_type_object( $post_type );
954
+
955
+ // If this is the 'post' post type, get the rewrite front items and map the rewrite tags.
956
+ if ( 'post' === $post_type ) {
957
+
958
+ // Add $wp_rewrite->front to the trail.
959
+ $this->add_rewrite_front_items();
960
+
961
+ // Map the rewrite tags.
962
+ $this->map_rewrite_tags( $post_id, get_option( 'permalink_structure' ) );
963
+ }
964
+
965
+ // If the post type has rewrite rules.
966
+ elseif ( false !== $post_type_object->rewrite ) {
967
+
968
+ // If 'with_front' is true, add $wp_rewrite->front to the trail.
969
+ if ( $post_type_object->rewrite['with_front'] )
970
+ $this->add_rewrite_front_items();
971
+
972
+ // If there's a path, check for parents.
973
+ if ( !empty( $post_type_object->rewrite['slug'] ) )
974
+ $this->add_path_parents( $post_type_object->rewrite['slug'] );
975
+ }
976
+
977
+ // If there's an archive page, add it to the trail.
978
+ if ( $post_type_object->has_archive ) {
979
+
980
+ // Add support for a non-standard label of 'archive_title' (special use case).
981
+ $label = !empty( $post_type_object->labels->archive_title ) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
982
+
983
+ // Core filter hook.
984
+ $label = apply_filters( 'post_type_archive_title', $label, $post_type_object->name );
985
+
986
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_post_type_archive_link( $post_type ) ), $label );
987
+ }
988
+ }
989
+
990
+ /**
991
+ * Gets post types by slug. This is needed because the get_post_types() function doesn't exactly
992
+ * match the 'has_archive' argument when it's set as a string instead of a boolean.
993
  *
994
  * @since 0.6.0
995
+ * @access protected
996
+ * @param int $slug The post type archive slug to search for.
997
+ * @return void
998
+ */
999
+ protected function get_post_types_by_slug( $slug ) {
1000
+
1001
+ $return = array();
1002
+
1003
+ $post_types = get_post_types( array(), 'objects' );
1004
+
1005
+ foreach ( $post_types as $type ) {
1006
+
1007
+ if ( $slug === $type->has_archive || ( true === $type->has_archive && $slug === $type->rewrite['slug'] ) )
1008
+ $return[] = $type;
1009
+ }
1010
+
1011
+ return $return;
1012
+ }
1013
+
1014
+ /**
1015
+ * Adds a post's terms from a specific taxonomy to the items array.
1016
+ *
1017
+ * @since 1.0.0
1018
+ * @access protected
1019
+ * @param int $post_id The ID of the post to get the terms for.
1020
+ * @param string $taxonomy The taxonomy to get the terms from.
1021
+ * @return void
1022
+ */
1023
+ protected function add_post_terms( $post_id, $taxonomy ) {
1024
+
1025
+ // Get the post type.
1026
+ $post_type = get_post_type( $post_id );
1027
+
1028
+ // Get the post categories.
1029
+ $terms = get_the_terms( $post_id, $taxonomy );
1030
+
1031
+ // Check that categories were returned.
1032
+ if ( $terms && ! is_wp_error( $terms ) ) {
1033
+
1034
+ // Sort the terms by ID and get the first category.
1035
+ usort( $terms, '_usort_terms_by_ID' );
1036
+ $term = get_term( $terms[0], $taxonomy );
1037
+
1038
+ // If the category has a parent, add the hierarchy to the trail.
1039
+ if ( 0 < $term->parent )
1040
+ $this->add_term_parents( $term->parent, $taxonomy );
1041
+
1042
+ // Add the category archive link to the trail.
1043
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_term_link( $term, $taxonomy ) ), $term->name );
1044
+ }
1045
+ }
1046
+
1047
+ /**
1048
+ * Get parent posts by path. Currently, this method only supports getting parents of the 'page'
1049
+ * post type. The goal of this function is to create a clear path back to home given what would
1050
+ * normally be a "ghost" directory. If any page matches the given path, it'll be added.
1051
+ *
1052
+ * @since 1.0.0
1053
+ * @access protected
1054
  * @param string $path The path (slug) to search for posts by.
1055
  * @return void
1056
  */
1057
+ function add_path_parents( $path ) {
1058
 
1059
+ // Trim '/' off $path in case we just got a simple '/' instead of a real path.
1060
  $path = trim( $path, '/' );
1061
 
1062
+ // If there's no path, return.
1063
  if ( empty( $path ) )
1064
  return;
1065
 
1066
+ // Get parent post by the path.
1067
  $post = get_page_by_path( $path );
1068
 
1069
  if ( !empty( $post ) ) {
1070
+ $this->add_post_parents( $post->ID );
1071
  }
1072
 
1073
  elseif ( is_null( $post ) ) {
1074
 
1075
+ // Separate post names into separate paths by '/'.
1076
  $path = trim( $path, '/' );
1077
  preg_match_all( "/\/.*?\z/", $path, $matches );
1078
 
1079
+ // If matches are found for the path.
1080
  if ( isset( $matches ) ) {
1081
 
1082
+ // Reverse the array of matches to search for posts in the proper order.
1083
  $matches = array_reverse( $matches );
1084
 
1085
+ // Loop through each of the path matches.
1086
  foreach ( $matches as $match ) {
1087
 
1088
+ // If a match is found.
1089
  if ( isset( $match[0] ) ) {
1090
 
1091
+ // Get the parent post by the given path.
1092
  $path = str_replace( $match[0], '', $path );
1093
  $post = get_page_by_path( trim( $path, '/' ) );
1094
 
1095
+ // If a parent post is found, set the $post_id and break out of the loop.
1096
  if ( !empty( $post ) && 0 < $post->ID ) {
1097
+ $this->add_post_parents( $post->ID );
1098
  break;
1099
  }
1100
  }
1104
  }
1105
 
1106
  /**
1107
+ * Searches for term parents of hierarchical taxonomies. This function is similar to the WordPress
1108
  * function get_category_parents() but handles any type of taxonomy.
1109
  *
1110
+ * @since 1.0.0
1111
  * @param int $term_id ID of the term to get the parents of.
1112
  * @param string $taxonomy Name of the taxonomy for the given term.
1113
  * @return void
1114
  */
1115
+ function add_term_parents( $term_id, $taxonomy ) {
1116
 
1117
+ // Set up some default arrays.
1118
  $parents = array();
1119
 
1120
+ // While there is a parent ID, add the parent term link to the $parents array.
1121
  while ( $term_id ) {
1122
 
1123
+ // Get the parent term.
1124
  $term = get_term( $term_id, $taxonomy );
1125
 
1126
+ // Add the formatted term link to the array of parent terms.
1127
+ $parents[] = sprintf( '<a href="%s">%s</a>', esc_url( get_term_link( $term, $taxonomy ) ), $term->name );
1128
 
1129
+ // Set the parent term's parent as the parent ID.
1130
  $term_id = $term->parent;
1131
  }
1132
 
1133
+ // If we have parent terms, reverse the array to put them in the proper order for the trail.
1134
  if ( !empty( $parents ) )
1135
  $this->items = array_merge( $this->items, $parents );
1136
  }
1137
 
1138
  /**
1139
  * Turns %tag% from permalink structures into usable links for the breadcrumb trail. This feels kind of
1140
+ * hackish for now because we're checking for specific %tag% examples and only doing it for the 'post'
1141
  * post type. In the future, maybe it'll handle a wider variety of possibilities, especially for custom post
1142
  * types.
1143
  *
1144
  * @since 0.6.0
1145
+ * @access protected
1146
  * @param int $post_id ID of the post whose parents we want.
1147
  * @param string $path Path of a potential parent page.
1148
  * @param array $args Mixed arguments for the menu.
1149
  * @return array
1150
  */
1151
+ protected function map_rewrite_tags( $post_id, $path ) {
1152
 
 
1153
  $post = get_post( $post_id );
1154
 
1155
+ // If the post doesn't have the `post` post type, bail.
1156
+ if ( 'post' !== $post->post_type )
1157
+ return;
1158
 
1159
+ // Trim '/' from both sides of the $path.
1160
  $path = trim( $path, '/' );
1161
 
1162
+ // Split the $path into an array of strings.
1163
  $matches = explode( '/', $path );
1164
 
1165
+ // If matches are found for the path.
1166
  if ( is_array( $matches ) ) {
1167
 
1168
+ // Loop through each of the matches, adding each to the $trail array.
1169
  foreach ( $matches as $match ) {
1170
 
1171
+ // Trim any '/' from the $match.
1172
  $tag = trim( $match, '/' );
1173
 
1174
+ // If using the %year% tag, add a link to the yearly archive.
1175
  if ( '%year%' == $tag )
1176
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_year_link( get_the_time( 'Y', $post_id ) ) ), sprintf( $this->labels['archive_year'], get_the_time( esc_html_x( 'Y', 'yearly archives date format', 'breadcrumb-trail' ) ) ) );
1177
 
1178
+ // If using the %monthnum% tag, add a link to the monthly archive.
1179
  elseif ( '%monthnum%' == $tag )
1180
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_month_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ) ) ), sprintf( $this->labels['archive_month'], get_the_time( esc_html_x( 'F', 'monthly archives date format', 'breadcrumb-trail' ) ) ) );
1181
 
1182
+ // If using the %day% tag, add a link to the daily archive.
1183
  elseif ( '%day%' == $tag )
1184
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_day_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ), get_the_time( 'd', $post_id ) ) ), sprintf( $this->labels['archive_day'], get_the_time( esc_html_x( 'j', 'daily archives date format', 'breadcrumb-trail' ) ) ) );
1185
 
1186
+ // If using the %author% tag, add a link to the post author archive.
1187
  elseif ( '%author%' == $tag )
1188
+ $this->items[] = sprintf( '<a href="%s">%s</a>', esc_url( get_author_posts_url( $post->post_author ) ), get_the_author_meta( 'display_name', $post->post_author ) );
1189
 
1190
+ // If using the %category% tag, add a link to the first category archive to match permalinks.
1191
  elseif ( '%category%' == $tag ) {
1192
 
1193
+ // Force override terms in this post type.
1194
+ $this->post_taxonomy[ $post->post_type ] = false;
 
 
 
1195
 
1196
+ // Add the post categories.
1197
+ $this->add_post_terms( $post_id, 'category' );
 
 
 
 
 
 
 
 
 
 
 
 
1198
  }
1199
  }
1200
  }
1201
  }
1202
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
languages/breadcrumb-trail-fi.mo CHANGED
Binary file
languages/breadcrumb-trail-fi.po CHANGED
@@ -1,137 +1,138 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Breadcrumb Trail WordPress Plugin\n"
4
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/breadcrumb-trail\n"
5
- "POT-Creation-Date: 2014-07-11 15:37:55+00:00\n"
6
- "PO-Revision-Date: 2014-07-11 10:40-0600\n"
7
- "Last-Translator: Sami Keijonen <sami.keijonen@foxnet.fi>\n"
8
- "Language-Team: Foxnet Themes <sami.keijonen@foxnet.fi>\n"
9
- "Language: fi\n"
10
- "MIME-Version: 1.0\n"
11
- "Content-Type: text/plain; charset=UTF-8\n"
12
- "Content-Transfer-Encoding: 8bit\n"
13
- "X-Generator: Poedit 1.5.7\n"
14
- "X-Poedit-KeywordsList: _e;__;esc_attr_e;esc_attr__;esc_html_e;esc_html__;_n;"
15
- "_x;_x:1,2c;_n:1,2\n"
16
- "X-Poedit-Basepath: ../\n"
17
- "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
- "X-Poedit-SearchPath-0: .\n"
19
-
20
- #: inc/breadcrumbs.php:178
21
- msgid "Browse:"
22
- msgstr "Olet täällä:"
23
-
24
- #: inc/breadcrumbs.php:179
25
- msgid "Home"
26
- msgstr "Etusivu"
27
-
28
- #: inc/breadcrumbs.php:180
29
- msgid "404 Not Found"
30
- msgstr "404 Sivua ei löytynyt"
31
-
32
- #: inc/breadcrumbs.php:181
33
- msgid "Archives"
34
- msgstr "Arkistot"
35
-
36
- #. Translators: %s is the search query. The HTML entities are opening and
37
- #. closing curly quotes.
38
- #: inc/breadcrumbs.php:183
39
- msgid "Search results for &#8220;%s&#8221;"
40
- msgstr "Hakutulokset haulle: \"%s\""
41
-
42
- #. Translators: %s is the page number.
43
- #: inc/breadcrumbs.php:185
44
- msgid "Page %s"
45
- msgstr "Sivu %d"
46
-
47
- #. Translators: Minute archive title. %s is the minute time format.
48
- #: inc/breadcrumbs.php:187
49
- msgid "Minute %s"
50
- msgstr "Minuutti %d"
51
-
52
- #. Translators: Weekly archive title. %s is the week date format.
53
- #: inc/breadcrumbs.php:189
54
- msgid "Week %s"
55
- msgstr "Viikko %d"
56
-
57
- #: inc/breadcrumbs.php:716
58
- msgctxt "minute and hour archives time format"
59
- msgid "g:i a"
60
- msgstr "G:i"
61
-
62
- #: inc/breadcrumbs.php:733
63
- msgctxt "minute archives time format"
64
- msgid "i"
65
- msgstr ""
66
-
67
- #: inc/breadcrumbs.php:750
68
- msgctxt "hour archives time format"
69
- msgid "g a"
70
- msgstr "g a"
71
-
72
- #: inc/breadcrumbs.php:766 inc/breadcrumbs.php:795 inc/breadcrumbs.php:822
73
- #: inc/breadcrumbs.php:849 inc/breadcrumbs.php:1036
74
- msgctxt "yearly archives date format"
75
- msgid "Y"
76
- msgstr "Y"
77
-
78
- #: inc/breadcrumbs.php:767 inc/breadcrumbs.php:823 inc/breadcrumbs.php:1040
79
- msgctxt "monthly archives date format"
80
- msgid "F"
81
- msgstr "F"
82
-
83
- #: inc/breadcrumbs.php:768 inc/breadcrumbs.php:1044
84
- msgctxt "daily archives date format"
85
- msgid "j"
86
- msgstr ""
87
-
88
- #: inc/breadcrumbs.php:796
89
- msgctxt "weekly archives date format"
90
- msgid "W"
91
- msgstr ""
92
-
93
- #: inc/breadcrumbs.php:1135 inc/breadcrumbs.php:1171 inc/breadcrumbs.php:1188
94
- #: inc/breadcrumbs.php:1219
95
- msgid "Edit"
96
- msgstr "Muokkaa"
97
-
98
- #: inc/breadcrumbs.php:1163
99
- msgid "Split"
100
- msgstr "Jaa"
101
-
102
- #: inc/breadcrumbs.php:1167
103
- msgid "Merge"
104
- msgstr "Yhdistä"
105
-
106
- #. Plugin Name of the plugin/theme
107
- msgid "Breadcrumb Trail"
108
- msgstr ""
109
-
110
- #. Plugin URI of the plugin/theme
111
- msgid "http://themehybrid.com/plugins/breadcrumb-trail"
112
- msgstr ""
113
-
114
- #. Description of the plugin/theme
115
- msgid ""
116
- "A smart breadcrumb menu plugin embedded with <a href=\"http://schema.org"
117
- "\">Schema.org</a> microdata that can handle variations in site structure "
118
- "more accurately than any other breadcrumb plugin for WordPress. Insert into "
119
- "your theme with the <code>breadcrumb_trail()</code> template tag."
120
- msgstr ""
121
-
122
- #. Author of the plugin/theme
123
- msgid "Justin Tadlock"
124
- msgstr ""
125
-
126
- #. Author URI of the plugin/theme
127
- msgid "http://justintadlock.com"
128
- msgstr ""
129
-
130
- #~ msgid "d"
131
- #~ msgstr "d"
132
-
133
- #~ msgid "F Y"
134
- #~ msgstr "F Y"
135
-
136
- #~ msgid "F j, Y"
137
- #~ msgstr "j.m.Y"
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Breadcrumb Trail WordPress Plugin\n"
4
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/breadcrumb-trail\n"
5
+ "POT-Creation-Date: 2015-07-07 16:55:40+00:00\n"
6
+ "PO-Revision-Date: 2015-07-07 11:58-0600\n"
7
+ "Last-Translator: Sami Keijonen <sami.keijonen@foxnet.fi>\n"
8
+ "Language-Team: Foxnet Themes <sami.keijonen@foxnet.fi>\n"
9
+ "Language: fi\n"
10
+ "MIME-Version: 1.0\n"
11
+ "Content-Type: text/plain; charset=UTF-8\n"
12
+ "Content-Transfer-Encoding: 8bit\n"
13
+ "X-Generator: Poedit 1.5.7\n"
14
+ "X-Poedit-KeywordsList: _e;__;esc_attr_e;esc_attr__;esc_html_e;esc_html__;_n;"
15
+ "_x;_x:1,2c;_n:1,2\n"
16
+ "X-Poedit-Basepath: ../\n"
17
+ "Plural-Forms: nplurals=2; plural=(n != 1);\n"
18
+ "X-Poedit-SearchPath-0: .\n"
19
+
20
+ #: inc/breadcrumbs.php:244
21
+ msgid "Browse:"
22
+ msgstr "Olet täällä:"
23
+
24
+ #: inc/breadcrumbs.php:245
25
+ msgctxt "breadcrumbs aria label"
26
+ msgid "Breadcrumbs"
27
+ msgstr ""
28
+
29
+ #: inc/breadcrumbs.php:246
30
+ msgid "Home"
31
+ msgstr "Etusivu"
32
+
33
+ #: inc/breadcrumbs.php:247
34
+ msgid "404 Not Found"
35
+ msgstr "404 Sivua ei löytynyt"
36
+
37
+ #: inc/breadcrumbs.php:248
38
+ msgid "Archives"
39
+ msgstr "Arkistot"
40
+
41
+ #. Translators: %s is the search query. The HTML entities are opening and
42
+ #. closing curly quotes.
43
+ #: inc/breadcrumbs.php:250
44
+ msgid "Search results for &#8220;%s&#8221;"
45
+ msgstr "Hakutulokset haulle: \"%s\""
46
+
47
+ #. Translators: %s is the page number.
48
+ #: inc/breadcrumbs.php:252
49
+ msgid "Page %s"
50
+ msgstr "Sivu %d"
51
+
52
+ #. Translators: Minute archive title. %s is the minute time format.
53
+ #: inc/breadcrumbs.php:254
54
+ msgid "Minute %s"
55
+ msgstr "Minuutti %d"
56
+
57
+ #. Translators: Weekly archive title. %s is the week date format.
58
+ #: inc/breadcrumbs.php:256
59
+ msgid "Week %s"
60
+ msgstr "Viikko %d"
61
+
62
+ #: inc/breadcrumbs.php:708
63
+ msgctxt "minute and hour archives time format"
64
+ msgid "g:i a"
65
+ msgstr "G:i"
66
+
67
+ #: inc/breadcrumbs.php:725
68
+ msgctxt "minute archives time format"
69
+ msgid "i"
70
+ msgstr ""
71
+
72
+ #: inc/breadcrumbs.php:742
73
+ msgctxt "hour archives time format"
74
+ msgid "g a"
75
+ msgstr "g a"
76
+
77
+ #: inc/breadcrumbs.php:758 inc/breadcrumbs.php:787 inc/breadcrumbs.php:814
78
+ #: inc/breadcrumbs.php:841 inc/breadcrumbs.php:1176
79
+ msgctxt "yearly archives date format"
80
+ msgid "Y"
81
+ msgstr "Y"
82
+
83
+ #: inc/breadcrumbs.php:759 inc/breadcrumbs.php:815 inc/breadcrumbs.php:1180
84
+ msgctxt "monthly archives date format"
85
+ msgid "F"
86
+ msgstr "F"
87
+
88
+ #: inc/breadcrumbs.php:760 inc/breadcrumbs.php:1184
89
+ msgctxt "daily archives date format"
90
+ msgid "j"
91
+ msgstr ""
92
+
93
+ #: inc/breadcrumbs.php:788
94
+ msgctxt "weekly archives date format"
95
+ msgid "W"
96
+ msgstr ""
97
+
98
+ #. Plugin Name of the plugin/theme
99
+ msgid "Breadcrumb Trail"
100
+ msgstr ""
101
+
102
+ #. Plugin URI of the plugin/theme
103
+ msgid "http://themehybrid.com/plugins/breadcrumb-trail"
104
+ msgstr ""
105
+
106
+ #. Description of the plugin/theme
107
+ msgid ""
108
+ "A smart breadcrumb menu plugin embedded with <a href=\"http://schema.org"
109
+ "\">Schema.org</a> microdata that can handle variations in site structure "
110
+ "more accurately than any other breadcrumb plugin for WordPress. Insert into "
111
+ "your theme with the <code>breadcrumb_trail()</code> template tag."
112
+ msgstr ""
113
+
114
+ #. Author of the plugin/theme
115
+ msgid "Justin Tadlock"
116
+ msgstr ""
117
+
118
+ #. Author URI of the plugin/theme
119
+ msgid "http://justintadlock.com"
120
+ msgstr ""
121
+
122
+ #~ msgid "Edit"
123
+ #~ msgstr "Muokkaa"
124
+
125
+ #~ msgid "Split"
126
+ #~ msgstr "Jaa"
127
+
128
+ #~ msgid "Merge"
129
+ #~ msgstr "Yhdistä"
130
+
131
+ #~ msgid "d"
132
+ #~ msgstr "d"
133
+
134
+ #~ msgid "F Y"
135
+ #~ msgstr "F Y"
136
+
137
+ #~ msgid "F j, Y"
138
+ #~ msgstr "j.m.Y"
languages/breadcrumb-trail-fr_FR.mo ADDED
Binary file
languages/breadcrumb-trail-fr_FR.po ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Copyright (C) 2014 Breadcrumb Trail
2
+ # This file is distributed under the same license as the Breadcrumb Trail package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Breadcrumb Trail 0.6.1\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/breadcrumb-trail\n"
7
+ "POT-Creation-Date: 2015-07-07 16:55:40+00:00\n"
8
+ "PO-Revision-Date: 2015-07-07 11:59-0600\n"
9
+ "Last-Translator: Sami Keijonen <sami.keijonen@foxnet.fi>\n"
10
+ "Language-Team: Hexagone <fx@hexagone.io>\n"
11
+ "Language: fr_FR\n"
12
+ "MIME-Version: 1.0\n"
13
+ "Content-Type: text/plain; charset=UTF-8\n"
14
+ "Content-Transfer-Encoding: 8bit\n"
15
+ "X-Generator: Poedit 1.5.7\n"
16
+ "Plural-Forms: nplurals=2; plural=(n > 1);\n"
17
+ "X-Poedit-SourceCharset: UTF-8\n"
18
+
19
+ #: inc/breadcrumbs.php:244
20
+ msgid "Browse:"
21
+ msgstr "Vous êtes ici&nbsp;:"
22
+
23
+ #: inc/breadcrumbs.php:245
24
+ msgctxt "breadcrumbs aria label"
25
+ msgid "Breadcrumbs"
26
+ msgstr ""
27
+
28
+ #: inc/breadcrumbs.php:246
29
+ msgid "Home"
30
+ msgstr "Accueil"
31
+
32
+ #: inc/breadcrumbs.php:247
33
+ msgid "404 Not Found"
34
+ msgstr "404 page non trouvée"
35
+
36
+ #: inc/breadcrumbs.php:248
37
+ msgid "Archives"
38
+ msgstr "Archives"
39
+
40
+ #. Translators: %s is the search query. The HTML entities are opening and
41
+ #. closing curly quotes.
42
+ #: inc/breadcrumbs.php:250
43
+ msgid "Search results for &#8220;%s&#8221;"
44
+ msgstr "Résultats de recherche pour &#8220;%s&#8221;"
45
+
46
+ #. Translators: %s is the page number.
47
+ #: inc/breadcrumbs.php:252
48
+ msgid "Page %s"
49
+ msgstr "Page %s"
50
+
51
+ #. Translators: Minute archive title. %s is the minute time format.
52
+ #: inc/breadcrumbs.php:254
53
+ msgid "Minute %s"
54
+ msgstr "%s minute"
55
+
56
+ #. Translators: Weekly archive title. %s is the week date format.
57
+ #: inc/breadcrumbs.php:256
58
+ msgid "Week %s"
59
+ msgstr "Semaine %s"
60
+
61
+ #: inc/breadcrumbs.php:708
62
+ msgctxt "minute and hour archives time format"
63
+ msgid "g:i a"
64
+ msgstr "G \\h i \\m\\i\\n"
65
+
66
+ #: inc/breadcrumbs.php:725
67
+ msgctxt "minute archives time format"
68
+ msgid "i"
69
+ msgstr "i"
70
+
71
+ #: inc/breadcrumbs.php:742
72
+ msgctxt "hour archives time format"
73
+ msgid "g a"
74
+ msgstr "g a"
75
+
76
+ #: inc/breadcrumbs.php:758 inc/breadcrumbs.php:787 inc/breadcrumbs.php:814
77
+ #: inc/breadcrumbs.php:841 inc/breadcrumbs.php:1176
78
+ msgctxt "yearly archives date format"
79
+ msgid "Y"
80
+ msgstr "Y"
81
+
82
+ #: inc/breadcrumbs.php:759 inc/breadcrumbs.php:815 inc/breadcrumbs.php:1180
83
+ msgctxt "monthly archives date format"
84
+ msgid "F"
85
+ msgstr "F"
86
+
87
+ #: inc/breadcrumbs.php:760 inc/breadcrumbs.php:1184
88
+ msgctxt "daily archives date format"
89
+ msgid "j"
90
+ msgstr "j"
91
+
92
+ #: inc/breadcrumbs.php:788
93
+ msgctxt "weekly archives date format"
94
+ msgid "W"
95
+ msgstr "S"
96
+
97
+ #. Plugin Name of the plugin/theme
98
+ msgid "Breadcrumb Trail"
99
+ msgstr "Breadcrumb Trail"
100
+
101
+ #. Plugin URI of the plugin/theme
102
+ msgid "http://themehybrid.com/plugins/breadcrumb-trail"
103
+ msgstr "http://themehybrid.com/plugins/breadcrumb-trail"
104
+
105
+ #. Description of the plugin/theme
106
+ msgid ""
107
+ "A smart breadcrumb menu plugin embedded with <a href=\"http://schema.org"
108
+ "\">Schema.org</a> microdata that can handle variations in site structure "
109
+ "more accurately than any other breadcrumb plugin for WordPress. Insert into "
110
+ "your theme with the <code>breadcrumb_trail()</code> template tag."
111
+ msgstr ""
112
+ "Une extension intelligente de fil d&#39;Ariane intégrant les microdonnées de "
113
+ "<a href=\"http://schema.org\">Schema.org</a> et qui peut gérer les "
114
+ "variations dans la structure de votre site avec plus de précision que "
115
+ "n'importe quelle autre extension de Breadcrumb de WordPress. Insérez-la dans "
116
+ "votre thème avec le modèle <code>breadcrumb_trail()</code>."
117
+
118
+ #. Author of the plugin/theme
119
+ msgid "Justin Tadlock"
120
+ msgstr "Justin Tadlock"
121
+
122
+ #. Author URI of the plugin/theme
123
+ msgid "http://justintadlock.com"
124
+ msgstr "http://justintadlock.com"
125
+
126
+ #~ msgid "Edit"
127
+ #~ msgstr "Modifier"
128
+
129
+ #~ msgid "Split"
130
+ #~ msgstr "Diviser"
131
+
132
+ #~ msgid "Merge"
133
+ #~ msgstr "Fusionner"
languages/breadcrumb-trail.pot CHANGED
@@ -1,122 +1,114 @@
1
- # Copyright (C) 2014 Breadcrumb Trail
2
- # This file is distributed under the same license as the Breadcrumb Trail package.
3
- msgid ""
4
- msgstr ""
5
- "Project-Id-Version: Breadcrumb Trail 0.6.1-alpha\n"
6
- "Report-Msgid-Bugs-To: http://wordpress.org/tag/breadcrumb-trail\n"
7
- "POT-Creation-Date: 2014-07-11 15:37:55+00:00\n"
8
- "MIME-Version: 1.0\n"
9
- "Content-Type: text/plain; charset=UTF-8\n"
10
- "Content-Transfer-Encoding: 8bit\n"
11
- "PO-Revision-Date: 2014-MO-DA HO:MI+ZONE\n"
12
- "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
- "Language-Team: LANGUAGE <LL@li.org>\n"
14
-
15
- #: inc/breadcrumbs.php:178
16
- msgid "Browse:"
17
- msgstr ""
18
-
19
- #: inc/breadcrumbs.php:179
20
- msgid "Home"
21
- msgstr ""
22
-
23
- #: inc/breadcrumbs.php:180
24
- msgid "404 Not Found"
25
- msgstr ""
26
-
27
- #: inc/breadcrumbs.php:181
28
- msgid "Archives"
29
- msgstr ""
30
-
31
- #. Translators: %s is the search query. The HTML entities are opening and
32
- #. closing curly quotes.
33
-
34
- #: inc/breadcrumbs.php:183
35
- msgid "Search results for &#8220;%s&#8221;"
36
- msgstr ""
37
-
38
- #. Translators: %s is the page number.
39
-
40
- #: inc/breadcrumbs.php:185
41
- msgid "Page %s"
42
- msgstr ""
43
-
44
- #. Translators: Minute archive title. %s is the minute time format.
45
-
46
- #: inc/breadcrumbs.php:187
47
- msgid "Minute %s"
48
- msgstr ""
49
-
50
- #. Translators: Weekly archive title. %s is the week date format.
51
-
52
- #: inc/breadcrumbs.php:189
53
- msgid "Week %s"
54
- msgstr ""
55
-
56
- #: inc/breadcrumbs.php:716
57
- msgctxt "minute and hour archives time format"
58
- msgid "g:i a"
59
- msgstr ""
60
-
61
- #: inc/breadcrumbs.php:733
62
- msgctxt "minute archives time format"
63
- msgid "i"
64
- msgstr ""
65
-
66
- #: inc/breadcrumbs.php:750
67
- msgctxt "hour archives time format"
68
- msgid "g a"
69
- msgstr ""
70
-
71
- #: inc/breadcrumbs.php:766 inc/breadcrumbs.php:795 inc/breadcrumbs.php:822
72
- #: inc/breadcrumbs.php:849 inc/breadcrumbs.php:1036
73
- msgctxt "yearly archives date format"
74
- msgid "Y"
75
- msgstr ""
76
-
77
- #: inc/breadcrumbs.php:767 inc/breadcrumbs.php:823 inc/breadcrumbs.php:1040
78
- msgctxt "monthly archives date format"
79
- msgid "F"
80
- msgstr ""
81
-
82
- #: inc/breadcrumbs.php:768 inc/breadcrumbs.php:1044
83
- msgctxt "daily archives date format"
84
- msgid "j"
85
- msgstr ""
86
-
87
- #: inc/breadcrumbs.php:796
88
- msgctxt "weekly archives date format"
89
- msgid "W"
90
- msgstr ""
91
-
92
- #: inc/breadcrumbs.php:1135 inc/breadcrumbs.php:1171 inc/breadcrumbs.php:1188
93
- #: inc/breadcrumbs.php:1219
94
- msgid "Edit"
95
- msgstr ""
96
-
97
- #: inc/breadcrumbs.php:1163
98
- msgid "Split"
99
- msgstr ""
100
-
101
- #: inc/breadcrumbs.php:1167
102
- msgid "Merge"
103
- msgstr ""
104
- #. Plugin Name of the plugin/theme
105
- msgid "Breadcrumb Trail"
106
- msgstr ""
107
-
108
- #. Plugin URI of the plugin/theme
109
- msgid "http://themehybrid.com/plugins/breadcrumb-trail"
110
- msgstr ""
111
-
112
- #. Description of the plugin/theme
113
- msgid "A smart breadcrumb menu plugin embedded with <a href=\"http://schema.org\">Schema.org</a> microdata that can handle variations in site structure more accurately than any other breadcrumb plugin for WordPress. Insert into your theme with the <code>breadcrumb_trail()</code> template tag."
114
- msgstr ""
115
-
116
- #. Author of the plugin/theme
117
- msgid "Justin Tadlock"
118
- msgstr ""
119
-
120
- #. Author URI of the plugin/theme
121
- msgid "http://justintadlock.com"
122
- msgstr ""
1
+ # Copyright (C) 2015 Breadcrumb Trail
2
+ # This file is distributed under the same license as the Breadcrumb Trail package.
3
+ msgid ""
4
+ msgstr ""
5
+ "Project-Id-Version: Breadcrumb Trail 1.0.0-alpha-1\n"
6
+ "Report-Msgid-Bugs-To: http://wordpress.org/tag/breadcrumb-trail\n"
7
+ "POT-Creation-Date: 2015-07-07 16:55:40+00:00\n"
8
+ "MIME-Version: 1.0\n"
9
+ "Content-Type: text/plain; charset=UTF-8\n"
10
+ "Content-Transfer-Encoding: 8bit\n"
11
+ "PO-Revision-Date: 2015-MO-DA HO:MI+ZONE\n"
12
+ "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13
+ "Language-Team: LANGUAGE <LL@li.org>\n"
14
+
15
+ #: inc/breadcrumbs.php:244
16
+ msgid "Browse:"
17
+ msgstr ""
18
+
19
+ #: inc/breadcrumbs.php:245
20
+ msgctxt "breadcrumbs aria label"
21
+ msgid "Breadcrumbs"
22
+ msgstr ""
23
+
24
+ #: inc/breadcrumbs.php:246
25
+ msgid "Home"
26
+ msgstr ""
27
+
28
+ #: inc/breadcrumbs.php:247
29
+ msgid "404 Not Found"
30
+ msgstr ""
31
+
32
+ #: inc/breadcrumbs.php:248
33
+ msgid "Archives"
34
+ msgstr ""
35
+
36
+ #. Translators: %s is the search query. The HTML entities are opening and
37
+ #. closing curly quotes.
38
+
39
+ #: inc/breadcrumbs.php:250
40
+ msgid "Search results for &#8220;%s&#8221;"
41
+ msgstr ""
42
+
43
+ #. Translators: %s is the page number.
44
+
45
+ #: inc/breadcrumbs.php:252
46
+ msgid "Page %s"
47
+ msgstr ""
48
+
49
+ #. Translators: Minute archive title. %s is the minute time format.
50
+
51
+ #: inc/breadcrumbs.php:254
52
+ msgid "Minute %s"
53
+ msgstr ""
54
+
55
+ #. Translators: Weekly archive title. %s is the week date format.
56
+
57
+ #: inc/breadcrumbs.php:256
58
+ msgid "Week %s"
59
+ msgstr ""
60
+
61
+ #: inc/breadcrumbs.php:708
62
+ msgctxt "minute and hour archives time format"
63
+ msgid "g:i a"
64
+ msgstr ""
65
+
66
+ #: inc/breadcrumbs.php:725
67
+ msgctxt "minute archives time format"
68
+ msgid "i"
69
+ msgstr ""
70
+
71
+ #: inc/breadcrumbs.php:742
72
+ msgctxt "hour archives time format"
73
+ msgid "g a"
74
+ msgstr ""
75
+
76
+ #: inc/breadcrumbs.php:758 inc/breadcrumbs.php:787 inc/breadcrumbs.php:814
77
+ #: inc/breadcrumbs.php:841 inc/breadcrumbs.php:1176
78
+ msgctxt "yearly archives date format"
79
+ msgid "Y"
80
+ msgstr ""
81
+
82
+ #: inc/breadcrumbs.php:759 inc/breadcrumbs.php:815 inc/breadcrumbs.php:1180
83
+ msgctxt "monthly archives date format"
84
+ msgid "F"
85
+ msgstr ""
86
+
87
+ #: inc/breadcrumbs.php:760 inc/breadcrumbs.php:1184
88
+ msgctxt "daily archives date format"
89
+ msgid "j"
90
+ msgstr ""
91
+
92
+ #: inc/breadcrumbs.php:788
93
+ msgctxt "weekly archives date format"
94
+ msgid "W"
95
+ msgstr ""
96
+ #. Plugin Name of the plugin/theme
97
+ msgid "Breadcrumb Trail"
98
+ msgstr ""
99
+
100
+ #. Plugin URI of the plugin/theme
101
+ msgid "http://themehybrid.com/plugins/breadcrumb-trail"
102
+ msgstr ""
103
+
104
+ #. Description of the plugin/theme
105
+ msgid "A smart breadcrumb menu plugin embedded with <a href=\"http://schema.org\">Schema.org</a> microdata that can handle variations in site structure more accurately than any other breadcrumb plugin for WordPress. Insert into your theme with the <code>breadcrumb_trail()</code> template tag."
106
+ msgstr ""
107
+
108
+ #. Author of the plugin/theme
109
+ msgid "Justin Tadlock"
110
+ msgstr ""
111
+
112
+ #. Author URI of the plugin/theme
113
+ msgid "http://justintadlock.com"
114
+ msgstr ""
 
 
 
 
 
 
 
 
readme.md CHANGED
@@ -23,38 +23,36 @@ That's all you need to do to add breadcrumbs to your site. Of course, you can c
23
  The `breadcrumb_trail()` function accepts a single parameter of `$args`, which is an array of arguments for deciding how your breadcrumbs should behave. The default arguments are the following.
24
 
25
  $defaults = array(
26
- 'container' => 'div', // container element
27
- 'separator' => '&#47;', // separator between items
28
- 'before' => '', // HTML to output before
29
- 'after' => '', // HTML to output after
30
- 'show_on_front' => true, // whether to show on front
31
- 'network' => false, // whether to create trail back to main site (multisite)
32
- 'show_title' => true, // whether to show the current page title
33
- 'show_browse' => true, // whether to show the "browse" text
34
- 'echo' => true, // whether to echo or return the breadcrumbs
35
-
36
- /* Post taxonomy (examples follow). */
37
  'post_taxonomy' => array(
38
  // 'post' => 'post_tag', // 'post' post type and 'post_tag' taxonomy
39
  // 'book' => 'genre', // 'book' post type and 'genre' taxonomy
40
  ),
41
 
42
- /* Labels for text used (see Breadcrumb_Trail::default_labels). */
43
  'labels' => array(
44
- 'browse' => __( 'Browse:', 'breadcrumb-trail' ),
45
- 'home' => __( 'Home', 'breadcrumb-trail' ),
46
- 'error_404' => __( '404 Not Found', 'breadcrumb-trail' ),
47
- 'archives' => __( 'Archives', 'breadcrumb-trail' ),
48
- /* Translators: %s is the search query. The HTML entities are opening and closing curly quotes. */
49
- 'search' => __( 'Search results for &#8220;%s&#8221;', 'breadcrumb-trail' ),
50
- /* Translators: %s is the page number. */
51
- 'paged' => __( 'Page %s', 'breadcrumb-trail' ),
52
- /* Translators: Minute archive title. %s is the minute time format. */
53
- 'archive_minute' => __( 'Minute %s', 'breadcrumb-trail' ),
54
- /* Translators: Weekly archive title. %s is the week date format. */
55
- 'archive_week' => __( 'Week %s', 'breadcrumb-trail' ),
 
56
 
57
- /* "%s" is replaced with the translated date/time format. */
58
  'archive_minute_hour' => '%s',
59
  'archive_hour' => '%s',
60
  'archive_day' => '%s',
@@ -65,129 +63,31 @@ The `breadcrumb_trail()` function accepts a single parameter of `$args`, which i
65
 
66
  ### Hooks ###
67
 
 
68
  * `breadcrumb_trail_args` - Filter hook on the array of arguments passed in.
 
 
69
  * `breadcrumb_trail_items` - Filter hook on the array of items before being output.
70
- * `breadcrumb_trail_get_bbpress_items` - Filter hook on the array of items when using bbPress.
71
  * `breadcrumb_trail` - Filter hook on the HTML output of the breadcrumb trail.
72
 
73
  ### Extending `Breadcrumb_Trail` ###
74
 
75
- You can extend the `Breadcrumb_Trail` class with a custom class if needed. See the `bbPress_Breadcrumb_Trail` class as an example.
76
 
77
  #### Available properties ####
78
 
79
  * `$items` - Array of trail items.
80
  * `$args` - The parsed arguments passed in.
 
 
81
 
82
  #### Available methods #####
83
 
84
  * `trail()` - Outputs/returns the final HTML.
85
- * `do_trail_items()` - Method for filling the `$items` array.
86
 
87
  Others are available, but those are the two you would actually put into real-world use.
88
 
89
- ## Changelog ##
90
-
91
- ### Version 0.6.1 ###
92
-
93
- * Make sure `breadcrumb_trail()` can return the HTML.
94
- * Add `rel="home"` to the home page link. This got removed at some point.
95
- * Do network and site home links in bbPress.
96
- * Slight fix to stop bbPress from putting double "Forums" in the breadcrumb trail.
97
- * The `show_on_front` argument should only work if the front page is not paginated.
98
- * Better handling of the text strings, particularly when displaying date/time.
99
- * Updated `breadcrumb-trail.pot` file for better translating.
100
-
101
- ### Version 0.6.0 ###
102
-
103
- * [Schema.org](http://schema.org) support.
104
- * Completely overhauled the entire plugin, rewriting large swathes of code from the ground up. This version takes an object-oriented approach.
105
- * Blew every other breadcrumb menu script out of the water.
106
-
107
- ### Version 0.5.3 ###
108
-
109
- #### Enhancements ####
110
-
111
- * Use `post_type_archive_title()` on post type archives in the trail.
112
- * Add support for taxonomies that have a `$rewrite->slug` that matches a string value for a custom post type's `has_archive` argument.
113
- * Added support for an `archive_title` label for custom post types because we can't use the `post_type_archive_title()` function on single posts views for the post type.
114
- * Loads of pagination support on both archive-type pages and paged single posts.
115
- * Added support for hierarchical custom post types (get parent posts).
116
- * Added the `network` argument to allow multisite owners to run the trail all the way back to the main site.
117
-
118
- #### Bug fixes ####
119
-
120
- * Only check attachment trail if the attachment has a parent.
121
- * Fixed the issue where the wrong post type archive link matches with a term archive page.
122
-
123
- ### Version 0.5.2 ###
124
-
125
- * No friggin' clue. I think I actually skipped version numbers somehow. :)
126
-
127
- ### Version 0.5.1 ###
128
-
129
- * Changed license from GPL 2-only to GPL 2+.
130
- * Smarter handling of the `trail-begin` and `trail-end` classes.
131
- * Added `container` argument for wrapping breadcrumbs in a custom HTML element.
132
- * Changed `bbp_get_forum_parent()` to `bbp_get_forum_parent_id()`.
133
-
134
- ### Version 0.5.0 ###
135
-
136
- * Use hardcoded strings for the textdomain, not a variable.
137
- * Inline doc updates.
138
- * Added bbPress support.
139
- * Use `single_post_title()` instead of `get_the_title()` for post titles.
140
-
141
- ### Version 0.4.1 ###
142
-
143
- * Use `get_queried_object()` and `get_queried_object_id()` instead of accessing `$wp_query` directly.
144
- * Pass `$args` as second parameter in `breadcrumb_trail` hook.
145
-
146
- ### Version 0.4.0 ###
147
-
148
- * New function: `breadcrumb_trail_get_items()`, which grabs a list of all the trail items. This separates the items from the main `breadcrumb_trail()` function.
149
- * New filter hook: `breadcrumb_trail_items`, which allows devs to filter just the items.
150
- * New function: `breadcrumb_trail_map_rewrite_tags()`, which maps the permalink structure tags set under Permalink Settings in the admin to make for a much more accurate breadcrumb trail.
151
- * New function: `breadcrumb_trail_textdomain()`, which can be filtered when integrating the plugin into a theme to match the theme's textdomain.
152
- * Added functionality to handle WP 3.1 post type enhancements.
153
-
154
- ### Version 0.3.1 ###
155
-
156
- * Smarter logic in certain areas.
157
- * Removed localization for things that shouldn't be localized with time formats.
158
- * `single_tax` set to `null` instead of `false`.
159
- * Better escaping of element attributes.
160
- * Use `$wp_query->get_queried_object()` and `$wp_query->get_queried_object_id()`.
161
- * Add in initial support of WordPress 3.1's post type archives.
162
- * Better formatting and organization of the output late in the function.
163
- * Added `trail-before` and `trail-after` CSS classes if `$before` or `$after` is set.
164
-
165
- ### Version 0.3.1 ###
166
-
167
- * Undefined index error fixes.
168
- * Fixes for trying to get a property of a non-object.
169
-
170
- ### Version 0.3.0 ###
171
-
172
- * Added more support for custom post types and taxonomies.
173
- * Added more support for more complex hierarchies.
174
- * The breadcrumb trail now recognizes more patterns with pages as part of the permalink structure of other objects.
175
- * All post types can have any taxonomy as the leading part of the trail.
176
- * Cleaned up the code.
177
-
178
- ### Version 0.2.1 ###
179
-
180
- * Removed and/or added (depending on the case) the extra separator item on sub-categories and date-/time-based breadcrumbs.
181
-
182
- ### Version 0.2.0 ###
183
-
184
- * The title of the "home" page (i.e. posts page) when not the front page is now properly recognized.
185
- * Cleaned up the code and logic behind the plugin.
186
-
187
- ### Version 0.1.0 ###
188
-
189
- * Launch of the new plugin.
190
-
191
  ## Support ##
192
 
193
  I run a WordPress community called [Theme Hybrid](http://themehybrid.com), which is where I fully support all of my WordPress plugins, themes, and other projects. You can sign up for an account to get plugin support for a small yearly fee.
@@ -198,4 +98,4 @@ I know. I know. You might not want to pay for support, but just consider it a
198
 
199
  Breadcrumb Trail is licensed under the [GNU GPL](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html), version 2 or later.
200
 
201
- 2008&thinsp;&ndash;&thinsp;2013 &copy; [Justin Tadlock](http://justintadlock.com).
23
  The `breadcrumb_trail()` function accepts a single parameter of `$args`, which is an array of arguments for deciding how your breadcrumbs should behave. The default arguments are the following.
24
 
25
  $defaults = array(
26
+ 'container' => 'nav',
27
+ 'before' => '',
28
+ 'after' => '',
29
+ 'show_on_front' => true,
30
+ 'network' => false,
31
+ 'show_title' => true,
32
+ 'show_browse' => true,
33
+ 'echo' => true
34
+
 
 
35
  'post_taxonomy' => array(
36
  // 'post' => 'post_tag', // 'post' post type and 'post_tag' taxonomy
37
  // 'book' => 'genre', // 'book' post type and 'genre' taxonomy
38
  ),
39
 
 
40
  'labels' => array(
41
+ 'browse' => esc_html__( 'Browse:', 'breadcrumb-trail' ),
42
+ 'aria_label' => esc_attr_x( 'Breadcrumbs', 'breadcrumbs aria label', 'breadcrumb-trail' ),
43
+ 'home' => esc_html__( 'Home', 'breadcrumb-trail' ),
44
+ 'error_404' => esc_html__( '404 Not Found', 'breadcrumb-trail' ),
45
+ 'archives' => esc_html__( 'Archives', 'breadcrumb-trail' ),
46
+ // Translators: %s is the search query. The HTML entities are opening and closing curly quotes.
47
+ 'search' => esc_html__( 'Search results for &#8220;%s&#8221;', 'breadcrumb-trail' ),
48
+ // Translators: %s is the page number.
49
+ 'paged' => esc_html__( 'Page %s', 'breadcrumb-trail' ),
50
+ // Translators: Minute archive title. %s is the minute time format.
51
+ 'archive_minute' => esc_html__( 'Minute %s', 'breadcrumb-trail' ),
52
+ // Translators: Weekly archive title. %s is the week date format.
53
+ 'archive_week' => esc_html__( 'Week %s', 'breadcrumb-trail' ),
54
 
55
+ // "%s" is replaced with the translated date/time format.
56
  'archive_minute_hour' => '%s',
57
  'archive_hour' => '%s',
58
  'archive_day' => '%s',
63
 
64
  ### Hooks ###
65
 
66
+ * `breadcrumb_trail_object` - Filter the `Breadcrumb_Trail` object used for the trail.
67
  * `breadcrumb_trail_args` - Filter hook on the array of arguments passed in.
68
+ * `breadcrumb_trail_labels` - Filter hook on the text labels.
69
+ * `breadcrumb_trail_post_taxonomy` - Filter hook on the taxonomy to use with specific post types.
70
  * `breadcrumb_trail_items` - Filter hook on the array of items before being output.
 
71
  * `breadcrumb_trail` - Filter hook on the HTML output of the breadcrumb trail.
72
 
73
  ### Extending `Breadcrumb_Trail` ###
74
 
75
+ You can extend the `Breadcrumb_Trail` class with a custom class if needed. When creating a sub-class, you'll need to filter `breadcrumb_trail_object` to tell the plugin to use your class. Always return an object on this filter.
76
 
77
  #### Available properties ####
78
 
79
  * `$items` - Array of trail items.
80
  * `$args` - The parsed arguments passed in.
81
+ * `$labels` - The parsed text labels.
82
+ * `$post_taxonomy` - The parsed post taxonomy array.
83
 
84
  #### Available methods #####
85
 
86
  * `trail()` - Outputs/returns the final HTML.
87
+ * `add_items()` - Method for filling the `$items` array.
88
 
89
  Others are available, but those are the two you would actually put into real-world use.
90
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  ## Support ##
92
 
93
  I run a WordPress community called [Theme Hybrid](http://themehybrid.com), which is where I fully support all of my WordPress plugins, themes, and other projects. You can sign up for an account to get plugin support for a small yearly fee.
98
 
99
  Breadcrumb Trail is licensed under the [GNU GPL](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html), version 2 or later.
100
 
101
+ 2008&thinsp;&ndash;&thinsp;2015 &copy; [Justin Tadlock](http://justintadlock.com).
readme.txt CHANGED
@@ -3,8 +3,8 @@
3
  Contributors: greenshady
4
  Donate link: http://themehybrid.com/donate
5
  Tags: navigation, menu, breadcrumb, breadcrumbs, microdata, schema
6
- Requires at least: 3.6
7
- Stable tag: 0.6.1
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.htm
10
 
@@ -22,14 +22,14 @@ This means that it can also detect custom post types and taxonomies right out of
22
 
23
  ### Features ###
24
 
25
- * 5+ years of development and user testing.
26
  * Auto-detects the permalink structure of your site for the most accurate breadcrumbs.
27
  * Hooks for plugin/theme developers to overwrite output.
28
  * Coded with object-oriented programming (OOP) methods to allow developers to extend it for those highly-custom setups.
29
 
30
  ### Professional support ###
31
 
32
- If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](http://themehybrid.com/support), which is a professional WordPress help/support site where I handle support for all my plugins and themes for a community of 40,000+ users (and growing).
33
 
34
  == Installation ==
35
 
@@ -61,7 +61,19 @@ There are several methods, but in general, you would add the following line of c
61
 
62
  <?php if ( function_exists( 'breadcrumb_trail' ) ) breadcrumb_trail(); ?>
63
 
64
- To see all methods and options, refer to the `readme.md` file included with the plugin download.
 
 
 
 
 
 
 
 
 
 
 
 
65
 
66
  ### Do breadcrumbs show in Google search results? ###
67
 
@@ -96,108 +108,17 @@ There's not really much I can do to correct that within the Breadcrumb Trail plu
96
 
97
  == Upgrade Notice ==
98
 
99
- ### Version 0.6.0+ ###
100
 
101
- If upgrading to a version earlier than 0.6.0 to 0.6.0+, you should check the `readme.md` documentation on some of the argument changes if you've been adding custom arguments into the `breadcrumb_trail()` function.
102
 
103
  == Changelog ==
104
 
105
- ### Version 0.6.1 ###
106
-
107
- * Make sure `breadcrumb_trail()` can return the HTML.
108
- * Add `rel="home"` to the home page link. This got removed at some point.
109
- * Do network and site home links in bbPress.
110
- * Slight fix to stop bbPress from putting double "Forums" in the breadcrumb trail.
111
- * The `show_on_front` argument should only work if the front page is not paginated.
112
- * Better handling of the text strings, particularly when displaying date/time.
113
- * Updated `breadcrumb-trail.pot` file for better translating.
114
-
115
- ### Version 0.6.0 ###
116
-
117
- * [Schema.org](http://schema.org) support.
118
- * Completely overhauled the entire plugin, rewriting large swathes of code from the ground up. This version takes an object-oriented approach.
119
- * Blew every other breadcrumb menu script out of the water.
120
-
121
- ### Version 0.5.3 ###
122
-
123
- #### Enhancements ####
124
-
125
- * Use `post_type_archive_title()` on post type archives in the trail.
126
- * Add support for taxonomies that have a `$rewrite->slug` that matches a string value for a custom post type's `has_archive` argument.
127
- * Added support for an `archive_title` label for custom post types because we can't use the `post_type_archive_title()` function on single posts views for the post type.
128
- * Loads of pagination support on both archive-type pages and paged single posts.
129
- * Added support for hierarchical custom post types (get parent posts).
130
- * Added the `network` argument to allow multisite owners to run the trail all the way back to the main site.
131
-
132
- #### Bug fixes ####
133
-
134
- * Only check attachment trail if the attachment has a parent.
135
- * Fixed the issue where the wrong post type archive link matches with a term archive page.
136
-
137
- ### Version 0.5.2 ###
138
-
139
- * No friggin' clue. I think I actually skipped version numbers somehow. :)
140
-
141
- ### Version 0.5.1 ###
142
-
143
- * Changed license from GPL 2-only to GPL 2+.
144
- * Smarter handling of the `trail-begin` and `trail-end` classes.
145
- * Added `container` argument for wrapping breadcrumbs in a custom HTML element.
146
- * Changed `bbp_get_forum_parent()` to `bbp_get_forum_parent_id()`.
147
-
148
- ### Version 0.5.0 ###
149
-
150
- * Use hardcoded strings for the textdomain, not a variable.
151
- * Inline doc updates.
152
- * Added bbPress support.
153
- * Use `single_post_title()` instead of `get_the_title()` for post titles.
154
-
155
- ### Version 0.4.1 ###
156
-
157
- * Use `get_queried_object()` and `get_queried_object_id()` instead of accessing `$wp_query` directly.
158
- * Pass `$args` as second parameter in `breadcrumb_trail` hook.
159
-
160
- ### Version 0.4.0 ###
161
-
162
- * New function: `breadcrumb_trail_get_items()`, which grabs a list of all the trail items. This separates the items from the main `breadcrumb_trail()` function.
163
- * New filter hook: `breadcrumb_trail_items`, which allows devs to filter just the items.
164
- * New function: `breadcrumb_trail_map_rewrite_tags()`, which maps the permalink structure tags set under Permalink Settings in the admin to make for a much more accurate breadcrumb trail.
165
- * New function: `breadcrumb_trail_textdomain()`, which can be filtered when integrating the plugin into a theme to match the theme's textdomain.
166
- * Added functionality to handle WP 3.1 post type enhancements.
167
-
168
- ### Version 0.3.1 ###
169
-
170
- * Smarter logic in certain areas.
171
- * Removed localization for things that shouldn't be localized with time formats.
172
- * `single_tax` set to `null` instead of `false`.
173
- * Better escaping of element attributes.
174
- * Use `$wp_query->get_queried_object()` and `$wp_query->get_queried_object_id()`.
175
- * Add in initial support of WordPress 3.1's post type archives.
176
- * Better formatting and organization of the output late in the function.
177
- * Added `trail-before` and `trail-after` CSS classes if `$before` or `$after` is set.
178
-
179
- ### Version 0.3.1 ###
180
-
181
- * Undefined index error fixes.
182
- * Fixes for trying to get a property of a non-object.
183
-
184
- ### Version 0.3.0 ###
185
 
186
- * Added more support for custom post types and taxonomies.
187
- * Added more support for more complex hierarchies.
188
- * The breadcrumb trail now recognizes more patterns with pages as part of the permalink structure of other objects.
189
- * All post types can have any taxonomy as the leading part of the trail.
190
- * Cleaned up the code.
191
 
192
- ### Version 0.2.1 ###
193
 
194
- * Removed and/or added (depending on the case) the extra separator item on sub-categories and date-/time-based breadcrumbs.
195
 
196
- ### Version 0.2.0 ###
197
 
198
- * The title of the "home" page (i.e. posts page) when not the front page is now properly recognized.
199
- * Cleaned up the code and logic behind the plugin.
200
 
201
- ### Version 0.1.0 ###
202
 
203
- * Launch of the new plugin.
3
  Contributors: greenshady
4
  Donate link: http://themehybrid.com/donate
5
  Tags: navigation, menu, breadcrumb, breadcrumbs, microdata, schema
6
+ Requires at least: 4.2
7
+ Stable tag: 1.0.0
8
  License: GPLv2 or later
9
  License URI: http://www.gnu.org/licenses/gpl-2.0.htm
10
 
22
 
23
  ### Features ###
24
 
25
+ * 7+ years of development and user testing.
26
  * Auto-detects the permalink structure of your site for the most accurate breadcrumbs.
27
  * Hooks for plugin/theme developers to overwrite output.
28
  * Coded with object-oriented programming (OOP) methods to allow developers to extend it for those highly-custom setups.
29
 
30
  ### Professional support ###
31
 
32
+ If you need professional plugin support from me, the plugin author, you can access the support forums at [Theme Hybrid](http://themehybrid.com), which is a professional WordPress help/support site where I handle support for all my plugins and themes for a community of 60,000+ users (and growing).
33
 
34
  == Installation ==
35
 
61
 
62
  <?php if ( function_exists( 'breadcrumb_trail' ) ) breadcrumb_trail(); ?>
63
 
64
+ To see all methods and options, refer to the `readme.md` file included with the plugin download. You can also [view the readme online](https://github.com/justintadlock/breadcrumb-trail/blob/master/readme.md).
65
+
66
+ ### How do I disable the plugin styles? ###
67
+
68
+ You can disable the plugin styles by adding this to your theme's `functions.php` file:
69
+
70
+ add_action( 'after_setup_theme', 'bct_theme_setup' );
71
+
72
+ function bct_theme_setup() {
73
+ add_theme_support( 'breadcrumb-trail' );
74
+ }
75
+
76
+ Note that the breadcrumbs will be completely unstyled at this point. You'll need to add style rules to your theme's `style.css` file.
77
 
78
  ### Do breadcrumbs show in Google search results? ###
79
 
108
 
109
  == Upgrade Notice ==
110
 
111
+ ### Version 1.0.0+ ###
112
 
113
+ If upgrading to a version earlier than 1.0.0, your custom styles may need to be adjusted. The HTML markup has changed to a better HTML5 structure.
114
 
115
  == Changelog ==
116
 
117
+ Please see the `changelog.md` file included with the plugin file. Or, you can view the [online change log](https://github.com/justintadlock/breadcrumb-trail/blob/master/readme.md).
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
118
 
 
 
 
 
 
119
 
 
120
 
 
121
 
 
122
 
 
 
123
 
 
124