Breadcrumb Trail - Version 0.6.0

Version Description

Version 0.6.0+

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 padding custom arguments into the breadcrumb_trail() function.

Download this release

Release Info

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

Code changes from version 0.4.1 to 0.6.0

breadcrumb-trail-en_EN.mo DELETED
Binary file
breadcrumb-trail-en_EN.po DELETED
@@ -1,87 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Breadcrumb Trail WordPress Plugin\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2011-03-19 15:52-0600\n"
6
- "PO-Revision-Date: \n"
7
- "Last-Translator: Justin Tadlock <justin@justintadlock.com>\n"
8
- "Language-Team: <justin@justintadlock.com>\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Poedit-Language: English\n"
13
- "X-Poedit-Country: UNITED STATES\n"
14
- "X-Poedit-KeywordsList: _e;__;esc_attr_e;esc_attr__;esc_html_e;esc_html__\n"
15
- "X-Poedit-Basepath: .\n"
16
- "X-Poedit-SearchPath-0: .\n"
17
-
18
- #: breadcrumb-trail.php:62
19
- msgid "Browse:"
20
- msgstr ""
21
-
22
- #: breadcrumb-trail.php:65
23
- msgid "Home"
24
- msgstr ""
25
-
26
- #: breadcrumb-trail.php:314
27
- msgid "g:i a"
28
- msgstr ""
29
-
30
- #: breadcrumb-trail.php:317
31
- #, php-format
32
- msgid "Minute %1$s"
33
- msgstr ""
34
-
35
- #: breadcrumb-trail.php:317
36
- msgid "i"
37
- msgstr ""
38
-
39
- #: breadcrumb-trail.php:320
40
- msgid "g a"
41
- msgstr ""
42
-
43
- #: breadcrumb-trail.php:331
44
- #: breadcrumb-trail.php:337
45
- #: breadcrumb-trail.php:342
46
- #: breadcrumb-trail.php:347
47
- #: breadcrumb-trail.php:411
48
- msgid "Y"
49
- msgstr ""
50
-
51
- #: breadcrumb-trail.php:332
52
- #: breadcrumb-trail.php:343
53
- #: breadcrumb-trail.php:415
54
- msgid "F"
55
- msgstr ""
56
-
57
- #: breadcrumb-trail.php:333
58
- #: breadcrumb-trail.php:419
59
- msgid "d"
60
- msgstr ""
61
-
62
- #: breadcrumb-trail.php:338
63
- #, php-format
64
- msgid "Week %1$s"
65
- msgstr ""
66
-
67
- #: breadcrumb-trail.php:338
68
- msgid "W"
69
- msgstr ""
70
-
71
- #: breadcrumb-trail.php:354
72
- #, php-format
73
- msgid "Search results for &quot;%1$s&quot;"
74
- msgstr ""
75
-
76
- #: breadcrumb-trail.php:358
77
- msgid "404 Not Found"
78
- msgstr ""
79
-
80
- #: breadcrumb-trail.php:415
81
- msgid "F Y"
82
- msgstr ""
83
-
84
- #: breadcrumb-trail.php:419
85
- msgid "F j, Y"
86
- msgstr ""
87
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
breadcrumb-trail.php CHANGED
@@ -1,589 +1,16 @@
1
  <?php
2
  /**
3
  * Plugin Name: Breadcrumb Trail
4
- * Plugin URI: http://justintadlock.com/archives/2009/04/05/breadcrumb-trail-wordpress-plugin
5
- * Description: A WordPress plugin that gives you the <code>breadcrumb_trail()</code> template tag to use anywhere in your theme to show a breadcrumb menu.
6
- * Version: 0.4.1
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
9
- *
10
- * Breadcrumb Trail - A breadcrumb menu script for WordPress.
11
- *
12
- * Breadcrumb Trail is a script for showing a breadcrumb trail for any type of page. It tries to anticipate
13
- * any type of structure and display the best possible trail that matches your site's permalink structure.
14
- * While not perfect, it attempts to fill in the gaps left by many other breadcrumb scripts.
15
- *
16
- * This program is free software; you can redistribute it and/or modify it under the terms of the GNU
17
- * General Public License version 2, as published by the Free Software Foundation. You may NOT assume
18
- * that you can use any other version of the GPL.
19
- *
20
- * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
21
- * even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22
- *
23
- * @package BreadcrumbTrail
24
- * @version 0.4.1
25
- * @author Justin Tadlock <justin@justintadlock.com>
26
- * @copyright Copyright (c) 2008 - 2011, Justin Tadlock
27
- * @link http://justintadlock.com/archives/2009/04/05/breadcrumb-trail-wordpress-plugin
28
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
29
  */
30
 
31
- /**
32
- * Yes, we're localizing the plugin. This partly makes sure non-English users can use it too.
33
- * To translate into your language use the breadcrumb-trail-en_EN.po file as as guide. Poedit
34
- * is a good tool to for translating.
35
- * @link http://poedit.net
36
- *
37
- * @since 0.1.0
38
- */
39
- load_plugin_textdomain( 'breadcrumb-trail', false, 'breadcrumb-trail' );
40
-
41
- /**
42
- * Shows a breadcrumb for all types of pages. This function is formatting the final output of the
43
- * breadcrumb trail. The breadcrumb_trail_get_items() function returns the items and this function
44
- * formats those items.
45
- *
46
- * @since 0.1.0
47
- * @param array $args Mixed arguments for the menu.
48
- * @return string Output of the breadcrumb menu.
49
- */
50
- function breadcrumb_trail( $args = array() ) {
51
-
52
- /* Get the textdomain. */
53
- $textdomain = breadcrumb_trail_textdomain();
54
-
55
- /* Create an empty variable for the breadcrumb. */
56
- $breadcrumb = '';
57
-
58
- /* Set up the default arguments for the breadcrumb. */
59
- $defaults = array(
60
- 'separator' => '/',
61
- 'before' => '<span class="breadcrumb-title">' . __( 'Browse:', $textdomain ) . '</span>',
62
- 'after' => false,
63
- 'front_page' => true,
64
- 'show_home' => __( 'Home', $textdomain ),
65
- 'echo' => true
66
- );
67
-
68
- /* Allow singular post views to have a taxonomy's terms prefixing the trail. */
69
- if ( is_singular() ) {
70
- $post = get_queried_object();
71
- $defaults["singular_{$post->post_type}_taxonomy"] = false;
72
- }
73
-
74
- /* Apply filters to the arguments. */
75
- $args = apply_filters( 'breadcrumb_trail_args', $args );
76
-
77
- /* Parse the arguments and extract them for easy variable naming. */
78
- $args = wp_parse_args( $args, $defaults );
79
-
80
- /* Get the trail items. */
81
- $trail = breadcrumb_trail_get_items( $args );
82
-
83
- /* Connect the breadcrumb trail if there are items in the trail. */
84
- if ( !empty( $trail ) && is_array( $trail ) ) {
85
-
86
- /* Open the breadcrumb trail containers. */
87
- $breadcrumb = '<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail">';
88
-
89
- /* If $before was set, wrap it in a container. */
90
- $breadcrumb .= ( !empty( $args['before'] ) ? '<span class="trail-before">' . $args['before'] . '</span> ' : '' );
91
-
92
- /* Wrap the $trail['trail_end'] value in a container. */
93
- if ( !empty( $trail['trail_end'] ) )
94
- $trail['trail_end'] = '<span class="trail-end">' . $trail['trail_end'] . '</span>';
95
-
96
- /* Format the separator. */
97
- $separator = ( !empty( $args['separator'] ) ? '<span class="sep">' . $args['separator'] . '</span>' : '<span class="sep">/</span>' );
98
-
99
- /* Join the individual trail items into a single string. */
100
- $breadcrumb .= join( " {$separator} ", $trail );
101
-
102
- /* If $after was set, wrap it in a container. */
103
- $breadcrumb .= ( !empty( $args['after'] ) ? ' <span class="trail-after">' . $args['after'] . '</span>' : '' );
104
-
105
- /* Close the breadcrumb trail containers. */
106
- $breadcrumb .= '</div></div>';
107
- }
108
-
109
- /* Allow developers to filter the breadcrumb trail HTML. */
110
- $breadcrumb = apply_filters( 'breadcrumb_trail', $breadcrumb, $args );
111
-
112
- /* Output the breadcrumb. */
113
- if ( $args['echo'] )
114
- echo $breadcrumb;
115
- else
116
- return $breadcrumb;
117
- }
118
-
119
- /**
120
- * Gets the items for the breadcrumb trail. This is the heart of the script. It checks the current page
121
- * being viewed and decided based on the information provided by WordPress what items should be
122
- * added to the breadcrumb trail.
123
- *
124
- * @since 0.4.0
125
- * @todo Build in caching based on the queried object ID.
126
- * @param array $args Mixed arguments for the menu.
127
- * @return array List of items to be shown in the trail.
128
- */
129
- function breadcrumb_trail_get_items( $args = array() ) {
130
- global $wp_rewrite;
131
-
132
- /* Get the textdomain. */
133
- $textdomain = breadcrumb_trail_textdomain();
134
-
135
- /* Set up an empty trail array and empty path. */
136
- $trail = array();
137
- $path = '';
138
-
139
- /* If $show_home is set and we're not on the front page of the site, link to the home page. */
140
- if ( !is_front_page() && $args['show_home'] )
141
- $trail[] = '<a href="' . home_url() . '" title="' . esc_attr( get_bloginfo( 'name' ) ) . '" rel="home" class="trail-begin">' . $args['show_home'] . '</a>';
142
-
143
- /* If viewing the front page of the site. */
144
- if ( is_front_page() ) {
145
- if ( $args['show_home'] && $args['front_page'] )
146
- $trail['trail_end'] = "{$args['show_home']}";
147
- }
148
-
149
- /* If viewing the "home"/posts page. */
150
- elseif ( is_home() ) {
151
- $home_page = get_page( get_queried_object_id() );
152
- $trail = array_merge( $trail, breadcrumb_trail_get_parents( $home_page->post_parent, '' ) );
153
- $trail['trail_end'] = get_the_title( $home_page->ID );
154
- }
155
-
156
- /* If viewing a singular post (page, attachment, etc.). */
157
- elseif ( is_singular() ) {
158
-
159
- /* Get singular post variables needed. */
160
- $post = get_queried_object();
161
- $post_id = absint( get_queried_object_id() );
162
- $post_type = $post->post_type;
163
- $parent = absint( $post->post_parent );
164
-
165
- /* Get the post type object. */
166
- $post_type_object = get_post_type_object( $post_type );
167
-
168
- /* If viewing a singular 'post'. */
169
- if ( 'post' == $post_type ) {
170
-
171
- /* If $front has been set, add it to the $path. */
172
- $path .= trailingslashit( $wp_rewrite->front );
173
-
174
- /* If there's a path, check for parents. */
175
- if ( !empty( $path ) )
176
- $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
177
-
178
- /* Map the permalink structure tags to actual links. */
179
- $trail = array_merge( $trail, breadcrumb_trail_map_rewrite_tags( $post_id, get_option( 'permalink_structure' ), $args ) );
180
- }
181
-
182
- /* If viewing a singular 'attachment'. */
183
- elseif ( 'attachment' == $post_type ) {
184
-
185
- /* If $front has been set, add it to the $path. */
186
- $path .= trailingslashit( $wp_rewrite->front );
187
-
188
- /* If there's a path, check for parents. */
189
- if ( !empty( $path ) )
190
- $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
191
-
192
- /* Map the post (parent) permalink structure tags to actual links. */
193
- $trail = array_merge( $trail, breadcrumb_trail_map_rewrite_tags( $post->post_parent, get_option( 'permalink_structure' ), $args ) );
194
- }
195
-
196
- /* If a custom post type, check if there are any pages in its hierarchy based on the slug. */
197
- elseif ( 'page' !== $post_type ) {
198
-
199
- /* If $front has been set, add it to the $path. */
200
- if ( $post_type_object->rewrite['with_front'] && $wp_rewrite->front )
201
- $path .= trailingslashit( $wp_rewrite->front );
202
-
203
- /* If there's a slug, add it to the $path. */
204
- if ( !empty( $post_type_object->rewrite['slug'] ) )
205
- $path .= $post_type_object->rewrite['slug'];
206
-
207
- /* If there's a path, check for parents. */
208
- if ( !empty( $path ) )
209
- $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
210
-
211
- /* If there's an archive page, add it to the trail. */
212
- if ( !empty( $post_type_object->has_archive ) )
213
- $trail[] = '<a href="' . get_post_type_archive_link( $post_type ) . '" title="' . esc_attr( $post_type_object->labels->name ) . '">' . $post_type_object->labels->name . '</a>';
214
- }
215
-
216
- /* If the post type path returns nothing and there is a parent, get its parents. */
217
- if ( ( empty( $path ) && 0 !== $parent ) || ( 'attachment' == $post_type ) )
218
- $trail = array_merge( $trail, breadcrumb_trail_get_parents( $parent, '' ) );
219
-
220
- /* Or, if the post type is hierarchical and there's a parent, get its parents. */
221
- elseif ( 0 !== $parent && is_post_type_hierarchical( $post_type ) )
222
- $trail = array_merge( $trail, breadcrumb_trail_get_parents( $parent, '' ) );
223
-
224
- /* Display terms for specific post type taxonomy if requested. */
225
- if ( !empty( $args["singular_{$post_type}_taxonomy"] ) && $terms = get_the_term_list( $post_id, $args["singular_{$post_type}_taxonomy"], '', ', ', '' ) )
226
- $trail[] = $terms;
227
-
228
- /* End with the post title. */
229
- $post_title = get_the_title();
230
- if ( !empty( $post_title ) )
231
- $trail['trail_end'] = $post_title;
232
- }
233
-
234
- /* If we're viewing any type of archive. */
235
- elseif ( is_archive() ) {
236
-
237
- /* If viewing a taxonomy term archive. */
238
- if ( is_tax() || is_category() || is_tag() ) {
239
-
240
- /* Get some taxonomy and term variables. */
241
- $term = get_queried_object();
242
- $taxonomy = get_taxonomy( $term->taxonomy );
243
-
244
- /* Get the path to the term archive. Use this to determine if a page is present with it. */
245
- if ( is_category() )
246
- $path = get_option( 'category_base' );
247
- elseif ( is_tag() )
248
- $path = get_option( 'tag_base' );
249
- else {
250
- if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front )
251
- $path = trailingslashit( $wp_rewrite->front );
252
- $path .= $taxonomy->rewrite['slug'];
253
- }
254
-
255
- /* Get parent pages by path if they exist. */
256
- if ( $path )
257
- $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
258
-
259
- /* If the taxonomy is hierarchical, list its parent terms. */
260
- if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent )
261
- $trail = array_merge( $trail, breadcrumb_trail_get_term_parents( $term->parent, $term->taxonomy ) );
262
-
263
- /* Add the term name to the trail end. */
264
- $trail['trail_end'] = single_term_title( '', false );
265
- }
266
-
267
- /* If viewing a post type archive. */
268
- elseif ( is_post_type_archive() ) {
269
-
270
- /* Get the post type object. */
271
- $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
272
-
273
- /* If $front has been set, add it to the $path. */
274
- if ( $post_type_object->rewrite['with_front'] && $wp_rewrite->front )
275
- $path .= trailingslashit( $wp_rewrite->front );
276
-
277
- /* If there's a slug, add it to the $path. */
278
- if ( !empty( $post_type_object->rewrite['slug'] ) )
279
- $path .= $post_type_object->rewrite['slug'];
280
-
281
- /* If there's a path, check for parents. */
282
- if ( !empty( $path ) )
283
- $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
284
-
285
- /* Add the post type [plural] name to the trail end. */
286
- $trail['trail_end'] = $post_type_object->labels->name;
287
- }
288
-
289
- /* If viewing an author archive. */
290
- elseif ( is_author() ) {
291
-
292
- /* If $front has been set, add it to $path. */
293
- if ( !empty( $wp_rewrite->front ) )
294
- $path .= trailingslashit( $wp_rewrite->front );
295
-
296
- /* If an $author_base exists, add it to $path. */
297
- if ( !empty( $wp_rewrite->author_base ) )
298
- $path .= $wp_rewrite->author_base;
299
-
300
- /* If $path exists, check for parent pages. */
301
- if ( !empty( $path ) )
302
- $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
303
-
304
- /* Add the author's display name to the trail end. */
305
- $trail['trail_end'] = get_the_author_meta( 'display_name', get_query_var( 'author' ) );
306
- }
307
-
308
- /* If viewing a time-based archive. */
309
- elseif ( is_time() ) {
310
-
311
- if ( get_query_var( 'minute' ) && get_query_var( 'hour' ) )
312
- $trail['trail_end'] = get_the_time( __( 'g:i a', $textdomain ) );
313
-
314
- elseif ( get_query_var( 'minute' ) )
315
- $trail['trail_end'] = sprintf( __( 'Minute %1$s', $textdomain ), get_the_time( __( 'i', $textdomain ) ) );
316
-
317
- elseif ( get_query_var( 'hour' ) )
318
- $trail['trail_end'] = get_the_time( __( 'g a', $textdomain ) );
319
- }
320
-
321
- /* If viewing a date-based archive. */
322
- elseif ( is_date() ) {
323
-
324
- /* If $front has been set, check for parent pages. */
325
- if ( $wp_rewrite->front )
326
- $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $wp_rewrite->front ) );
327
-
328
- if ( is_day() ) {
329
- $trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
330
- $trail[] = '<a href="' . get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) . '" title="' . get_the_time( esc_attr__( 'F', $textdomain ) ) . '">' . get_the_time( __( 'F', $textdomain ) ) . '</a>';
331
- $trail['trail_end'] = get_the_time( __( 'd', $textdomain ) );
332
- }
333
-
334
- elseif ( get_query_var( 'w' ) ) {
335
- $trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
336
- $trail['trail_end'] = sprintf( __( 'Week %1$s', $textdomain ), get_the_time( esc_attr__( 'W', $textdomain ) ) );
337
- }
338
-
339
- elseif ( is_month() ) {
340
- $trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
341
- $trail['trail_end'] = get_the_time( __( 'F', $textdomain ) );
342
- }
343
-
344
- elseif ( is_year() ) {
345
- $trail['trail_end'] = get_the_time( __( 'Y', $textdomain ) );
346
- }
347
- }
348
- }
349
-
350
- /* If viewing search results. */
351
- elseif ( is_search() )
352
- $trail['trail_end'] = sprintf( __( 'Search results for &quot;%1$s&quot;', $textdomain ), esc_attr( get_search_query() ) );
353
-
354
- /* If viewing a 404 error page. */
355
- elseif ( is_404() )
356
- $trail['trail_end'] = __( '404 Not Found', $textdomain );
357
-
358
- /* Allow devs to step in and filter the $trail array. */
359
- return apply_filters( 'breadcrumb_trail_items', $trail, $args );
360
- }
361
-
362
- /**
363
- * Turns %tag% from permalink structures into usable links for the breadcrumb trail. This feels kind of
364
- * hackish for now because we're checking for specific %tag% examples and only doing it for the 'post'
365
- * post type. In the future, maybe it'll handle a wider variety of possibilities, especially for custom post
366
- * types.
367
- *
368
- * @since 0.4.0
369
- * @param int $post_id ID of the post whose parents we want.
370
- * @param string $path Path of a potential parent page.
371
- * @param array $args Mixed arguments for the menu.
372
- * @return array $trail Array of links to the post breadcrumb.
373
- */
374
- function breadcrumb_trail_map_rewrite_tags( $post_id = '', $path = '', $args = array() ) {
375
-
376
- /* Set up an empty $trail array. */
377
- $trail = array();
378
-
379
- /* Make sure there's a $path and $post_id before continuing. */
380
- if ( empty( $path ) || empty( $post_id ) )
381
- return $trail;
382
-
383
- /* Get the post based on the post ID. */
384
- $post = get_post( $post_id );
385
-
386
- /* If no post is returned, an error is returned, or the post does not have a 'post' post type, return. */
387
- if ( empty( $post ) || is_wp_error( $post ) || 'post' !== $post->post_type )
388
- return $trail;
389
-
390
- /* Get the textdomain. */
391
- $textdomain = breadcrumb_trail_textdomain();
392
-
393
- /* Trim '/' from both sides of the $path. */
394
- $path = trim( $path, '/' );
395
-
396
- /* Split the $path into an array of strings. */
397
- $matches = explode( '/', $path );
398
-
399
- /* If matches are found for the path. */
400
- if ( is_array( $matches ) ) {
401
-
402
- /* Loop through each of the matches, adding each to the $trail array. */
403
- foreach ( $matches as $match ) {
404
-
405
- /* Trim any '/' from the $match. */
406
- $tag = trim( $match, '/' );
407
-
408
- /* If using the %year% tag, add a link to the yearly archive. */
409
- if ( '%year%' == $tag )
410
- $trail[] = '<a href="' . get_year_link( get_the_time( 'Y', $post_id ) ) . '" title="' . get_the_time( esc_attr__( 'Y', $textdomain ), $post_id ) . '">' . get_the_time( __( 'Y', $textdomain ), $post_id ) . '</a>';
411
-
412
- /* If using the %monthnum% tag, add a link to the monthly archive. */
413
- elseif ( '%monthnum%' == $tag )
414
- $trail[] = '<a href="' . get_month_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ) ) . '" title="' . get_the_time( esc_attr__( 'F Y', $textdomain ), $post_id ) . '">' . get_the_time( __( 'F', $textdomain ), $post_id ) . '</a>';
415
-
416
- /* If using the %day% tag, add a link to the daily archive. */
417
- elseif ( '%day%' == $tag )
418
- $trail[] = '<a href="' . get_day_link( get_the_time( 'Y', $post_id ), get_the_time( 'm', $post_id ), get_the_time( 'd', $post_id ) ) . '" title="' . get_the_time( esc_attr__( 'F j, Y', $textdomain ), $post_id ) . '">' . get_the_time( __( 'd', $textdomain ), $post_id ) . '</a>';
419
-
420
- /* If using the %author% tag, add a link to the post author archive. */
421
- elseif ( '%author%' == $tag )
422
- $trail[] = '<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>';
423
-
424
- /* If using the %category% tag, add a link to the first category archive to match permalinks. */
425
- elseif ( '%category%' == $tag && 'category' !== $args["singular_{$post->post_type}_taxonomy"] ) {
426
-
427
- /* Get the post categories. */
428
- $terms = get_the_category( $post_id );
429
-
430
- /* Check that categories were returned. */
431
- if ( $terms ) {
432
-
433
- /* Sort the terms by ID and get the first category. */
434
- usort( $terms, '_usort_terms_by_ID' );
435
- $term = get_term( $terms[0], 'category' );
436
-
437
- /* If the category has a parent, add the hierarchy to the trail. */
438
- if ( 0 !== $term->parent )
439
- $trail = array_merge( $trail, breadcrumb_trail_get_term_parents( $term->parent, 'category' ) );
440
-
441
- /* Add the category archive link to the trail. */
442
- $trail[] = '<a href="' . get_term_link( $term, 'category' ) . '" title="' . esc_attr( $term->name ) . '">' . $term->name . '</a>';
443
- }
444
- }
445
- }
446
- }
447
-
448
- /* Return the $trail array. */
449
- return $trail;
450
- }
451
-
452
- /**
453
- * Gets parent pages of any post type or taxonomy by the ID or Path. The goal of this function is to create
454
- * a clear path back to home given what would normally be a "ghost" directory. If any page matches the given
455
- * path, it'll be added. But, it's also just a way to check for a hierarchy with hierarchical post types.
456
- *
457
- * @since 0.3.0
458
- * @param int $post_id ID of the post whose parents we want.
459
- * @param string $path Path of a potential parent page.
460
- * @return array $trail Array of parent page links.
461
- */
462
- function breadcrumb_trail_get_parents( $post_id = '', $path = '' ) {
463
-
464
- /* Set up an empty trail array. */
465
- $trail = array();
466
-
467
- /* Trim '/' off $path in case we just got a simple '/' instead of a real path. */
468
- $path = trim( $path, '/' );
469
-
470
- /* If neither a post ID nor path set, return an empty array. */
471
- if ( empty( $post_id ) && empty( $path ) )
472
- return $trail;
473
-
474
- /* If the post ID is empty, use the path to get the ID. */
475
- if ( empty( $post_id ) ) {
476
-
477
- /* Get parent post by the path. */
478
- $parent_page = get_page_by_path( $path );
479
-
480
- /* If a parent post is found, set the $post_id variable to it. */
481
- if ( !empty( $parent_page ) )
482
- $post_id = $parent_page->ID;
483
- }
484
-
485
- /* If a post ID and path is set, search for a post by the given path. */
486
- if ( $post_id == 0 && !empty( $path ) ) {
487
-
488
- /* Separate post names into separate paths by '/'. */
489
- $path = trim( $path, '/' );
490
- preg_match_all( "/\/.*?\z/", $path, $matches );
491
-
492
- /* If matches are found for the path. */
493
- if ( isset( $matches ) ) {
494
-
495
- /* Reverse the array of matches to search for posts in the proper order. */
496
- $matches = array_reverse( $matches );
497
-
498
- /* Loop through each of the path matches. */
499
- foreach ( $matches as $match ) {
500
-
501
- /* If a match is found. */
502
- if ( isset( $match[0] ) ) {
503
-
504
- /* Get the parent post by the given path. */
505
- $path = str_replace( $match[0], '', $path );
506
- $parent_page = get_page_by_path( trim( $path, '/' ) );
507
-
508
- /* If a parent post is found, set the $post_id and break out of the loop. */
509
- if ( !empty( $parent_page ) && $parent_page->ID > 0 ) {
510
- $post_id = $parent_page->ID;
511
- break;
512
- }
513
- }
514
- }
515
- }
516
- }
517
-
518
- /* While there's a post ID, add the post link to the $parents array. */
519
- while ( $post_id ) {
520
-
521
- /* Get the post by ID. */
522
- $page = get_page( $post_id );
523
-
524
- /* Add the formatted post link to the array of parents. */
525
- $parents[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . get_the_title( $post_id ) . '</a>';
526
-
527
- /* Set the parent post's parent to the post ID. */
528
- $post_id = $page->post_parent;
529
- }
530
-
531
- /* If we have parent posts, reverse the array to put them in the proper order for the trail. */
532
- if ( isset( $parents ) )
533
- $trail = array_reverse( $parents );
534
-
535
- /* Return the trail of parent posts. */
536
- return $trail;
537
- }
538
-
539
- /**
540
- * Searches for term parents of hierarchical taxonomies. This function is similar to the WordPress
541
- * function get_category_parents() but handles any type of taxonomy.
542
- *
543
- * @since 0.3.0
544
- * @param int $parent_id The ID of the first parent.
545
- * @param object|string $taxonomy The taxonomy of the term whose parents we want.
546
- * @return array $trail Array of links to parent terms.
547
- */
548
- function breadcrumb_trail_get_term_parents( $parent_id = '', $taxonomy = '' ) {
549
-
550
- /* Set up some default arrays. */
551
- $trail = array();
552
- $parents = array();
553
-
554
- /* If no term parent ID or taxonomy is given, return an empty array. */
555
- if ( empty( $parent_id ) || empty( $taxonomy ) )
556
- return $trail;
557
-
558
- /* While there is a parent ID, add the parent term link to the $parents array. */
559
- while ( $parent_id ) {
560
-
561
- /* Get the parent term. */
562
- $parent = get_term( $parent_id, $taxonomy );
563
-
564
- /* Add the formatted term link to the array of parent terms. */
565
- $parents[] = '<a href="' . get_term_link( $parent, $taxonomy ) . '" title="' . esc_attr( $parent->name ) . '">' . $parent->name . '</a>';
566
-
567
- /* Set the parent term's parent as the parent ID. */
568
- $parent_id = $parent->parent;
569
- }
570
-
571
- /* If we have parent terms, reverse the array to put them in the proper order for the trail. */
572
- if ( !empty( $parents ) )
573
- $trail = array_reverse( $parents );
574
-
575
- /* Return the trail of parent terms. */
576
- return $trail;
577
- }
578
-
579
- /**
580
- * Returns the textdomain used by the script and allows it to be filtered by plugins/themes.
581
- *
582
- * @since 0.4.0
583
- * @returns string The textdomain for the script.
584
- */
585
- function breadcrumb_trail_textdomain() {
586
- return apply_filters( 'breadcrumb_trail_textdomain', 'breadcrumb-trail' );
587
- }
588
 
589
- ?>
 
1
  <?php
2
  /**
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.0
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
9
  */
10
 
11
+ /* Extra check in case the script is being loaded by a theme. */
12
+ if ( !function_exists( 'breadcrumb_trail' ) )
13
+ require_once( 'inc/breadcrumbs.php' );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
14
 
15
+ /* Load translation files. Note: Remove this line if packaging with a theme. */
16
+ load_plugin_textdomain( 'breadcrumb-trail', false, 'breadcrumb-trail/languages' );
breadcrumb-trail.pot DELETED
@@ -1,76 +0,0 @@
1
- msgid ""
2
- msgstr ""
3
- "Project-Id-Version: Breadcrumb Trail WordPress Plugin\n"
4
- "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2010-10-24 09:26-0600\n"
6
- "PO-Revision-Date: \n"
7
- "Last-Translator: Justin Tadlock <justin@justintadlock.com>\n"
8
- "Language-Team: <justin@justintadlock.com>\n"
9
- "MIME-Version: 1.0\n"
10
- "Content-Type: text/plain; charset=UTF-8\n"
11
- "Content-Transfer-Encoding: 8bit\n"
12
- "X-Poedit-Language: English\n"
13
- "X-Poedit-Country: UNITED STATES\n"
14
- "X-Poedit-KeywordsList: _e;__;esc_attr_e;esc_attr__;esc_html_e;esc_html__\n"
15
- "X-Poedit-Basepath: .\n"
16
- "X-Poedit-SearchPath-0: .\n"
17
-
18
- #: breadcrumb-trail.php:55
19
- msgid "Browse:"
20
- msgstr ""
21
-
22
- #: breadcrumb-trail.php:58
23
- msgid "Home"
24
- msgstr ""
25
-
26
- #: breadcrumb-trail.php:219
27
- msgid "g:i a"
28
- msgstr ""
29
-
30
- #: breadcrumb-trail.php:222
31
- #, php-format
32
- msgid "Minute %1$s"
33
- msgstr ""
34
-
35
- #: breadcrumb-trail.php:222
36
- msgid "i"
37
- msgstr ""
38
-
39
- #: breadcrumb-trail.php:225
40
- msgid "g a"
41
- msgstr ""
42
-
43
- #: breadcrumb-trail.php:236
44
- #: breadcrumb-trail.php:242
45
- #: breadcrumb-trail.php:247
46
- #: breadcrumb-trail.php:252
47
- msgid "Y"
48
- msgstr ""
49
-
50
- #: breadcrumb-trail.php:237
51
- #: breadcrumb-trail.php:248
52
- msgid "F"
53
- msgstr ""
54
-
55
- #: breadcrumb-trail.php:238
56
- msgid "j"
57
- msgstr ""
58
-
59
- #: breadcrumb-trail.php:243
60
- #, php-format
61
- msgid "Week %1$s"
62
- msgstr ""
63
-
64
- #: breadcrumb-trail.php:243
65
- msgid "W"
66
- msgstr ""
67
-
68
- #: breadcrumb-trail.php:259
69
- #, php-format
70
- msgid "Search results for &quot;%1$s&quot;"
71
- msgstr ""
72
-
73
- #: breadcrumb-trail.php:263
74
- msgid "404 Not Found"
75
- msgstr ""
76
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
inc/breadcrumbs.php ADDED
@@ -0,0 +1,1217 @@