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 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
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.0
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
30
+ * @access public
31
+ * @param array $args Arguments to pass to Breadcrumb_Trail.
32
+ * @return void
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
+ $breadcrumb->trail();
42
+ }
43
+
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
+
51
+ /**
52
+ * Array of items belonging to the current breadcrumb trail.
53
+ *
54
+ * @since 0.1.0
55
+ * @access public
56
+ * @var array
57
+ */
58
+ public $items = array();
59
+
60
+ /**
61
+ * Arguments used to build the breadcrumb trail.
62
+ *
63
+ * @since 0.1.0
64
+ * @access public
65
+ * @var array
66
+ */
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
117
+ * @return string
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
+ /* Open the breadcrumb trail containers. */
127
+ $breadcrumb = "\n\t\t" . '<' . tag_escape( $this->args['container'] ) . ' class="breadcrumb-trail breadcrumbs" itemprop="breadcrumb">';
128
+
129
+ /* If $before was set, wrap it in a container. */
130
+ $breadcrumb .= ( !empty( $this->args['before'] ) ? "\n\t\t\t" . '<span class="trail-before">' . $this->args['before'] . '</span> ' . "\n\t\t\t" : '' );
131
+
132
+ /* Add 'browse' label if it should be shown. */
133
+ if ( true === $this->args['show_browse'] )
134
+ $breadcrumb .= "\n\t\t\t" . '<span class="trail-browse">' . $this->args['labels']['browse'] . '</span> ';
135
+
136
+ /* Adds the 'trail-begin' class around first item if there's more than one item. */
137
+ if ( 1 < count( $this->items ) )
138
+ array_unshift( $this->items, '<span class="trail-begin">' . array_shift( $this->items ) . '</span>' );
139
+
140
+ /* Adds the 'trail-end' class around last item. */
141
+ array_push( $this->items, '<span class="trail-end">' . array_pop( $this->items ) . '</span>' );
142
+
143
+ /* Format the separator. */
144
+ $separator = ( !empty( $this->args['separator'] ) ? '<span class="sep">' . $this->args['separator'] . '</span>' : '<span class="sep">/</span>' );
145
+
146
+ /* Join the individual trail items into a single string. */
147
+ $breadcrumb .= join( "\n\t\t\t {$separator} ", $this->items );
148
+
149
+ /* If $after was set, wrap it in a container. */
150
+ $breadcrumb .= ( !empty( $this->args['after'] ) ? "\n\t\t\t" . ' <span class="trail-after">' . $this->args['after'] . '</span>' : '' );
151
+
152
+ /* Close the breadcrumb trail containers. */
153
+ $breadcrumb .= "\n\t\t" . '</' . tag_escape( $this->args['container'] ) . '>';
154
+ }
155
+
156
+ /* Allow developers to filter the breadcrumb trail HTML. */
157
+ $breadcrumb = apply_filters( 'breadcrumb_trail', $breadcrumb, $this->args );
158
+
159
+ if ( true === $this->args['echo'] )
160
+ echo $breadcrumb;
161
+ else
162
+ return $breadcrumb;
163
+ }
164
+
165
+ /**
166
+ * Returns an array of the default labels.
167
+ *
168
+ * @since 0.6.0
169
+ * @access public
170
+ * @return array
171
+ */
172
+ public function default_labels() {
173
+
174
+ $labels = array(
175
+ 'browse' => __( 'Browse:', 'breadcrumb-trail' ),
176
+ 'home' => __( 'Home', 'breadcrumb-trail' ),
177
+ 'search' => __( 'Search results for "%s"', 'breadcrumb-trail' ),
178
+ 'error_404' => __( '404 Not Found', 'breadcrumb-trail' ),
179
+ 'paged' => __( 'Page %d', 'breadcrumb-trail' ),
180
+ 'archives' => __( 'Archives', 'breadcrumb-trail' ),
181
+ 'archive_minute_hour' => __( 'g:i a', 'breadcrumb-trail' ),
182
+ 'archive_minute' => __( 'Minute %d', 'breadcrumb-trail' ),
183
+ 'archive_hour' => __( 'g a', 'breadcrumb-trail' ),
184
+ 'archive_day' => __( 'd', 'breadcrumb-trail' ),
185
+ 'archive_week' => __( 'Week %d', 'breadcrumb-trail' ),
186
+ 'archive_month' => __( 'F', 'breadcrumb-trail' ),
187
+ 'archive_year' => __( 'Y', 'breadcrumb-trail' ),
188
+ // 'edit' => __( 'Edit', 'breadcrumb-trail' ), // @todo Implement edit link
189
+ );
190
+
191
+ return $labels;
192
+ }
193
+
194
+ /**
195
+ * Runs through the various WordPress conditional tags to check the current page being viewed. Once
196
+ * a condition is met, a specific method is launched to add items to the $items array.
197
+ *
198
+ * @since 0.6.0
199
+ * @access public
200
+ * @return void
201
+ */
202
+ public function do_trail_items() {
203
+
204
+ /* If viewing the front page. */
205
+ if ( is_front_page() ) {
206
+ $this->do_front_page_items();
207
+ }
208
+
209
+ /* If not viewing the front page. */
210
+ else {
211
+
212
+ /* Add the network and site home links. */
213
+ $this->do_network_home_link();
214
+ $this->do_site_home_link();
215
+
216
+ /* If viewing the home/blog page. */
217
+ if ( is_home() ) {
218
+ $this->do_posts_page_items();
219
+ }
220
+
221
+ /* If viewing a single post. */
222
+ elseif ( is_singular() ) {
223
+ $this->do_singular_items();
224
+ }
225
+
226
+ /* If viewing an archive page. */
227
+ elseif ( is_archive() ) {
228
+
229
+ if ( is_post_type_archive() )
230
+ $this->do_post_type_archive_items();
231
+
232
+ elseif ( is_category() || is_tag() || is_tax() )
233
+ $this->do_term_archive_items();
234
+
235
+ elseif ( is_author() )
236
+ $this->do_user_archive_items();
237
+
238
+ elseif ( get_query_var( 'minute' ) && get_query_var( 'hour' ) )
239
+ $this->do_minute_hour_archive_items();
240
+
241
+ elseif ( get_query_var( 'minute' ) )
242
+ $this->do_minute_archive_items();
243
+
244
+ elseif ( get_query_var( 'hour' ) )
245
+ $this->do_hour_archive_items();
246
+
247
+ elseif ( is_day() )
248
+ $this->do_day_archive_items();
249
+
250
+ elseif ( get_query_var( 'w' ) )
251
+ $this->do_week_archive_items();
252
+
253
+ elseif ( is_month() )
254
+ $this->do_month_archive_items();
255
+
256
+ elseif ( is_year() )
257
+ $this->do_year_archive_items();
258
+
259
+ else
260
+ $this->do_default_archive_items();
261
+ }
262
+
263
+ /* If viewing a search results page. */
264
+ elseif ( is_search() ) {
265
+ $this->do_search_items();
266
+ }
267
+
268
+ /* If viewing the 404 page. */
269
+ elseif ( is_404() ) {
270
+ $this->do_404_items();
271
+ }
272
+ }
273
+
274
+ /* Add paged items if they exist. */
275
+ $this->do_paged_items();
276
+
277
+ /* Allow developers to overwrite the items for the breadcrumb trail. */
278
+ $this->items = apply_filters( 'breadcrumb_trail_items', $this->items, $this->args );
279
+ }
280
+
281
+ /**
282
+ * Gets front items based on $wp_rewrite->front.
283
+ *
284
+ * @since 0.6.0
285
+ * @access public
286
+ * @return void
287
+ */
288
+ public function do_rewrite_front_items() {
289
+ global $wp_rewrite;
290
+
291
+ if ( $wp_rewrite->front )
292
+ $this->do_path_parents( $wp_rewrite->front );
293
+ }
294
+
295
+ /**
296
+ * Adds the page/paged number to the items array.
297
+ *
298
+ * @since 0.6.0
299
+ * @access public
300
+ * @return void
301
+ */
302
+ public function do_paged_items() {
303
+
304
+ /* If viewing a paged singular post. */
305
+ if ( is_singular() && 1 < get_query_var( 'page' ) && true === $this->args['show_title'] )
306
+ $this->items[] = sprintf( $this->args['labels']['paged'], absint( get_query_var( 'page' ) ) );
307
+
308
+ /* If viewing a paged archive-type page. */
309
+ elseif ( is_paged() && true === $this->args['show_title'] )
310
+ $this->items[] = sprintf( $this->args['labels']['paged'], absint( get_query_var( 'paged' ) ) );
311
+
312
+ }
313
+
314
+ /**
315
+ * Adds the network (all sites) home page link to the items array.
316
+ *
317
+ * @since 0.6.0
318
+ * @access public
319
+ * @return void
320
+ */
321
+ public function do_network_home_link() {
322
+ if ( is_multisite() && !is_main_site() && true === $this->args['network'] )
323
+ $this->items[] = '<a href="' . network_home_url() . '" title="' . esc_attr( $this->args['labels']['home'] ) . '">' . $this->args['labels']['home'] . '</a>';
324
+ }
325
+
326
+ /**
327
+ * Adds the current site's home page link to the items array.
328
+ *
329
+ * @since 0.6.0
330
+ * @access public
331
+ * @return void
332
+ */
333
+ public function do_site_home_link() {
334
+ $label = ( is_multisite() && !is_main_site() && true === $this->args['network'] ) ? get_bloginfo( 'name' ) : $this->args['labels']['home'];
335
+ $this->items[] = '<a href="' . home_url() . '" title="' . esc_attr( get_bloginfo( 'name' ) ) . '">' . $label . '</a>';
336
+ }
337
+
338
+ /**
339
+ * Adds items for the front page to the items array.
340
+ *
341
+ * @since 0.6.0
342
+ * @access public
343
+ * @return void
344
+ */
345
+ public function do_front_page_items() {
346
+
347
+ /* Only show front items if the 'show_on_front' argument is set to 'true'. */
348
+ if ( true === $this->args['show_on_front'] ) {
349
+
350
+ /* If on a paged view, add the home link items. */
351
+ if ( is_paged() ) {
352
+ $this->do_network_home_link();
353
+ $this->do_site_home_link();
354
+ }
355
+
356
+ /* If on the main front page, add the network home link item and the home item. */
357
+ else {
358
+ $this->do_network_home_link();
359
+
360
+ if ( true === $this->args['show_title'] )
361
+ $this->items[] = ( is_multisite() && true === $this->args['network'] ) ? get_bloginfo( 'name' ) : $this->args['labels']['home'];
362
+ }
363
+ }
364
+ }
365
+
366
+ /**
367
+ * Adds items for the posts page (i.e., is_home()) to the items array.
368
+ *
369
+ * @since 0.6.0
370
+ * @access public
371
+ * @return void
372
+ */
373
+ public function do_posts_page_items() {
374
+
375
+ /* Get the post ID and post. */
376
+ $post_id = get_queried_object_id();
377
+ $post = get_page( $post_id );
378
+
379
+ /* If the post has parents, add them to the trail. */
380
+ if ( 0 < $post->post_parent )
381
+ $this->do_post_parents( $post->post_parent );
382
+
383
+ /* Get the page title. */
384
+ $title = get_the_title( $post_id );
385
+
386
+ /* Add the posts page item. */
387
+ if ( is_paged() )
388
+ $this->items[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( $title ) . '">' . $title . '</a>';
389
+
390
+ elseif ( $title && true === $this->args['show_title'] )
391
+ $this->items[] = $title;
392
+ }
393
+
394
+ /**
395
+ * Adds singular post items to the items array.
396
+ *
397
+ * @since 0.6.0
398
+ * @access public
399
+ * @return void
400
+ */
401
+ public function do_singular_items() {
402
+
403
+ /* Get the queried post. */
404
+ $post = get_queried_object();
405
+ $post_id = get_queried_object_id();
406
+
407
+ /* If the post has a parent, follow the parent trail. */
408
+ if ( 0 < $post->post_parent )
409
+ $this->do_post_parents( $post->post_parent );
410
+
411
+ /* If the post doesn't have a parent, get its hierarchy based off the post type. */
412
+ else
413
+ $this->do_post_hierarchy( $post_id );
414
+
415
+ /* Display terms for specific post type taxonomy if requested. */
416
+ $this->do_post_terms( $post_id );
417
+
418
+ /* End with the post title. */
419
+ if ( $post_title = single_post_title( '', false ) ) {
420
+
421
+ if ( 1 < get_query_var( 'page' ) )
422
+ $this->items[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( $post_title ) . '">' . $post_title . '</a>';
423
+
424
+ elseif ( true === $this->args['show_title'] )
425
+ $this->items[] = $post_title;
426
+ }
427
+ }
428
+
429
+ /**
430
+ * Adds a specific post's parents to the items array.
431
+ *
432
+ * @since 0.6.0
433
+ * @access public
434
+ * @param int $post_id The ID of the post to get the parents of.
435
+ * @return void
436
+ */
437
+ public function do_post_parents( $post_id ) {
438
+ $parents = array();
439
+
440
+ while ( $post_id ) {
441
+
442
+ /* Get the post by ID. */
443
+ $post = get_post( $post_id );
444
+
445
+ /* Add the formatted post link to the array of parents. */
446
+ $parents[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . get_the_title( $post_id ) . '</a>';
447
+
448
+ /* If there's no longer a post parent, brea out of the loop. */
449
+ if ( 0 >= $post->post_parent )
450
+ break;
451
+
452
+ /* Change the post ID to the parent post to continue looping. */
453
+ $post_id = $post->post_parent;
454
+ }
455
+
456
+ /* Get the post hierarchy based off the final parent post. */
457
+ $this->do_post_hierarchy( $post_id );
458
+
459
+ /* Merge the parent items into the items array. */
460
+ $this->items = array_merge( $this->items, array_reverse( $parents ) );
461
+ }
462
+
463
+ /**
464
+ * Adds a post's terms from a specific taxonomy to the items array.
465
+ *
466
+ * @since 0.6.0
467
+ * @access public
468
+ * @param int $post_id The ID of the post to get the terms for.
469
+ * @return void
470
+ */
471
+ public function do_post_terms( $post_id ) {
472
+
473
+ /* Get the post type. */
474
+ $post_type = get_post_type( $post_id );
475
+
476
+ /* Add the terms of the taxonomy for this post. */
477
+ if ( !empty( $this->args['post_taxonomy'][ $post_type ] ) )
478
+ $this->items[] = get_the_term_list( $post_id, $this->args['post_taxonomy'][ $post_type ], '', ', ', '' );
479
+ }
480
+
481
+ /**
482
+ * Adds a specific post's hierarchy to the items array. The hierarchy is determined by post type's
483
+ * rewrite arguments and whether it has an archive page.
484
+ *
485
+ * @since 0.6.0
486
+ * @access public
487
+ * @param int $post_id The ID of the post to get the hierarchy for.
488
+ * @return void
489
+ */
490
+ public function do_post_hierarchy( $post_id ) {
491
+
492
+ /* Get the post type. */
493
+ $post_type = get_post_type( $post_id );
494
+ $post_type_object = get_post_type_object( $post_type );
495
+
496
+ /* If this is the 'post' post type, get the rewrite front items and map the rewrite tags. */
497
+ if ( 'post' === $post_type ) {
498
+
499
+ /* Add $wp_rewrite->front to the trail. */
500
+ $this->do_rewrite_front_items();
501
+
502
+ /* Map the rewrite tags. */
503
+ $this->map_rewrite_tags( $post_id, get_option( 'permalink_structure' ) );
504
+ }
505
+
506
+ /* If the post type has rewrite rules. */
507
+ elseif ( false !== $post_type_object->rewrite ) {
508
+
509
+ /* If 'with_front' is true, add $wp_rewrite->front to the trail. */
510
+ if ( $post_type_object->rewrite['with_front'] )
511
+ $this->do_rewrite_front_items();
512
+
513
+ /* If there's a path, check for parents. */
514
+ if ( !empty( $post_type_object->rewrite['slug'] ) )
515
+ $this->do_path_parents( $post_type_object->rewrite['slug'] );
516
+ }
517
+
518
+ /* If there's an archive page, add it to the trail. */
519
+ if ( !empty( $post_type_object->has_archive ) ) {
520
+
521
+ /* Add support for a non-standard label of 'archive_title' (special use case). */
522
+ $label = !empty( $post_type_object->labels->archive_title ) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
523
+
524
+ $this->items[] = '<a href="' . get_post_type_archive_link( $post_type ) . '" title="' . esc_attr( $label ) . '">' . $label . '</a>';
525
+ }
526
+ }
527
+
528
+ /**
529
+ * Gets post types by slug. This is needed because the get_post_types() function doesn't exactly
530
+ * match the 'has_archive' argument when it's set as a string instead of a boolean.
531
+ *
532
+ * @since 0.6.0
533
+ * @access public
534
+ * @param int $slug The post type archive slug to search for.
535
+ * @return void
536
+ */
537
+ public function get_post_types_by_slug( $slug ) {
538
+
539
+ $return = array();
540
+
541
+ $post_types = get_post_types( array(), 'objects' );
542
+
543
+ foreach ( $post_types as $type ) {
544
+
545
+ if ( $slug === $type->has_archive || ( true === $type->has_archive && $slug === $type->rewrite['slug'] ) )
546
+ $return[] = $type;
547
+ }
548
+
549
+ return $return;
550
+ }
551
+
552
+ /**
553
+ * Adds the items to the trail items array for taxonomy term archives.
554
+ *
555
+ * @since 0.6.0
556
+ * @access public
557
+ * @global object $wp_rewrite
558
+ * @return void
559
+ */
560
+ public function do_term_archive_items() {
561
+ global $wp_rewrite;
562
+
563
+ /* Get some taxonomy and term variables. */
564
+ $term = get_queried_object();
565
+ $taxonomy = get_taxonomy( $term->taxonomy );
566
+
567
+ /* If there are rewrite rules for the taxonomy. */
568
+ if ( false !== $taxonomy->rewrite ) {
569
+
570
+ /* If 'with_front' is true, dd $wp_rewrite->front to the trail. */
571
+ if ( $taxonomy->rewrite['with_front'] && $wp_rewrite->front )
572
+ $this->do_rewrite_front_items();
573
+
574
+ /* Get parent pages by path if they exist. */
575
+ $this->do_path_parents( $taxonomy->rewrite['slug'] );
576
+
577
+ /* Add post type archive if its 'has_archive' matches the taxonomy rewrite 'slug'. */
578
+ if ( $taxonomy->rewrite['slug'] ) {
579
+
580
+ $slug = trim( $taxonomy->rewrite['slug'], '/' );
581
+
582
+ /**
583
+ * Deals with the situation if the slug has a '/' between multiple strings. For
584
+ * example, "movies/genres" where "movies" is the post type archive.
585
+ */
586
+ $matches = explode( '/', $slug );
587
+
588
+ /* If matches are found for the path. */
589
+ if ( isset( $matches ) ) {
590
+
591
+ /* Reverse the array of matches to search for posts in the proper order. */
592
+ $matches = array_reverse( $matches );
593
+
594
+ /* Loop through each of the path matches. */
595
+ foreach ( $matches as $match ) {
596
+
597
+ /* If a match is found. */
598
+ $slug = $match;
599
+
600
+ /* Get public post types that match the rewrite slug. */
601
+ $post_types = $this->get_post_types_by_slug( $match );
602
+
603
+ if ( !empty( $post_types ) ) {
604
+
605
+ $post_type_object = $post_types[0];
606
+
607
+ /* Add support for a non-standard label of 'archive_title' (special use case). */
608
+ $label = !empty( $post_type_object->labels->archive_title ) ? $post_type_object->labels->archive_title : $post_type_object->labels->name;
609
+
610
+ /* Add the post type archive link to the trail. */
611
+ $this->items[] = '<a href="' . get_post_type_archive_link( $post_type_object->name ) . '" title="' . esc_attr( $label ) . '">' . $label . '</a>';
612
+
613
+ /* Break out of the loop. */
614
+ break;
615
+ }
616
+ }
617
+ }
618
+ }
619
+ }
620
+
621
+ /* If the taxonomy is hierarchical, list its parent terms. */
622
+ if ( is_taxonomy_hierarchical( $term->taxonomy ) && $term->parent )
623
+ $this->do_term_parents( $term->parent, $term->taxonomy );
624
+
625
+ /* Add the term name to the trail end. */
626
+ if ( is_paged() )
627
+ $this->items[] = '<a href="' . esc_url( get_term_link( $term, $term->taxonomy ) ) . '" title="' . esc_attr( single_term_title( '', false ) ) . '">' . single_term_title( '', false ) . '</a>';
628
+
629
+ elseif ( true === $this->args['show_title'] )
630
+ $this->items[] = single_term_title( '', false );
631
+ }
632
+
633
+ /**
634
+ * Adds the items to the trail items array for post type archives.
635
+ *
636
+ * @since 0.6.0
637
+ * @access public
638
+ * @return void
639
+ */
640
+ public function do_post_type_archive_items() {
641
+
642
+ /* Get the post type object. */
643
+ $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
644
+
645
+ if ( false !== $post_type_object->rewrite ) {
646
+
647
+ /* If 'with_front' is true, add $wp_rewrite->front to the trail. */
648
+ if ( $post_type_object->rewrite['with_front'] )
649
+ $this->do_rewrite_front_items();
650
+
651
+ /* If there's a rewrite slug, check for parents. */
652
+ if ( !empty( $post_type_object->rewrite['slug'] ) )
653
+ $this->do_path_parents( $post_type_object->rewrite['slug'] );
654
+ }
655
+
656
+ /* Add the post type [plural] name to the trail end. */
657
+ if ( is_paged() )
658
+ $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>';
659
+
660
+ elseif ( true === $this->args['show_title'] )
661
+ $this->items[] = post_type_archive_title( '', false );
662
+ }
663
+
664
+ /**
665
+ * Adds the items to the trail items array for user (author) archives.
666
+ *
667
+ * @since 0.6.0
668
+ * @access public
669
+ * @global object $wp_rewrite
670
+ * @return void
671
+ */
672
+ public function do_user_archive_items() {
673
+ global $wp_rewrite;
674
+
675
+ /* Add $wp_rewrite->front to the trail. */
676
+ $this->do_rewrite_front_items();
677
+
678
+ /* Get the user ID. */
679
+ $user_id = get_query_var( 'author' );
680
+
681
+ /* If $author_base exists, check for parent pages. */
682
+ if ( !empty( $wp_rewrite->author_base ) )
683
+ $this->do_path_parents( $wp_rewrite->author_base );
684
+
685
+ /* Add the author's display name to the trail end. */
686
+ if ( is_paged() )
687
+ $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>';
688
+
689
+ elseif ( true === $this->args['show_title'] )
690
+ $this->items[] = get_the_author_meta( 'display_name', $user_id );
691
+ }
692
+
693
+ /**
694
+ * Adds the items to the trail items array for minute + hour archives.
695
+ *
696
+ * @since 0.6.0
697
+ * @access public
698
+ * @return void
699
+ */
700
+ public function do_minute_hour_archive_items() {
701
+
702
+ /* Add $wp_rewrite->front to the trail. */
703
+ $this->do_rewrite_front_items();
704
+
705
+ /* Add the minute + hour item. */
706
+ if ( true === $this->args['show_title'] )
707
+ $this->items[] = get_the_time( $this->args['labels']['archive_minute_hour'] );
708
+ }
709
+
710
+ /**
711
+ * Adds the items to the trail items array for minute archives.
712
+ *
713
+ * @since 0.6.0
714
+ * @access public
715
+ * @return void
716
+ */
717
+ public function do_minute_archive_items() {
718
+
719
+ /* Add $wp_rewrite->front to the trail. */
720
+ $this->do_rewrite_front_items();
721
+
722
+ /* Add the minute item. */
723
+ if ( true === $this->args['show_title'] )
724
+ $this->items[] = sprintf( $this->args['labels']['archive_minute'], date_i18n( 'i', get_the_time( 'U' ) ) );
725
+ }
726
+
727
+ /**
728
+ * Adds the items to the trail items array for hour archives.
729
+ *
730
+ * @since 0.6.0
731
+ * @access public
732
+ * @return void
733
+ */
734
+ public function do_hour_archive_items() {
735
+
736
+ /* Add $wp_rewrite->front to the trail. */
737
+ $this->do_rewrite_front_items();
738
+
739
+ /* Add the hour item. */
740
+ if ( true === $this->args['show_title'] )
741
+ $this->items[] = get_the_time( $this->args['labels']['archive_hour'] );
742
+ }
743
+
744
+ /**
745
+ * Adds the items to the trail items array for day archives.
746
+ *
747
+ * @since 0.6.0
748
+ * @access public
749
+ * @return void
750
+ */
751
+ public function do_day_archive_items() {
752
+
753
+ /* Add $wp_rewrite->front to the trail. */
754
+ $this->do_rewrite_front_items();
755
+
756
+ /* Get year, month, and day. */
757
+ $year = get_the_time( $this->args['labels']['archive_year'] );
758
+ $month = get_the_time( $this->args['labels']['archive_month'] );
759
+ $day = get_the_time( $this->args['labels']['archive_day'] );
760
+
761
+ /* Add the year and month items. */
762
+ $this->items[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . esc_attr( $year ) . '">' . $year . '</a>';
763
+ $this->items[] = '<a href="' . get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) . '" title="' . esc_attr( $month ) . '">' . $month . '</a>';
764
+
765
+ /* Add the day item. */
766
+ if ( is_paged() )
767
+ $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>';
768
+
769
+ elseif ( true === $this->args['show_title'] )
770
+ $this->items[] = $day;
771
+ }
772
+
773
+ /**
774
+ * Adds the items to the trail items array for week archives.
775
+ *
776
+ * @since 0.6.0
777
+ * @access public
778
+ * @return void
779
+ */
780
+ public function do_week_archive_items() {
781
+
782
+ /* Add $wp_rewrite->front to the trail. */
783
+ $this->do_rewrite_front_items();
784
+
785
+ /* Get the year and week. */
786
+ $year = get_the_time( $this->args['labels']['archive_year'] );
787
+ $week = sprintf( $this->args['labels']['archive_week'], date_i18n( 'W', get_the_time( 'U' ) ) );
788
+
789
+ /* Add the year item. */
790
+ $this->items[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . esc_attr( $year ) . '">' . $year . '</a>';
791
+
792
+ /* Add the week item. */
793
+ if ( is_paged() )
794
+ $this->items[] = get_archives_link( add_query_arg( array( 'm' => get_the_time( 'Y' ), 'w' => get_the_time( 'W' ) ), home_url() ), $week, false );
795
+
796
+ elseif ( true === $this->args['show_title'] )
797
+ $this->items[] = $week;
798
+ }
799
+
800
+ /**
801
+ * Adds the items to the trail items array for month archives.
802
+ *
803
+ * @since 0.6.0
804
+ * @access public
805
+ * @return void
806
+ */
807
+ public function do_month_archive_items() {
808
+
809
+ /* Add $wp_rewrite->front to the trail. */
810
+ $this->do_rewrite_front_items();
811
+
812
+ /* Get the year and month. */
813
+ $year = get_the_time( $this->args['labels']['archive_year'] );
814
+ $month = get_the_time( $this->args['labels']['archive_month'] );
815
+
816
+ /* Add the year item. */
817
+ $this->items[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . esc_attr( $year ) . '">' . $year . '</a>';
818
+
819
+ /* Add the month item. */
820
+ if ( is_paged() )
821
+ $this->items[] = '<a href="' . get_month_link( get_the_time( 'Y' ), get_the_time( 'm' ) ) . '" title="' . esc_attr( $month ) . '">' . $month . '</a>';
822
+
823
+ elseif ( true === $this->args['show_title'] )
824
+ $this->items[] = $month;
825
+ }
826
+
827
+ /**
828
+ * Adds the items to the trail items array for year archives.
829
+ *
830
+ * @since 0.6.0
831
+ * @access public
832
+ * @return void
833
+ */
834
+ public function do_year_archive_items() {
835
+
836
+ /* Add $wp_rewrite->front to the trail. */
837
+ $this->do_rewrite_front_items();
838
+
839
+ /* Get the year. */
840
+ $year = get_the_time( $this->args['labels']['archive_year'] );
841
+
842
+ /* Add the year item. */
843
+ if ( is_paged() )
844
+ $this->items[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . esc_attr( $year ) . '">' . $year . '</a>';
845
+
846
+ elseif ( true === $this->args['show_title'] )
847
+ $this->items[] = $year;
848
+ }
849
+
850
+ /**
851
+ * Adds the items to the trail items array for archives that don't have a more specific method
852
+ * defined in this class.
853
+ *
854
+ * @since 0.6.0
855
+ * @access public
856
+ * @return void
857
+ */
858
+ public function do_default_archive_items() {
859
+
860
+ /* If this is a date-/time-based archive, add $wp_rewrite->front to the trail. */
861
+ if ( is_date() || is_time() )
862
+ $this->do_rewrite_front_items();
863
+
864
+ if ( true === $this->args['show_title'] )
865
+ $this->items[] = $this->args['labels']['archives'];
866
+ }
867
+
868
+ /**
869
+ * Adds the items to the trail items array for search results.
870
+ *
871
+ * @since 0.6.0
872
+ * @access public
873
+ * @return void
874
+ */
875
+ public function do_search_items() {
876
+
877
+ if ( is_paged() )
878
+ $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>';
879
+
880
+ elseif ( true === $this->args['show_title'] )
881
+ $this->items[] = sprintf( $this->args['labels']['search'], get_search_query() );
882
+ }
883
+
884
+ /**
885
+ * Adds the items to the trail items array for 404 pages.
886
+ *
887
+ * @since 0.6.0
888
+ * @access public
889
+ * @return void
890
+ */
891
+ public function do_404_items() {
892
+
893
+ if ( true === $this->args['show_title'] )
894
+ $this->items[] = $this->args['labels']['error_404'];
895
+ }
896
+
897
+ /**
898
+ * Get parent posts by path. Currently, this method only supports getting parents of the 'page'
899
+ * post type. The goal of this function is to create a clear path back to home given what would
900
+ * normally be a "ghost" directory. If any page matches the given path, it'll be added.
901
+ *
902
+ * @since 0.6.0
903
+ * @access public
904
+ * @param string $path The path (slug) to search for posts by.
905
+ * @return void
906
+ */
907
+ function do_path_parents( $path ) {
908
+
909
+ /* Trim '/' off $path in case we just got a simple '/' instead of a real path. */
910
+ $path = trim( $path, '/' );
911
+
912
+ /* If there's no path, return. */
913
+ if ( empty( $path ) )
914
+ return;
915
+
916
+ /* Get parent post by the path. */
917
+ $post = get_page_by_path( $path );
918
+
919
+ if ( !empty( $post ) ) {
920
+ $this->do_post_parents( $post->ID );
921
+ }
922
+
923
+ elseif ( is_null( $post ) ) {
924
+
925
+ /* Separate post names into separate paths by '/'. */
926
+ $path = trim( $path, '/' );
927
+ preg_match_all( "/\/.*?\z/", $path, $matches );
928
+
929
+ /* If matches are found for the path. */
930
+ if ( isset( $matches ) ) {
931
+
932
+ /* Reverse the array of matches to search for posts in the proper order. */
933
+ $matches = array_reverse( $matches );
934
+
935
+ /* Loop through each of the path matches. */
936
+ foreach ( $matches as $match ) {
937
+
938
+ /* If a match is found. */
939
+ if ( isset( $match[0] ) ) {
940
+
941
+ /* Get the parent post by the given path. */
942
+ $path = str_replace( $match[0], '', $path );
943
+ $post = get_page_by_path( trim( $path, '/' ) );
944
+
945
+ /* If a parent post is found, set the $post_id and break out of the loop. */
946
+ if ( !empty( $post ) && 0 < $post->ID ) {
947
+ $this->do_post_parents( $post->ID );
948
+ break;
949
+ }
950
+ }
951
+ }
952
+ }
953
+ }
954
+ }
955
+
956
+ /**
957
+ * Searches for term parents of hierarchical taxonomies. This function is similar to the WordPress
958
+ * function get_category_parents() but handles any type of taxonomy.
959
+ *
960
+ * @since 0.6.0
961
+ * @param int $term_id ID of the term to get the parents of.
962
+ * @param string $taxonomy Name of the taxonomy for the given term.
963
+ * @return void
964
+ */
965
+ function do_term_parents( $term_id, $taxonomy ) {
966
+
967
+ /* Set up some default arrays. */
968
+ $parents = array();
969
+
970
+ /* While there is a parent ID, add the parent term link to the $parents array. */
971
+ while ( $term_id ) {
972
+
973
+ /* Get the parent term. */
974
+ $term = get_term( $term_id, $taxonomy );
975
+
976
+ /* Add the formatted term link to the array of parent terms. */
977
+ $parents[] = '<a href="' . get_term_link( $term, $taxonomy ) . '" title="' . esc_attr( $term->name ) . '">' . $term->name . '</a>';
978
+
979
+ /* Set the parent term's parent as the parent ID. */
980
+ $term_id = $term->parent;
981
+ }
982
+
983
+ /* If we have parent terms, reverse the array to put them in the proper order for the trail. */
984
+ if ( !empty( $parents ) )
985
+ $this->items = array_merge( $this->items, $parents );
986
+ }
987
+
988
+ /**
989
+ * Turns %tag% from permalink structures into usable links for the breadcrumb trail. This feels kind of
990
+ * hackish for now because we're checking for specific %tag% examples and only doing it for the 'post'
991
+ * post type. In the future, maybe it'll handle a wider variety of possibilities, especially for custom post
992
+ * types.
993
+ *
994
+ * @since 0.6.0
995
+ * @access public
996
+ * @param int $post_id ID of the post whose parents we want.
997
+ * @param string $path Path of a potential parent page.
998
+ * @param array $args Mixed arguments for the menu.
999
+ * @return array
1000
+ */
1001
+ public function map_rewrite_tags( $post_id, $path ) {
1002
+
1003
+ /* Get the post based on the post ID. */
1004
+ $post = get_post( $post_id );
1005
+
1006
+ /* If no post is returned, an error is returned, or the post does not have a 'post' post type, return. */
1007
+ if ( empty( $post ) || is_wp_error( $post ) || 'post' !== $post->post_type )
1008
+ return $trail;
1009
+
1010
+ /* Trim '/' from both sides of the $path. */
1011
+ $path = trim( $path, '/' );
1012
+
1013
+ /* Split the $path into an array of strings. */
1014
+ $matches = explode( '/', $path );
1015
+
1016
+ /* If matches are found for the path. */
1017
+ if ( is_array( $matches ) ) {
1018
+
1019
+ /* Loop through each of the matches, adding each to the $trail array. */
1020
+ foreach ( $matches as $match ) {
1021
+
1022
+ /* Trim any '/' from the $match. */
1023
+ $tag = trim( $match, '/' );
1024
+
1025
+ /* If using the %year% tag, add a link to the yearly archive. */
1026
+ if ( '%year%' == $tag )
1027
+ $this->items[] = '<a href="' . get_year_link( get_the_time( 'Y', $post_id ) ) . '" title="' . get_the_time( __( 'Y', 'breadcrumb-trail' ), $post_id ) . '">' . get_the_time( $this->args['labels']['archive_year'], $post_id ) . '</a>';
1028
+
1029
+ /* If using the %monthnum% tag, add a link to the monthly archive. */
1030
+ elseif ( '%monthnum%' == $tag )
1031
+ $this->items[] = '<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', 'breadcrumb-trail' ), $post_id ) . '">' . get_the_time( $this->args['labels']['archive_month'], $post_id ) . '</a>';
1032
+
1033
+ /* If using the %day% tag, add a link to the daily archive. */
1034
+ elseif ( '%day%' == $tag )
1035
+ $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 ) ) . '" title="' . get_the_time( esc_attr__( 'F j, Y', 'breadcrumb-trail' ), $post_id ) . '">' . get_the_time( $this->args['labels']['archive_day'], $post_id ) . '</a>';
1036
+
1037
+ /* If using the %author% tag, add a link to the post author archive. */
1038
+ elseif ( '%author%' == $tag )
1039
+ $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>';
1040
+
1041
+ /* If using the %category% tag, add a link to the first category archive to match permalinks. */
1042
+ elseif ( '%category%' == $tag ) {
1043
+
1044
+ /* Force override terms in this post type. */
1045
+ $this->args['post_taxonomy'][ $post->post_type ] = false;
1046
+
1047
+ /* Get the post categories. */
1048
+ $terms = get_the_category( $post_id );
1049
+
1050
+ /* Check that categories were returned. */
1051
+ if ( $terms ) {
1052
+
1053
+ /* Sort the terms by ID and get the first category. */
1054
+ usort( $terms, '_usort_terms_by_ID' );
1055
+ $term = get_term( $terms[0], 'category' );
1056
+
1057
+ /* If the category has a parent, add the hierarchy to the trail. */
1058
+ if ( 0 < $term->parent )
1059
+ $this->do_term_parents( $term->parent, 'category' );
1060
+
1061
+ /* Add the category archive link to the trail. */
1062
+ $this->items[] = '<a href="' . get_term_link( $term, 'category' ) . '" title="' . esc_attr( $term->name ) . '">' . $term->name . '</a>';
1063
+ }
1064
+ }
1065
+ }
1066
+ }
1067
+ }
1068
+ }
1069
+
1070
+ /**
1071
+ * Extends the Breadcrumb_Trail class for bbPress. Only use this if bbPress is in use. This should
1072
+ * serve as an example for other plugin developers to build custom breadcrumb items.
1073
+ *
1074
+ * @since 0.6.0
1075
+ * @access public
1076
+ */
1077
+ class bbPress_Breadcrumb_Trail extends Breadcrumb_Trail {
1078
+
1079
+ /**
1080
+ * Runs through the various bbPress conditional tags to check the current page being viewed. Once
1081
+ * a condition is met, add items to the $items array.
1082
+ *
1083
+ * @since 0.6.0
1084
+ * @access public
1085
+ * @return void
1086
+ */
1087
+ public function do_trail_items() {
1088
+
1089
+ /* Get the forum post type object. */
1090
+ $post_type_object = get_post_type_object( bbp_get_forum_post_type() );
1091
+
1092
+ /* If not viewing the forum root/archive page and a forum archive exists, add it. */
1093
+ if ( !empty( $post_type_object->has_archive ) && !bbp_is_forum_archive() )
1094
+ $this->items[] = '<a href="' . get_post_type_archive_link( bbp_get_forum_post_type() ) . '">' . bbp_get_forum_archive_title() . '</a>';
1095
+
1096
+ /* If viewing the forum root/archive. */
1097
+ if ( bbp_is_forum_archive() ) {
1098
+
1099
+ if ( true === $this->args['show_title'] )
1100
+ $this->items[] = bbp_get_forum_archive_title();
1101
+ }
1102
+
1103
+ /* If viewing the topics archive. */
1104
+ elseif ( bbp_is_topic_archive() ) {
1105
+
1106
+ if ( true === $this->args['show_title'] )
1107
+ $this->items[] = bbp_get_topic_archive_title();
1108
+ }
1109
+
1110
+ /* If viewing a topic tag archive. */
1111
+ elseif ( bbp_is_topic_tag() ) {
1112
+
1113
+ if ( true === $this->args['show_title'] )
1114
+ $this->items[] = bbp_get_topic_tag_name();
1115
+ }
1116
+
1117
+ /* If viewing a topic tag edit page. */
1118
+ elseif ( bbp_is_topic_tag_edit() ) {
1119
+ $this->items[] = '<a href="' . bbp_get_topic_tag_link() . '">' . bbp_get_topic_tag_name() . '</a>';
1120
+
1121
+ if ( true === $this->args['show_title'] )
1122
+ $this->items[] = __( 'Edit', 'breadcrumb-trail' );
1123
+ }
1124
+
1125
+ /* If viewing a "view" page. */
1126
+ elseif ( bbp_is_single_view() ) {
1127
+
1128
+ if ( true === $this->args['show_title'] )
1129
+ $this->items[] = bbp_get_view_title();
1130
+ }
1131
+
1132
+ /* If viewing a single topic page. */
1133
+ elseif ( bbp_is_single_topic() ) {
1134
+
1135
+ /* Get the queried topic. */
1136
+ $topic_id = get_queried_object_id();
1137
+
1138
+ /* Get the parent items for the topic, which would be its forum (and possibly forum grandparents). */
1139
+ $this->do_post_parents( bbp_get_topic_forum_id( $topic_id ) );
1140
+
1141
+ /* If viewing a split, merge, or edit topic page, show the link back to the topic. Else, display topic title. */
1142
+ if ( bbp_is_topic_split() || bbp_is_topic_merge() || bbp_is_topic_edit() )
1143
+ $this->items[] = '<a href="' . bbp_get_topic_permalink( $topic_id ) . '">' . bbp_get_topic_title( $topic_id ) . '</a>';
1144
+
1145
+ elseif ( true === $this->args['show_title'] )
1146
+ $this->items[] = bbp_get_topic_title( $topic_id );
1147
+
1148
+ /* If viewing a topic split page. */
1149
+ if ( bbp_is_topic_split() && true === $this->args['show_title'] )
1150
+ $this->items[] = __( 'Split', 'breadcrumb-trail' );
1151
+
1152
+ /* If viewing a topic merge page. */
1153
+ elseif ( bbp_is_topic_merge() && true === $this->args['show_title'] )
1154
+ $this->items[] = __( 'Merge', 'breadcrumb-trail' );
1155
+
1156
+ /* If viewing a topic edit page. */
1157
+ elseif ( bbp_is_topic_edit() && true === $this->args['show_title'] )
1158
+ $this->items[] = __( 'Edit', 'breadcrumb-trail' );
1159
+ }
1160
+
1161
+ /* If viewing a single reply page. */
1162
+ elseif ( bbp_is_single_reply() ) {
1163
+
1164
+ /* Get the queried reply object ID. */
1165
+ $reply_id = get_queried_object_id();
1166
+
1167
+ /* Get the parent items for the reply, which should be its topic. */
1168
+ $this->do_post_parents( bbp_get_reply_topic_id( $reply_id ) );
1169
+
1170
+ /* If viewing a reply edit page, link back to the reply. Else, display the reply title. */
1171
+ if ( bbp_is_reply_edit() ) {
1172
+ $this->items[] = '<a href="' . bbp_get_reply_url( $reply_id ) . '">' . bbp_get_reply_title( $reply_id ) . '</a>';
1173
+
1174
+ if ( true === $this->args['show_title'] )
1175
+ $this->items[] = __( 'Edit', 'breadcrumb-trail' );
1176
+
1177
+ } elseif ( true === $this->args['show_title'] ) {
1178
+ $this->items[] = bbp_get_reply_title( $reply_id );
1179
+ }
1180
+
1181
+ }
1182
+
1183
+ /* If viewing a single forum. */
1184
+ elseif ( bbp_is_single_forum() ) {
1185
+
1186
+ /* Get the queried forum ID and its parent forum ID. */
1187
+ $forum_id = get_queried_object_id();
1188
+ $forum_parent_id = bbp_get_forum_parent_id( $forum_id );
1189
+
1190
+ /* If the forum has a parent forum, get its parent(s). */
1191
+ if ( 0 !== $forum_parent_id)
1192
+ $this->do_post_parents( $forum_parent_id );
1193
+
1194
+ /* Add the forum title to the end of the trail. */
1195
+ if ( true === $this->args['show_title'] )
1196
+ $this->items[] = bbp_get_forum_title( $forum_id );
1197
+ }
1198
+
1199
+ /* If viewing a user page or user edit page. */
1200
+ elseif ( bbp_is_single_user() || bbp_is_single_user_edit() ) {
1201
+
1202
+ if ( bbp_is_single_user_edit() ) {
1203
+ $this->items[] = '<a href="' . bbp_get_user_profile_url() . '">' . bbp_get_displayed_user_field( 'display_name' ) . '</a>';
1204
+
1205
+ if ( true === $this->args['show_title'] )
1206
+ $this->items[] = __( 'Edit', 'breadcrumb-trail' );
1207
+ } elseif ( true === $this->args['show_title'] ) {
1208
+ $this->items[] = bbp_get_displayed_user_field( 'display_name' );
1209
+ }
1210
+ }
1211
+
1212
+ /* Return the bbPress breadcrumb trail items. */
1213
+ $this->items = apply_filters( 'breadcrumb_trail_get_bbpress_items', $this->items, $this->args );
1214
+ }
1215
+ }
1216
+
1217
+ ?>
languages/breadcrumb-trail.pot ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ msgid ""
2
+ msgstr ""
3
+ "Project-Id-Version: Breadcrumb Trail WordPress Plugin\n"
4
+ "POT-Creation-Date: 2013-10-01 08:34-0600\n"
5
+ "PO-Revision-Date: 2013-10-01 08:35-0600\n"
6
+ "Last-Translator: \n"
7
+ "Language-Team: <justin@justintadlock.com>\n"
8
+ "Language: en_US\n"
9
+ "MIME-Version: 1.0\n"
10
+ "Content-Type: text/plain; charset=UTF-8\n"
11
+ "Content-Transfer-Encoding: 8bit\n"
12
+ "X-Generator: Poedit 1.5.7\n"
13
+ "X-Poedit-KeywordsList: _e;__;esc_attr_e;esc_attr__;esc_html_e;esc_html__;_n;"
14
+ "_x;_x:1,2c;_n:1,2\n"
15
+ "X-Poedit-Basepath: ../\n"
16
+ "X-Poedit-SearchPath-0: .\n"
17
+
18
+ #: breadcrumb-trail.php:194
19
+ msgid "Browse:"
20
+ msgstr ""
21
+
22
+ #: breadcrumb-trail.php:195
23
+ msgid "Home"
24
+ msgstr ""
25
+
26
+ #: breadcrumb-trail.php:196
27
+ #, php-format
28
+ msgid "Search results for \"%s\""
29
+ msgstr ""
30
+
31
+ #: breadcrumb-trail.php:197
32
+ msgid "404 Not Found"
33
+ msgstr ""
34
+
35
+ #: breadcrumb-trail.php:198
36
+ #, php-format
37
+ msgid "Page %d"
38
+ msgstr ""
39
+
40
+ #: breadcrumb-trail.php:199
41
+ msgid "Archives"
42
+ msgstr ""
43
+
44
+ #: breadcrumb-trail.php:200
45
+ msgid "g:i a"
46
+ msgstr ""
47
+
48
+ #: breadcrumb-trail.php:201
49
+ #, php-format
50
+ msgid "Minute %d"
51
+ msgstr ""
52
+
53
+ #: breadcrumb-trail.php:202
54
+ msgid "g a"
55
+ msgstr ""
56
+
57
+ #: breadcrumb-trail.php:203
58
+ msgid "d"
59
+ msgstr ""
60
+
61
+ #: breadcrumb-trail.php:204
62
+ #, php-format
63
+ msgid "Week %d"
64
+ msgstr ""
65
+
66
+ #: breadcrumb-trail.php:205
67
+ msgid "F"
68
+ msgstr ""
69
+
70
+ #: breadcrumb-trail.php:206 breadcrumb-trail.php:1046
71
+ msgid "Y"
72
+ msgstr ""
73
+
74
+ #: breadcrumb-trail.php:1050
75
+ msgid "F Y"
76
+ msgstr ""
77
+
78
+ #: breadcrumb-trail.php:1054
79
+ msgid "F j, Y"
80
+ msgstr ""
81
+
82
+ #: breadcrumb-trail.php:1141 breadcrumb-trail.php:1177
83
+ #: breadcrumb-trail.php:1194 breadcrumb-trail.php:1225
84
+ msgid "Edit"
85
+ msgstr ""
86
+
87
+ #: breadcrumb-trail.php:1169
88
+ msgid "Split"
89
+ msgstr ""
90
+
91
+ #: breadcrumb-trail.php:1173
92
+ msgid "Merge"
93
+ msgstr ""
readme.css DELETED
@@ -1,77 +0,0 @@
1
- /* Reset values */
2
- html,body,div,span,object,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,tt,var,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;vertical-align:baseline;outline:none;font-size:100%;background:transparent;border:none;text-decoration:none}b,i,hr,u,center,menu,layer,s,strike,font,xmp{margin:0;padding:0;vertical-align:baseline;outline:none;font-size:100%;font-weight:normal;font-style:normal;background:transparent;border:none;text-decoration:none}font{color:#333}center{text-align:left}body{line-height:25px;font-family:Cambria,Georgia,Times,"Times New Roman",serif;color:#333;background:#fff}h1,h2,h3,h4,h5,h6{font-style:normal;font-weight:normal;margin:0 0 25px 0}h1{font-size:1.8em}h2{font-size:1.7em}h3{font-size:1.55em;}h4{font-size:1.4em}h5{font-size:1.25em}h6{font-size:1.1em}p{margin:0 0 25px 0}ol,ul{list-style:none}ul{list-style:disc;margin:0 0 25px 2.5em}ol{list-style-type:decimal;margin:0 0 25px 3em}ol ol{list-style:upper-roman}ol ol ol{list-style:lower-roman}ol ol ol ol{list-style:upper-alpha}ol ol ol ol ol{list-style:lower-alpha}ul ul,ol ol,ul ol,ol ul{margin-bottom:0}dl{margin:0 0 25px 5px}dl dt{font-weight:bold;margin:10px 0 0 0}dl dd{margin:5px 0 0 1.5em}strong{font-weight:bold}strong strong{font-weight:normal}em,cite{font-style:italic}em em,cite cite{font-style:normal}abbr{cursor:help}acronym{text-transform:uppercase;border-bottom:1px dashed #666;cursor:help}big{font-size:120%}small,sup,sub{font-size:80%}sup{vertical-align:baseline;position:relative;bottom:0.3em}sub{vertical-align:baseline;position:relative;top:0.3em}address{font-style:italic;margin:0 0 25px 0}li address,dd address{margin:0}blockquote{margin:0 25px;font-style:normal}blockquote em,blockquote cite{font-style:italic}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}a{cursor:pointer}a img{border:none}pre{overflow:auto;font:.9em Monaco,monospace,Courier,"Courier New";line-height:25px;margin-bottom:25px;padding:10px}code{font:.9em Monaco,monospace,Courier,"Courier New"}pre code{font-size:1em}ins,dfn{font-style:italic;text-decoration:none;border-bottom:1px solid #666}del{text-decoration:line-through}object{margin-bottom:25px}input,textarea{font-size:1em;font-family:Cambria,Georgia,Times,"Times New Roman",serif;padding:3px}:focus{outline:none}form label{cursor:pointer}option{padding:1px 2px}table{border-collapse:collapse;border-spacing:0;margin-bottom:25px}th,td{text-align:left}hr{margin-bottom:25px}img.wp-smiley{max-height:12px;margin:0;padding:0;border:none}.gallery{display:block;text-align:center;margin-bottom:25px !important}.alignleft,.left{float:left;margin-right:20px}.alignright,.right{float:right;margin-left:20px}.aligncenter,.center{display:block;margin:0 auto 25px auto}.alignnone,.block{clear:both;margin:0 0 25px 0}.clear{clear:both}img.alignleft,img.alignright{display:inline}
3
-
4
- body {
5
- width: 750px;
6
- margin: 36px auto 60px auto;
7
- font: 15px/21px Arial, 'Helvetica Neue', Helvetica, sans-serif;
8
- font: 16px/25px Georgia, Times, 'Times New Roman', serif;
9
- }
10
- /* Links */
11
- a:link, a:visited {
12
- color: #2f6eb9;
13
- text-decoration: none;
14
- }
15
- a:hover, a:active {
16
- text-decoration: underline;
17
- }
18
- /* Headers */
19
- h1, h2, h3, h4, h5, h6 {
20
- margin: 40px 0 30px 0;
21
- color: #000;
22
- font-weight: bold;
23
- font-family: Arial, sans-serif;
24
- }
25
- h3 {
26
- font-weight: normal;
27
- font-style: italic;
28
- font-family: Georgia, Times, 'Times New Roman', serif;
29
- }
30
- h1 {
31
- margin-top: 80px;
32
- font-size: 2.2em;
33
- }
34
- code {
35
- padding: 0 3px;
36
- background: #eee;
37
- }
38
- pre code {
39
- padding: 0;
40
- }
41
- pre {
42
- padding: 9px;
43
- background: #eee;
44
- border: 1px solid #ccc;
45
- }
46
- ul {
47
- list-style: square;
48
- }
49
- p.first {
50
- font-size: 21px;
51
- }
52
- p.second {
53
- font-size: 15px;
54
- }
55
- ul.space li {
56
- margin-bottom: 10px;
57
- }
58
- .section {
59
- overflow: hidden;
60
- }
61
-
62
- .columns-2 {
63
- float: left;
64
- width: 350px;
65
- margin: 0 0 21px 25px;
66
- }
67
- .columns-3 {
68
- float: left;
69
- width: 230px;
70
- margin: 0 0 21px 20px;
71
- }
72
- /* Warnings/Alerts */
73
- .warning, .alert {
74
- padding: 6px 9px;
75
- background: #fffbbc;
76
- border: 1px solid #E6DB55;
77
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.html DELETED
@@ -1,140 +0,0 @@
1
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
2
- <html xmlns="http://www.w3.org/1999/xhtml">
3
- <head>
4
- <meta http-equiv="Content-Type" content="text/html;charset=utf-8"/>
5
- <title>A guide to the Breadcrumb Trail plugin</title>
6
-
7
- <link rel="stylesheet" href="readme.css" type="text/css" media="screen" />
8
-
9
- </head>
10
- <body>
11
-
12
- <h1>A guide to Breadcrumb Trail</h1>
13
-
14
- <p class="first"><em>Breadcrumb Trail</em> is a plugin that displays a breadcrumb menu on your site. Plain and simple.</p>
15
-
16
- <p class="second">How is it any better than any other breadcrumb plugin? Well, it's probably not, to be perfectly honest. This is just a script I've been building upon for several years that I usually include with my WordPress themes. I figured I'd package it as a plugin for others to use as well.</p>
17
-
18
- <h2>How to install the plugin</h2>
19
-
20
- <ol>
21
- <li>Uzip the <code>breadcrumb-trail.zip</code> folder.</li>
22
- <li>Upload the <code>breadcrumb-trail</code> folder to your <code>/wp-content/plugins</code> directory.</li>
23
- <li>In your WordPress dashboard, head over to the <em>Plugins</em> section.</li>
24
- <li>Activate <em>Breadcrumb Trail</em>.</li>
25
- </ol>
26
-
27
- <h2>How to use the plugin</h2>
28
-
29
- <p>This plugin won't work automatically because there's no way for me to know where it should show within your theme. So, you'll have to add it manually in your template files. <em>Where?</em> Well, that's really up to you. You can add it pretty much anywhere you want.</p>
30
-
31
- <p>This is the basic code:</p>
32
-
33
- <pre><code>&lt;?php breadcrumb_trail(); ?></code></pre>
34
-
35
- <h2>The default parameters</h2>
36
-
37
- <p>By default, this plugin is designed to show things a certain way. Here are the defaults:</p>
38
-
39
- <pre><code>$defaults = array(
40
- 'separator' => '/',
41
- 'before' => '&lt;span class="breadcrumb-title">' . __('Browse:', 'breadcrumb_trail') . '&lt;/span>',
42
- 'after' => false,
43
- 'front_page' => true,
44
- 'show_home' => __('Home', 'breadcrumb_trail'),
45
- 'singular_{$post_type}_taxonomy' => false,
46
- 'echo' => true,
47
- );</code></pre>
48
-
49
- <dl>
50
- <dt>separator</dt>
51
- <dd>The element that separates each item in the breadcrumb menu.</dd>
52
- <dt>before</dt>
53
- <dd>What should be shown before the trail.</dd>
54
- <dt>after</dt>
55
- <dd>What should be shown after the trail.</dd>
56
- <dt>show_home</dt>
57
- <dd>The text for the home link. Set to <code>false</code> if no home link is needed.</dd>
58
- <dt>singular_{$post_type}_taxonomy</dt>
59
- <dd>A taxonomy to use as part of the leading trail on singular views of specific post types.</dd>
60
- <dt>echo</dt>
61
- <dd>Whether to print on the screen or return for use in a function.</dd>
62
- </dl>
63
-
64
- <h2>Custom examples</h2>
65
-
66
- <p>Let's change the text before the breadcrumb trail.</p>
67
-
68
- <pre><code>&lt;?php breadcrumb_trail( array( 'before' => 'You are here &amp;raquo;' ) ); ?></code></pre>
69
-
70
- <p>How about we change the separator between each item?</p>
71
-
72
- <pre><code>&lt;?php breadcrumb_trail( array( 'separator' => '&amp;rarr;' ) ); ?></code></pre>
73
-
74
- <p>This time, we'll wrap the entire menu in brackets.</p>
75
-
76
- <pre><code>&lt;?php breadcrumb_trail( array( 'before' => '{', 'after' => '}' ) ); ?></code></pre>
77
-
78
- <p>Now, let's add post tags as part of the trail for singular posts.</p>
79
-
80
- <pre><code>&lt;?php breadcrumb_trail( array( 'singular_post_taxonomy' => 'post_tag' ) ); ?></code></pre>
81
-
82
- <p>Pretty simple stuff, right? Just mix and match the parameters however you want.</p>
83
-
84
- <h2>Protect yourself from errors in the future</h2>
85
-
86
- <p>
87
- Sometimes, we stop using plugins, but we forget to remove the function calls to the plugins in our theme files. When deactivated, this causes errors. To protect yourself from these errors, you can call the breadcrumb trail like this:
88
- </p>
89
-
90
- <pre><code>&lt;?php if ( function_exists( 'breadcrumb_trail' ) ) { breadcrumb_trail(); } ?></code></pre>
91
-
92
- <p>
93
- Basically, this just checks to see if the plugin is activated and has loaded the appropriate function.
94
- </p>
95
-
96
- <h2>Styling your breadcrumb trail</h2>
97
-
98
- <p>
99
- <em>Breadcrumb Trail</em> comes with some extra classes to work with, so you can have a bit of freedom when styling your menu. Here are the <acronym title="Cascading Style Sheets">CSS</acronym> classes for your use:
100
- </p>
101
-
102
- <pre><code>.breadcrumb {
103
- /* This is the outer 'div' you can style */
104
- }
105
-
106
- .breadcrumb-trail {
107
- /* This is the inner 'div' you can style */
108
- }</code></pre>
109
-
110
- <h2>Developer tools</h2>
111
-
112
- <p>If you're a theme developer, you can always add checks for this plugin and place it yourself within your template files or use <code>add_action()</code> to add it to a custom theme hook.</p>
113
-
114
- <p>This plugin has three filter hooks for use as well:</p>
115
-
116
- <dl>
117
- <dt>breadcrumb_trail_args</dt>
118
- <dd>Overwrite the arguments input and/or the defaults.</dd>
119
- <dt>breadcrumb_trail</dt>
120
- <dd>Completely overwrite the entire breadcrumb menu.</dd>
121
- <dt>breadcrumb_trail_items</dt>
122
- <dd>Overwrite or extend the rrray of items shown in the trail.</dd>
123
- </dl>
124
-
125
- <h2>Plugin support</h2>
126
-
127
- <p>I run a WordPress community called <a href="http://themehybrid.com" title="Theme Hybrid">Theme Hybrid</a>, which is where I fully support all of my WordPress projects, including plugins. You can sign up for an account to get plugin support for a small yearly fee ($25 <acronym title="United States Dollars">USD</acronym> at the time of writing).</p>
128
-
129
- <p>I know. I know. You might not want to pay for support, but just consider it a donation to the project. To continue making cool, <acronym title="GNU General Public License">GPL</acronym>-licensed plugins and having the time to support them, I must pay the bills.</p>
130
-
131
- <h2>Copyright &amp; license</h2>
132
-
133
- <p><em>Breadcrumb Trail</em> is licensed under the <a href="http://www.gnu.org/licenses/old-licenses/gpl-2.0.html" title="GNU GPL">GNU General Public License</a>, version 2 (<acronym title="GNU General Public License">GPL</acronym>).</p>
134
-
135
- <p>This plugin is copyrighted to <a href="http://justintadlock.com" title="Justin Tadlock">Justin Tadlock</a>.</p>
136
-
137
- <p>2008&thinsp;&ndash;&thinsp;2011 &copy; Justin Tadlock. All rights reserved.</p>
138
-
139
- </body>
140
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
readme.md ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Breadcrumb Trail #
2
+
3
+ A powerful script for adding breadcrumbs to your site that supports Schema.org, HTML5-valid microdata.
4
+
5
+ Breadcrumb Trail is one of the most advanced and robust breadcrumb menu systems available for WordPress. It started out as a small script for basic blogs but has grown into a system that can handle nearly any site's setup to show the most accurate breadcrumbs for each page.
6
+
7
+ ## Usage ##
8
+
9
+ This script won't work automatically because there's no way for me to know where it should show within your theme. You'll have to add it manually in your template files. You can add it pretty much anywhere you want, but I usually recommend near the bottom of your theme's `header.php` template.
10
+
11
+ The basic code you need is:
12
+
13
+ <?php breadcrumb_trail(); ?>
14
+
15
+ Actually, you should always wrap it in a `functions_exists()` check too like so:
16
+
17
+ <?php if ( function_exists( 'breadcrumb_trail' ) ) breadcrumb_trail(); ?>
18
+
19
+ That's all you need to do to add breadcrumbs to your site. Of course, you can customize that a bit.
20
+
21
+ ### Parameters ###
22
+
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
+ 'search' => __( 'Search results for "%s"', 'breadcrumb-trail' ),
47
+ 'error_404' => __( '404 Not Found', 'breadcrumb-trail' ),
48
+ 'paged' => __( 'Page %d', 'breadcrumb-trail' ),
49
+ 'archives' => __( 'Archives', 'breadcrumb-trail' ),
50
+ 'archive_minute_hour' => __( 'g:i a', 'breadcrumb-trail' ),
51
+ 'archive_minute' => __( 'Minute %d', 'breadcrumb-trail' ),
52
+ 'archive_hour' => __( 'g a', 'breadcrumb-trail' ),
53
+ 'archive_day' => __( 'd', 'breadcrumb-trail' ),
54
+ 'archive_week' => __( 'Week %d', 'breadcrumb-trail' ),
55
+ 'archive_month' => __( 'F', 'breadcrumb-trail' ),
56
+ 'archive_year' => __( 'Y', 'breadcrumb-trail' ),
57
+ )
58
+ );
59
+
60
+ ### Hooks ###
61
+
62
+ * `breadcrumb_trail_args` - Filter hook on the array of arguments passed in.
63
+ * `breadcrumb_trail_items` - Filter hook on the array of items before being output.
64
+ * `breadcrumb_trail_get_bbpress_items` - Filter hook on the array of items when using bbPress.
65
+ * `breadcrumb_trail` - Filter hook on the HTML output of the breadcrumb trail.
66
+
67
+ ### Extending `Breadcrumb_Trail` ###
68
+
69
+ You can extend the `Breadcrumb_Trail` class with a custom class if needed. See the `bbPress_Breadcrumb_Trail` class as an example.
70
+
71
+ #### Available properties ####
72
+
73
+ * `$items` - Array of trail items.
74
+ * `$args` - The parsed arguments passed in.
75
+
76
+ #### Available methods #####
77
+
78
+ * `trail()` - Outputs/returns the final HTML.
79
+ * `do_trail_items()` - Method for filling the `$items` array.
80
+
81
+ Others are available, but those are the two you would actually put into real-world use.
82
+
83
+ ## Changelog ##
84
+
85
+ ### Version 0.6.0 ###
86
+
87
+ * [Schema.org](http://schema.org) support.
88
+ * Completely overhauled the entire plugin, rewriting large swathes of code from the ground up. This version takes an object-oriented approach.
89
+ * Blew every other breadcrumb menu script out of the water.
90
+
91
+ ### Version 0.5.3 ###
92
+
93
+ #### Enhancements ####
94
+
95
+ * Use `post_type_archive_title()` on post type archives in the trail.
96
+ * Add support for taxonomies that have a `$rewrite->slug` that matches a string value for a custom post type's `has_archive` argument.
97
+ * 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.
98
+ * Loads of pagination support on both archive-type pages and paged single posts.
99
+ * Added support for hierarchical custom post types (get parent posts).
100
+ * Added the `network` argument to allow multisite owners to run the trail all the way back to the main site.
101
+
102
+ #### Bug fixes ####
103
+
104
+ * Only check attachment trail if the attachment has a parent.
105
+ * Fixed the issue where the wrong post type archive link matches with a term archive page.
106
+
107
+ ### Version 0.5.2 ###
108
+
109
+ * No friggin' clue. I think I actually skipped version numbers somehow. :)
110
+
111
+ ### Version 0.5.1 ###
112
+
113
+ * Changed license from GPL 2-only to GPL 2+.
114
+ * Smarter handling of the `trail-begin` and `trail-end` classes.
115
+ * Added `container` argument for wrapping breadcrumbs in a custom HTML element.
116
+ * Changed `bbp_get_forum_parent()` to `bbp_get_forum_parent_id()`.
117
+
118
+ ### Version 0.5.0 ###
119
+
120
+ * Use hardcoded strings for the textdomain, not a variable.
121
+ * Inline doc updates.
122
+ * Added bbPress support.
123
+ * Use `single_post_title()` instead of `get_the_title()` for post titles.
124
+
125
+ ### Version 0.4.1 ###
126
+
127
+ * Use `get_queried_object()` and `get_queried_object_id()` instead of accessing `$wp_query` directly.
128
+ * Pass `$args` as second parameter in `breadcrumb_trail` hook.
129
+
130
+ ### Version 0.4.0 ###
131
+
132
+ * 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.
133
+ * New filter hook: `breadcrumb_trail_items`, which allows devs to filter just the items.
134
+ * 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.
135
+ * New function: `breadcrumb_trail_textdomain()`, which can be filtered when integrating the plugin into a theme to match the theme's textdomain.
136
+ * Added functionality to handle WP 3.1 post type enhancements.
137
+
138
+ ### Version 0.3.1 ###
139
+
140
+ * Smarter logic in certain areas.
141
+ * Removed localization for things that shouldn't be localized with time formats.
142
+ * `single_tax` set to `null` instead of `false`.
143
+ * Better escaping of element attributes.
144
+ * Use `$wp_query->get_queried_object()` and `$wp_query->get_queried_object_id()`.
145
+ * Add in initial support of WordPress 3.1's post type archives.
146
+ * Better formatting and organization of the output late in the function.
147
+ * Added `trail-before` and `trail-after` CSS classes if `$before` or `$after` is set.
148
+
149
+ ### Version 0.3.1 ###
150
+
151
+ * Undefined index error fixes.
152
+ * Fixes for trying to get a property of a non-object.
153
+
154
+ ### Version 0.3.0 ###
155
+
156
+ * Added more support for custom post types and taxonomies.
157
+ * Added more support for more complex hierarchies.
158
+ * The breadcrumb trail now recognizes more patterns with pages as part of the permalink structure of other objects.
159
+ * All post types can have any taxonomy as the leading part of the trail.
160
+ * Cleaned up the code.
161
+
162
+ ### Version 0.2.1 ###
163
+
164
+ * Removed and/or added (depending on the case) the extra separator item on sub-categories and date-/time-based breadcrumbs.
165
+
166
+ ### Version 0.2.0 ###
167
+
168
+ * The title of the "home" page (i.e. posts page) when not the front page is now properly recognized.
169
+ * Cleaned up the code and logic behind the plugin.
170
+
171
+ ### Version 0.1.0 ###
172
+
173
+ * Launch of the new plugin.
174
+
175
+ ## Support ##
176
+
177
+ 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.
178
+
179
+ I know. I know. You might not want to pay for support, but just consider it a donation to the project. To continue making cool, GPL-licensed plugins/themes and having the time to support them, I must pay the bills.
180
+
181
+ ## Copyright and License ##
182
+
183
+ Breadcrumb Trail is licensed under the [GNU GPL](http://www.gnu.org/licenses/old-licenses/gpl-2.0.html), version 2 or later.
184
+
185
+ 2008&thinsp;&ndash;&thinsp;2013 &copy; [Justin Tadlock](http://justintadlock.com).
readme.txt CHANGED
@@ -1,67 +1,154 @@
1
  === Breadcrumb Trail ===
 
2
  Contributors: greenshady
3
- Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=3687060
4
- Tags: navigation, menu, breadcrumb, breadcrumbs
5
- Requires at least: 3.1
6
- Tested up to: 3.2.1
7
- Stable tag: 0.4.1
 
 
8
 
9
- An easy-to-use template tag for showing a breadcrumb menu on your site.
10
 
11
  == Description ==
12
 
13
- *Breadcrumb Trail* is a plugin that was designed to make it easy to add a breadcrumb menu anywhere you want in your theme.
 
 
 
 
 
 
 
 
14
 
15
- How is it any better than any other breadcrumb plugin? Well, it's probably not, to be perfectly honest. This is just a script I've been building upon for nearly a couple of years that I usually include with my WordPress themes. I figured I'd package it as a plugin for others to use as well.
 
 
 
16
 
17
- It gives you a new template tag called `breadcrumb_trail()` that you can place anywhere in your template files.
 
 
18
 
19
  == Installation ==
20
 
21
  1. Upload `breadcrumb-trail` to the `/wp-content/plugins/` directory.
22
- 1. Activate the plugin through the 'Plugins' menu in WordPress.
23
- 1. Add the appropriate code to your template files as outlined in the `readme.html` file.
24
 
25
- More detailed instructions are included in the plugin's `readme.html` file. It is important to read through that file to properly understand all of the options and how the plugin works.
26
 
27
  == Frequently Asked Questions ==
28
 
29
- = Why was this plugin created? =
30
 
31
- I mostly develop WordPress themes. Many of my users had a real need for a functional breadcrumb menu without having to find and test a lot of other plugins. So, I've been developing this script for several years for my theme users.
32
 
33
- I finally thought it was time to release it publicly so others could enjoy the benefits of this plugin just as my theme users have been.
34
 
35
- = What's a breadcrumb menu? =
36
 
37
  Basically, it's a navigational tool. On many sites, you'll see something that looks like this:
38
 
39
- `You are here > Home > Archives > Sub-page`
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
- This plugin allows you to easily add this to your site.
42
 
43
- = How do I add it to my theme? =
44
 
45
- There are several methods, but in general, you would use this call:
46
 
47
- `
48
- <?php if ( function_exists( 'breadcrumb_trail' ) ) breadcrumb_trail(); ?>
49
- `
50
 
51
- To see all methods and options, refer to the `readme.html` file included with the plugin download.
 
 
52
 
53
  == Screenshots ==
54
 
55
- There are no screenshots for this plugin.
 
 
 
 
 
 
 
 
 
56
 
57
  == Changelog ==
58
 
59
- **Version 0.4.1**
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  * Use `get_queried_object()` and `get_queried_object_id()` instead of accessing `$wp_query` directly.
62
  * Pass `$args` as second parameter in `breadcrumb_trail` hook.
63
 
64
- **Version 0.4.0**
65
 
66
  * 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.
67
  * New filter hook: `breadcrumb_trail_items`, which allows devs to filter just the items.
@@ -69,7 +156,7 @@ There are no screenshots for this plugin.
69
  * New function: `breadcrumb_trail_textdomain()`, which can be filtered when integrating the plugin into a theme to match the theme's textdomain.
70
  * Added functionality to handle WP 3.1 post type enhancements.
71
 
72
- **Version 0.3.1**
73
 
74
  * Smarter logic in certain areas.
75
  * Removed localization for things that shouldn't be localized with time formats.
@@ -80,12 +167,12 @@ There are no screenshots for this plugin.
80
  * Better formatting and organization of the output late in the function.
81
  * Added `trail-before` and `trail-after` CSS classes if `$before` or `$after` is set.
82
 
83
- **Version 0.3.1**
84
 
85
  * Undefined index error fixes.
86
  * Fixes for trying to get a property of a non-object.
87
 
88
- **Version 0.3**
89
 
90
  * Added more support for custom post types and taxonomies.
91
  * Added more support for more complex hierarchies.
@@ -93,15 +180,15 @@ There are no screenshots for this plugin.
93
  * All post types can have any taxonomy as the leading part of the trail.
94
  * Cleaned up the code.
95
 
96
- ** Version 0.2.1 **
97
 
98
  * Removed and/or added (depending on the case) the extra separator item on sub-categories and date-/time-based breadcrumbs.
99
 
100
- ** Version 0.2 **
101
 
102
  * The title of the "home" page (i.e. posts page) when not the front page is now properly recognized.
103
  * Cleaned up the code and logic behind the plugin.
104
 
105
- **Version 0.1**
106
 
107
  * Launch of the new plugin.
1
  === Breadcrumb Trail ===
2
+
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
+ Tested up to: 3.7
8
+ Stable tag: 0.6.0
9
+ License: GPLv2 or later
10
+ License URI: http://www.gnu.org/licenses/gpl-2.0.htm
11
 
12
+ A powerful script for adding breadcrumbs to your site that supports Schema.org HTML5-valid microdata.
13
 
14
  == Description ==
15
 
16
+ Breadcrumb Trail is one of the most advanced and robust breadcrumb menu systems available for WordPress. It started out as a small script for basic blogs but has grown into a system that can handle nearly any site's setup to show the most accurate breadcrumbs for each page.
17
+
18
+ ### How it works ###
19
+
20
+ This plugin automatically detects your permalink setup and displays breadcrumbs based off that structure. Nearly all sites have some sort of hierarchy. Breadcrumb Trail recognizes that and builds a set of unique breadcrumbs for each page on your site.
21
+
22
+ This means that it can also detect custom post types and taxonomies right out of the box. Whatever you throw at it, it's got a solution.
23
+
24
+ ### Features ###
25
 
26
+ * 5+ years of development and user testing.
27
+ * Auto-detects the permalink structure of your site for the most accurate breadcrumbs.
28
+ * Hooks for plugin/theme developers to overwrite output.
29
+ * Coded with object-oriented programming (OOP) methods to allow developers to extend it for those highly-custom setups.
30
 
31
+ ### Professional support ###
32
+
33
+ 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).
34
 
35
  == Installation ==
36
 
37
  1. Upload `breadcrumb-trail` to the `/wp-content/plugins/` directory.
38
+ 2. Activate the plugin through the 'Plugins' menu in WordPress.
39
+ 3. Add the `breadcrumb_trail()` template tag to your theme.
40
 
41
+ More detailed instructions are included in the plugin's `readme.md` file.
42
 
43
  == Frequently Asked Questions ==
44
 
45
+ ### Why was this plugin created? ###
46
 
47
+ Many of my theme users had a real need for a functional breadcrumb menu without having to find and test a lot of other plugins. Therefore, I created a breadcrumbs script for those users. Eventually, I decided to package it as a plugin and share it with others.
48
 
49
+ The plugin is still mostly packaged with themes and is currently being used on millions of WordPress sites.
50
 
51
+ ### What's a breadcrumb menu? ###
52
 
53
  Basically, it's a navigational tool. On many sites, you'll see something that looks like this:
54
 
55
+ You are here: Home > Page > Sub-page > Sub-sub-page
56
+
57
+ This plugin allows you to easily add this type of menu your site.
58
+
59
+ ### How do I add it to my theme? ###
60
+
61
+ There are several methods, but in general, you would add the following line of code to your theme. Generally, this goes somewhere near the bottom of your theme's `header.php` template. However, you can add it anywhere you want in your theme, and it should work.
62
+
63
+ <?php if ( function_exists( 'breadcrumb_trail' ) ) breadcrumb_trail(); ?>
64
+
65
+ To see all methods and options, refer to the `readme.md` file included with the plugin download.
66
+
67
+ ### Do breadcrumbs show in Google search results? ###
68
+
69
+ Yes, breadcrumbs *can* show in Google search results. The breadcrumbs are coded in a way that all of the major search engines should be able to recognize them. It is marked up with the appropriate Schema.org properties to make it easier for search engines and other systems to understand.
70
+
71
+ With that said, it's still left up to the search provider to actually show the breadcrumbs. Generally, they do show them.
72
+
73
+ Don't expect to see breadcrumbs in your search results on the first day either. It may take a bit, depending on how often your Web site is crawled.
74
+
75
+ ### What is Schema.org? Microdata? ###
76
+
77
+ [Microdata](http://en.wikipedia.org/wiki/Microdata_(HTML)) is a way to nest metadata into your Web site's pages. It allows things like search engines and browsers to provide a more useful experience for users. Microdata provides a way for you to describe the "meaning" (i.e., semantics) of specific items on your site by using a standardized vocabulary.
78
 
79
+ [Schema.org](http://schema.org) is a microdata vocabulary. It is a collaboration by Bing, Google, Yahoo!, and Yandex for creating a set of standardized conventions for using microdata on the Web. With these standards in place, we can make our Web sites' data more understandable to search engines and browsers while providing a richer experience for users.
80
 
81
+ ### Does this help with SEO? ###
82
 
83
+ Well, it doesn't hurt. The way I see it, the more meaningful information you provide to search engines, the more likely you are to rank up. Properly-coded breadcrumbs are just one tool in a gigantic toolbox for building a search-engine optimized site.
84
 
85
+ ### The breadcrumbs display the wrong data! ###
 
 
86
 
87
+ This is rare, especially if you put the code in your header template. However, it can happen on occasion when your theme or another plugin messes with some of WordPress' global variables but doesn't set things back properly after doing whatever it is they're doing.
88
+
89
+ There's not really much I can do to correct that within the Breadcrumb Trail plugin. The only thing I could do is help you fix the theme/plugin causing the issue. If this happens, you'll need to drop by my [support forums](http://themehybrid.com/support) to get help.
90
 
91
  == Screenshots ==
92
 
93
+ 1. Breadcrumbs in Google search results.
94
+ 2. Date-based permalink structure in breadcrumbs.
95
+ 3. Custom post type + taxonomy (portfolio).
96
+ 4. Image attachment of a blog post.
97
+
98
+ == Upgrade Notice ==
99
+
100
+ ### Version 0.6.0+ ###
101
+
102
+ 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.
103
 
104
  == Changelog ==
105
 
106
+ ### Version 0.6.0 ###
107
+
108
+ * [Schema.org](http://schema.org) support.
109
+ * Completely overhauled the entire plugin, rewriting large swathes of code from the ground up. This version takes an object-oriented approach.
110
+ * Blew every other breadcrumb menu script out of the water.
111
+
112
+ ### Version 0.5.3 ###
113
+
114
+ #### Enhancements ####
115
+
116
+ * Use `post_type_archive_title()` on post type archives in the trail.
117
+ * Add support for taxonomies that have a `$rewrite->slug` that matches a string value for a custom post type's `has_archive` argument.
118
+ * 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.
119
+ * Loads of pagination support on both archive-type pages and paged single posts.
120
+ * Added support for hierarchical custom post types (get parent posts).
121
+ * Added the `network` argument to allow multisite owners to run the trail all the way back to the main site.
122
+
123
+ #### Bug fixes ####
124
+
125
+ * Only check attachment trail if the attachment has a parent.
126
+ * Fixed the issue where the wrong post type archive link matches with a term archive page.
127
+
128
+ ### Version 0.5.2 ###
129
+
130
+ * No friggin' clue. I think I actually skipped version numbers somehow. :)
131
+
132
+ ### Version 0.5.1 ###
133
+
134
+ * Changed license from GPL 2-only to GPL 2+.
135
+ * Smarter handling of the `trail-begin` and `trail-end` classes.
136
+ * Added `container` argument for wrapping breadcrumbs in a custom HTML element.
137
+ * Changed `bbp_get_forum_parent()` to `bbp_get_forum_parent_id()`.
138
+
139
+ ### Version 0.5.0 ###
140
+
141
+ * Use hardcoded strings for the textdomain, not a variable.
142
+ * Inline doc updates.
143
+ * Added bbPress support.
144
+ * Use `single_post_title()` instead of `get_the_title()` for post titles.
145
+
146
+ ### Version 0.4.1 ###
147
 
148
  * Use `get_queried_object()` and `get_queried_object_id()` instead of accessing `$wp_query` directly.
149
  * Pass `$args` as second parameter in `breadcrumb_trail` hook.
150
 
151
+ ### Version 0.4.0 ###
152
 
153
  * 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.
154
  * New filter hook: `breadcrumb_trail_items`, which allows devs to filter just the items.
156
  * New function: `breadcrumb_trail_textdomain()`, which can be filtered when integrating the plugin into a theme to match the theme's textdomain.
157
  * Added functionality to handle WP 3.1 post type enhancements.
158
 
159
+ ### Version 0.3.1 ###
160
 
161
  * Smarter logic in certain areas.
162
  * Removed localization for things that shouldn't be localized with time formats.
167
  * Better formatting and organization of the output late in the function.
168
  * Added `trail-before` and `trail-after` CSS classes if `$before` or `$after` is set.
169
 
170
+ ### Version 0.3.1 ###
171
 
172
  * Undefined index error fixes.
173
  * Fixes for trying to get a property of a non-object.
174
 
175
+ ### Version 0.3.0 ###
176
 
177
  * Added more support for custom post types and taxonomies.
178
  * Added more support for more complex hierarchies.
180
  * All post types can have any taxonomy as the leading part of the trail.
181
  * Cleaned up the code.
182
 
183
+ ### Version 0.2.1 ###
184
 
185
  * Removed and/or added (depending on the case) the extra separator item on sub-categories and date-/time-based breadcrumbs.
186
 
187
+ ### Version 0.2.0 ###
188
 
189
  * The title of the "home" page (i.e. posts page) when not the front page is now properly recognized.
190
  * Cleaned up the code and logic behind the plugin.
191
 
192
+ ### Version 0.1.0 ###
193
 
194
  * Launch of the new plugin.
screenshot-1.png ADDED
Binary file
screenshot-2.png ADDED
Binary file
screenshot-3.jpg ADDED
Binary file
screenshot-4.jpg ADDED
Binary file