Breadcrumb Trail - Version 0.3.2

Version Description

Download this release

Release Info

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

Code changes from version 0.3.1 to 0.3.2

breadcrumb-trail-en_EN.mo CHANGED
Binary file
breadcrumb-trail-en_EN.po CHANGED
@@ -2,7 +2,7 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Breadcrumb Trail WordPress Plugin\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2009-12-23 20:00+0900\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Justin Tadlock <justin@justintadlock.com>\n"
8
  "Language-Team: <justin@justintadlock.com>\n"
@@ -15,67 +15,62 @@ msgstr ""
15
  "X-Poedit-Basepath: .\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
- #: breadcrumb-trail.php:56
19
  msgid "Browse:"
20
  msgstr ""
21
 
22
- #: breadcrumb-trail.php:59
23
  msgid "Home"
24
  msgstr ""
25
 
26
- #: breadcrumb-trail.php:146
27
  msgid "g:i a"
28
  msgstr ""
29
 
30
- #: breadcrumb-trail.php:149
31
  #, php-format
32
  msgid "Minute %1$s"
33
  msgstr ""
34
 
35
- #: breadcrumb-trail.php:149
36
  msgid "i"
37
  msgstr ""
38
 
39
- #: breadcrumb-trail.php:152
40
  msgid "g a"
41
  msgstr ""
42
 
43
- #: breadcrumb-trail.php:158
44
- #: breadcrumb-trail.php:159
45
- #: breadcrumb-trail.php:164
46
- #: breadcrumb-trail.php:169
47
- #: breadcrumb-trail.php:174
48
  msgid "Y"
49
  msgstr ""
50
 
51
- #: breadcrumb-trail.php:159
52
- msgid "m"
53
- msgstr ""
54
-
55
- #: breadcrumb-trail.php:159
56
- #: breadcrumb-trail.php:170
57
  msgid "F"
58
  msgstr ""
59
 
60
- #: breadcrumb-trail.php:160
61
  msgid "j"
62
  msgstr ""
63
 
64
- #: breadcrumb-trail.php:165
65
  #, php-format
66
  msgid "Week %1$s"
67
  msgstr ""
68
 
69
- #: breadcrumb-trail.php:165
70
  msgid "W"
71
  msgstr ""
72
 
73
- #: breadcrumb-trail.php:180
74
  #, php-format
75
  msgid "Search results for &quot;%1$s&quot;"
76
  msgstr ""
77
 
78
- #: breadcrumb-trail.php:183
79
  msgid "404 Not Found"
80
  msgstr ""
81
 
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"
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
 
breadcrumb-trail.php CHANGED
@@ -3,25 +3,29 @@
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.3.1
7
  * Author: Justin Tadlock
8
  * Author URI: http://justintadlock.com
9
  *
10
- * A script for showing a breadcrumb trail for any type of page. It tries to anticipate any
11
- * type of structure and display the best possible trail that matches your site's permalinks.
 
 
12
  * While not perfect, it attempts to fill in the gaps left by many other breadcrumb scripts.
13
  *
14
- * @copyright 2008 - 2010
15
- * @version 0.3.1
16
- * @author Justin Tadlock
17
- * @link http://justintadlock.com/archives/2009/04/05/breadcrumb-trail-wordpress-plugin
18
- * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19
  *
20
- * This program is distributed in the hope that it will be useful,
21
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
23
  *
24
  * @package BreadcrumbTrail
 
 
 
 
 
25
  */
26
 
27
  /**
@@ -35,8 +39,8 @@
35
  load_plugin_textdomain( 'breadcrumb-trail', false, 'breadcrumb-trail' );
36
 
37
  /**
38
- * Shows a breadcrumb for all types of pages. Themes and plugins can filter $args or
39
- * input directly. Allow filtering of only the $args using get_the_breadcrumb_args.
40
  *
41
  * @since 0.1
42
  * @param array $args Mixed arguments for the menu.
@@ -62,7 +66,7 @@ function breadcrumb_trail( $args = array() ) {
62
  'after' => false,
63
  'front_page' => true,
64
  'show_home' => __( 'Home', $textdomain ),
65
- 'single_tax' => false, // @deprecated 0.3 Use singular_{$post_type}_taxonomy.
66
  'echo' => true
67
  );
68
 
@@ -77,16 +81,12 @@ function breadcrumb_trail( $args = array() ) {
77
  extract( wp_parse_args( $args, $defaults ) );
78
 
79
  /* For backwards compatibility, set $single_tax if it's explicitly given. */
80
- if ( $single_tax )
81
  $args['singular_post_taxonomy'] = $single_tax;
82
 
83
- /* Format the separator. */
84
- if ( $separator )
85
- $separator = '<span class="sep">' . $separator . '</span>';
86
-
87
  /* If $show_home is set and we're not on the front page of the site, link to the home page. */
88
  if ( !is_front_page() && $show_home )
89
- $trail[] = '<a href="' . home_url() . '" title="' . get_bloginfo( 'name' ) . '" rel="home" class="trail-begin">' . $show_home . '</a>';
90
 
91
  /* If viewing the front page of the site. */
92
  if ( is_front_page() ) {
@@ -107,9 +107,10 @@ function breadcrumb_trail( $args = array() ) {
107
  elseif ( is_singular() ) {
108
 
109
  /* Get singular post variables needed. */
110
- $post_id = absint( $wp_query->post->ID );
111
- $post_type = $wp_query->post->post_type;
112
- $parent = $wp_query->post->post_parent;
 
113
 
114
  /* If a custom post type, check if there are any pages in its hierarchy based on the slug. */
115
  if ( 'page' !== $post_type ) {
@@ -127,6 +128,10 @@ function breadcrumb_trail( $args = array() ) {
127
  /* If there's a path, check for parents. */
128
  if ( !empty( $path ) )
129
  $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
 
 
 
 
130
  }
131
 
132
  /* If the post type path returns nothing and there is a parent, get its parents. */
@@ -176,6 +181,28 @@ function breadcrumb_trail( $args = array() ) {
176
  $trail['trail_end'] = $term->name;
177
  }
178
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
179
  /* If viewing an author archive. */
180
  elseif ( is_author() ) {
181
 
@@ -216,18 +243,18 @@ function breadcrumb_trail( $args = array() ) {
216
  $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $wp_rewrite->front ) );
217
 
218
  if ( is_day() ) {
219
- $trail[] = '<a href="' . get_year_link( get_the_time( __( 'Y', $textdomain ) ) ) . '" title="' . get_the_time( __( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
220
- $trail[] = '<a href="' . get_month_link( get_the_time( __( 'Y', $textdomain ) ), get_the_time( __( 'm', $textdomain ) ) ) . '" title="' . get_the_time( __( 'F', $textdomain ) ) . '">' . get_the_time( __( 'F', $textdomain ) ) . '</a>';
221
  $trail['trail_end'] = get_the_time( __( 'j', $textdomain ) );
222
  }
223
 
224
  elseif ( get_query_var( 'w' ) ) {
225
- $trail[] = '<a href="' . get_year_link( get_the_time( __( 'Y', $textdomain ) ) ) . '" title="' . get_the_time( __( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
226
- $trail['trail_end'] = sprintf( __( 'Week %1$s', $textdomain ), get_the_time( __( 'W', $textdomain ) ) );
227
  }
228
 
229
  elseif ( is_month() ) {
230
- $trail[] = '<a href="' . get_year_link( get_the_time( __( 'Y', $textdomain ) ) ) . '" title="' . get_the_time( __( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
231
  $trail['trail_end'] = get_the_time( __( 'F', $textdomain ) );
232
  }
233
 
@@ -247,13 +274,34 @@ function breadcrumb_trail( $args = array() ) {
247
 
248
  /* Connect the breadcrumb trail if there are items in the trail. */
249
  if ( is_array( $trail ) ) {
 
 
250
  $breadcrumb = '<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail">';
251
- $breadcrumb .= " {$before} ";
 
 
 
 
 
 
 
 
 
 
 
 
 
252
  $breadcrumb .= join( " {$separator} ", $trail );
253
- $breadcrumb .= " {$after} ";
 
 
 
 
 
254
  $breadcrumb .= '</div></div>';
255
  }
256
 
 
257
  $breadcrumb = apply_filters( 'breadcrumb_trail', $breadcrumb );
258
 
259
  /* Output the breadcrumb. */
@@ -264,10 +312,9 @@ function breadcrumb_trail( $args = array() ) {
264
  }
265
 
266
  /**
267
- * Gets parent pages of any post type or taxonomy by the ID or Path. The goal of this
268
- * function is to create a clear path back to home given what would normally be a "ghost"
269
- * directory. If any page matches the given path, it'll be added. But, it's also just a way
270
- * to check for a hierarchy with hierarchical post types.
271
  *
272
  * @since 0.3
273
  * @param int $post_id ID of the post whose parents we want.
@@ -276,30 +323,48 @@ function breadcrumb_trail( $args = array() ) {
276
  */
277
  function breadcrumb_trail_get_parents( $post_id = '', $path = '' ) {
278
 
 
279
  $trail = array();
280
 
 
281
  if ( empty( $post_id ) && empty( $path ) )
282
  return $trail;
283
 
 
284
  if ( empty( $post_id ) ) {
 
 
285
  $parent_page = get_page_by_path( $path );
 
 
286
  if ( !empty( $parent_page ) )
287
  $post_id = $parent_page->ID;
288
  }
289
 
290
- if ( $post_id == 0 ) {
 
 
 
291
  $path = trim( $path, '/' );
292
  preg_match_all( "/\/.*?\z/", $path, $matches );
293
 
 
294
  if ( isset( $matches ) ) {
 
 
295
  $matches = array_reverse( $matches );
296
 
 
297
  foreach ( $matches as $match ) {
298
 
 
299
  if ( isset( $match[0] ) ) {
 
 
300
  $path = str_replace( $match[0], '', $path );
301
  $parent_page = get_page_by_path( trim( $path, '/' ) );
302
 
 
303
  if ( !empty( $parent_page ) && $parent_page->ID > 0 ) {
304
  $post_id = $parent_page->ID;
305
  break;
@@ -309,21 +374,30 @@ function breadcrumb_trail_get_parents( $post_id = '', $path = '' ) {
309
  }
310
  }
311
 
 
312
  while ( $post_id ) {
 
 
313
  $page = get_page( $post_id );
 
 
314
  $parents[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . get_the_title( $post_id ) . '</a>';
 
 
315
  $post_id = $page->post_parent;
316
  }
317
 
 
318
  if ( isset( $parents ) )
319
  $trail = array_reverse( $parents );
320
 
 
321
  return $trail;
322
  }
323
 
324
  /**
325
- * Searches for term parents of hierarchical taxonomies. This function is similar to
326
- * the WordPress function get_category_parents() but handles any type of taxonomy.
327
  *
328
  * @since 0.3
329
  * @param int $parent_id The ID of the first parent.
@@ -331,21 +405,33 @@ function breadcrumb_trail_get_parents( $post_id = '', $path = '' ) {
331
  * @return array $trail Array of links to parent terms.
332
  */
333
  function breadcrumb_trail_get_term_parents( $parent_id = '', $taxonomy = '' ) {
 
 
334
  $trail = array();
335
  $parents = array();
336
 
 
337
  if ( empty( $parent_id ) || empty( $taxonomy ) )
338
  return $trail;
339
 
 
340
  while ( $parent_id ) {
 
 
341
  $parent = get_term( $parent_id, $taxonomy );
 
 
342
  $parents[] = '<a href="' . get_term_link( $parent, $taxonomy ) . '" title="' . esc_attr( $parent->name ) . '">' . $parent->name . '</a>';
 
 
343
  $parent_id = $parent->parent;
344
  }
345
 
346
- if ( $parents )
 
347
  $trail = array_reverse( $parents );
348
 
 
349
  return $trail;
350
  }
351
 
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.3.2
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.3.2
25
+ * @author Justin Tadlock <justin@justintadlock.com>
26
+ * @copyright Copyright (c) 2008 - 2010, 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
  /**
39
  load_plugin_textdomain( 'breadcrumb-trail', false, 'breadcrumb-trail' );
40
 
41
  /**
42
+ * Shows a breadcrumb for all types of pages. Themes and plugins can filter $args or input directly.
43
+ * Allow filtering of only the $args using get_the_breadcrumb_args.
44
  *
45
  * @since 0.1
46
  * @param array $args Mixed arguments for the menu.
66
  'after' => false,
67
  'front_page' => true,
68
  'show_home' => __( 'Home', $textdomain ),
69
+ 'single_tax' => null, // @deprecated 0.3 Use singular_{$post_type}_taxonomy.
70
  'echo' => true
71
  );
72
 
81
  extract( wp_parse_args( $args, $defaults ) );
82
 
83
  /* For backwards compatibility, set $single_tax if it's explicitly given. */
84
+ if ( !is_null( $single_tax ) )
85
  $args['singular_post_taxonomy'] = $single_tax;
86
 
 
 
 
 
87
  /* If $show_home is set and we're not on the front page of the site, link to the home page. */
88
  if ( !is_front_page() && $show_home )
89
+ $trail[] = '<a href="' . home_url() . '" title="' . esc_attr( get_bloginfo( 'name' ) ) . '" rel="home" class="trail-begin">' . $show_home . '</a>';
90
 
91
  /* If viewing the front page of the site. */
92
  if ( is_front_page() ) {
107
  elseif ( is_singular() ) {
108
 
109
  /* Get singular post variables needed. */
110
+ $post = $wp_query->get_queried_object();
111
+ $post_id = absint( $wp_query->get_queried_object_id() );
112
+ $post_type = $post->post_type;
113
+ $parent = $post->post_parent;
114
 
115
  /* If a custom post type, check if there are any pages in its hierarchy based on the slug. */
116
  if ( 'page' !== $post_type ) {
128
  /* If there's a path, check for parents. */
129
  if ( !empty( $path ) )
130
  $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
131
+
132
+ /* If there's an archive page, add it to the trail. */
133
+ if ( !empty( $post_type_object->rewrite['archive'] ) && function_exists( 'get_post_type_archive_link' ) )
134
+ $trail[] = '<a href="' . get_post_type_archive_link( $post_type ) . '" title="' . esc_attr( $post_type_object->labels->name ) . '">' . $post_type_object->labels->name . '</a>';
135
  }
136
 
137
  /* If the post type path returns nothing and there is a parent, get its parents. */
181
  $trail['trail_end'] = $term->name;
182
  }
183
 
184
+ /* If viewing a post type archive. */
185
+ elseif ( function_exists( 'is_post_type_archive' ) && is_post_type_archive() ) {
186
+
187
+ /* Get the post type object. */
188
+ $post_type_object = get_post_type_object( get_query_var( 'post_type' ) );
189
+
190
+ /* If $front has been set, add it to the $path. */
191
+ if ( $post_type_object->rewrite['with_front'] && $wp_rewrite->front )
192
+ $path .= trailingslashit( $wp_rewrite->front );
193
+
194
+ /* If there's a slug, add it to the $path. */
195
+ if ( !empty( $post_type_object->rewrite['archive'] ) )
196
+ $path .= $post_type_object->rewrite['archive'];
197
+
198
+ /* If there's a path, check for parents. */
199
+ if ( !empty( $path ) )
200
+ $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
201
+
202
+ /* Add the post type [plural] name to the trail end. */
203
+ $trail['trail_end'] = $post_type_object->labels->name;
204
+ }
205
+
206
  /* If viewing an author archive. */
207
  elseif ( is_author() ) {
208
 
243
  $trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $wp_rewrite->front ) );
244
 
245
  if ( is_day() ) {
246
+ $trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
247
+ $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>';
248
  $trail['trail_end'] = get_the_time( __( 'j', $textdomain ) );
249
  }
250
 
251
  elseif ( get_query_var( 'w' ) ) {
252
+ $trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
253
+ $trail['trail_end'] = sprintf( __( 'Week %1$s', $textdomain ), get_the_time( esc_attr__( 'W', $textdomain ) ) );
254
  }
255
 
256
  elseif ( is_month() ) {
257
+ $trail[] = '<a href="' . get_year_link( get_the_time( 'Y' ) ) . '" title="' . get_the_time( esc_attr__( 'Y', $textdomain ) ) . '">' . get_the_time( __( 'Y', $textdomain ) ) . '</a>';
258
  $trail['trail_end'] = get_the_time( __( 'F', $textdomain ) );
259
  }
260
 
274
 
275
  /* Connect the breadcrumb trail if there are items in the trail. */
276
  if ( is_array( $trail ) ) {
277
+
278
+ /* Open the breadcrumb trail containers. */
279
  $breadcrumb = '<div class="breadcrumb breadcrumbs"><div class="breadcrumb-trail">';
280
+
281
+ /* If $before was set, wrap it in a container. */
282
+ if ( !empty( $before ) )
283
+ $breadcrumb .= '<span class="trail-before">' . $before . '</span> ';
284
+
285
+ /* Wrap the $trail['trail_end'] value in a container. */
286
+ if ( !empty( $trail['trail_end'] ) )
287
+ $trail['trail_end'] = '<span class="trail-end">' . $trail['trail_end'] . '</span>';
288
+
289
+ /* Format the separator. */
290
+ if ( !empty( $separator ) )
291
+ $separator = '<span class="sep">' . $separator . '</span>';
292
+
293
+ /* Join the individual trail items into a single string. */
294
  $breadcrumb .= join( " {$separator} ", $trail );
295
+
296
+ /* If $after was set, wrap it in a container. */
297
+ if ( !empty( $after ) )
298
+ $breadcrumb .= ' <span class="trail-after">' . $after . '</span>';
299
+
300
+ /* Close the breadcrumb trail containers. */
301
  $breadcrumb .= '</div></div>';
302
  }
303
 
304
+ /* Allow developers to filter the breadcrumb trail HTML. */
305
  $breadcrumb = apply_filters( 'breadcrumb_trail', $breadcrumb );
306
 
307
  /* Output the breadcrumb. */
312
  }
313
 
314
  /**
315
+ * Gets parent pages of any post type or taxonomy by the ID or Path. The goal of this function is to create
316
+ * a clear path back to home given what would normally be a "ghost" directory. If any page matches the given
317
+ * path, it'll be added. But, it's also just a way to check for a hierarchy with hierarchical post types.
 
318
  *
319
  * @since 0.3
320
  * @param int $post_id ID of the post whose parents we want.
323
  */
324
  function breadcrumb_trail_get_parents( $post_id = '', $path = '' ) {
325
 
326
+ /* Set up an empty trail array. */
327
  $trail = array();
328
 
329
+ /* If neither a post ID nor path set, return an empty array. */
330
  if ( empty( $post_id ) && empty( $path ) )
331
  return $trail;
332
 
333
+ /* If the post ID is empty, use the path to get the ID. */
334
  if ( empty( $post_id ) ) {
335
+
336
+ /* Get parent post by the path. */
337
  $parent_page = get_page_by_path( $path );
338
+
339
+ /* If a parent post is found, set the $post_id variable to it. */
340
  if ( !empty( $parent_page ) )
341
  $post_id = $parent_page->ID;
342
  }
343
 
344
+ /* If a post ID and path is set, search for a post by the given path. */
345
+ if ( $post_id == 0 && !empty( $path ) ) {
346
+
347
+ /* Separate post names into separate paths by '/'. */
348
  $path = trim( $path, '/' );
349
  preg_match_all( "/\/.*?\z/", $path, $matches );
350
 
351
+ /* If matches are found for the path. */
352
  if ( isset( $matches ) ) {
353
+
354
+ /* Reverse the array of matches to search for posts in the proper order. */
355
  $matches = array_reverse( $matches );
356
 
357
+ /* Loop through each of the path matches. */
358
  foreach ( $matches as $match ) {
359
 
360
+ /* If a match is found. */
361
  if ( isset( $match[0] ) ) {
362
+
363
+ /* Get the parent post by the given path. */
364
  $path = str_replace( $match[0], '', $path );
365
  $parent_page = get_page_by_path( trim( $path, '/' ) );
366
 
367
+ /* If a parent post is found, set the $post_id and break out of the loop. */
368
  if ( !empty( $parent_page ) && $parent_page->ID > 0 ) {
369
  $post_id = $parent_page->ID;
370
  break;
374
  }
375
  }
376
 
377
+ /* While there's a post ID, add the post link to the $parents array. */
378
  while ( $post_id ) {
379
+
380
+ /* Get the post by ID. */
381
  $page = get_page( $post_id );
382
+
383
+ /* Add the formatted post link to the array of parents. */
384
  $parents[] = '<a href="' . get_permalink( $post_id ) . '" title="' . esc_attr( get_the_title( $post_id ) ) . '">' . get_the_title( $post_id ) . '</a>';
385
+
386
+ /* Set the parent post's parent to the post ID. */
387
  $post_id = $page->post_parent;
388
  }
389
 
390
+ /* If we have parent posts, reverse the array to put them in the proper order for the trail. */
391
  if ( isset( $parents ) )
392
  $trail = array_reverse( $parents );
393
 
394
+ /* Return the trail of parent posts. */
395
  return $trail;
396
  }
397
 
398
  /**
399
+ * Searches for term parents of hierarchical taxonomies. This function is similar to the WordPress
400
+ * function get_category_parents() but handles any type of taxonomy.
401
  *
402
  * @since 0.3
403
  * @param int $parent_id The ID of the first parent.
405
  * @return array $trail Array of links to parent terms.
406
  */
407
  function breadcrumb_trail_get_term_parents( $parent_id = '', $taxonomy = '' ) {
408
+
409
+ /* Set up some default arrays. */
410
  $trail = array();
411
  $parents = array();
412
 
413
+ /* If no term parent ID or taxonomy is given, return an empty array. */
414
  if ( empty( $parent_id ) || empty( $taxonomy ) )
415
  return $trail;
416
 
417
+ /* While there is a parent ID, add the parent term link to the $parents array. */
418
  while ( $parent_id ) {
419
+
420
+ /* Get the parent term. */
421
  $parent = get_term( $parent_id, $taxonomy );
422
+
423
+ /* Add the formatted term link to the array of parent terms. */
424
  $parents[] = '<a href="' . get_term_link( $parent, $taxonomy ) . '" title="' . esc_attr( $parent->name ) . '">' . $parent->name . '</a>';
425
+
426
+ /* Set the parent term's parent as the parent ID. */
427
  $parent_id = $parent->parent;
428
  }
429
 
430
+ /* If we have parent terms, reverse the array to put them in the proper order for the trail. */
431
+ if ( !empty( $parents ) )
432
  $trail = array_reverse( $parents );
433
 
434
+ /* Return the trail of parent terms. */
435
  return $trail;
436
  }
437
 
breadcrumb-trail.pot CHANGED
@@ -2,7 +2,7 @@ msgid ""
2
  msgstr ""
3
  "Project-Id-Version: Breadcrumb Trail WordPress Plugin\n"
4
  "Report-Msgid-Bugs-To: \n"
5
- "POT-Creation-Date: 2009-12-23 20:00+0900\n"
6
  "PO-Revision-Date: \n"
7
  "Last-Translator: Justin Tadlock <justin@justintadlock.com>\n"
8
  "Language-Team: <justin@justintadlock.com>\n"
@@ -15,67 +15,62 @@ msgstr ""
15
  "X-Poedit-Basepath: .\n"
16
  "X-Poedit-SearchPath-0: .\n"
17
 
18
- #: breadcrumb-trail.php:56
19
  msgid "Browse:"
20
  msgstr ""
21
 
22
- #: breadcrumb-trail.php:59
23
  msgid "Home"
24
  msgstr ""
25
 
26
- #: breadcrumb-trail.php:146
27
  msgid "g:i a"
28
  msgstr ""
29
 
30
- #: breadcrumb-trail.php:149
31
  #, php-format
32
  msgid "Minute %1$s"
33
  msgstr ""
34
 
35
- #: breadcrumb-trail.php:149
36
  msgid "i"
37
  msgstr ""
38
 
39
- #: breadcrumb-trail.php:152
40
  msgid "g a"
41
  msgstr ""
42
 
43
- #: breadcrumb-trail.php:158
44
- #: breadcrumb-trail.php:159
45
- #: breadcrumb-trail.php:164
46
- #: breadcrumb-trail.php:169
47
- #: breadcrumb-trail.php:174
48
  msgid "Y"
49
  msgstr ""
50
 
51
- #: breadcrumb-trail.php:159
52
- msgid "m"
53
- msgstr ""
54
-
55
- #: breadcrumb-trail.php:159
56
- #: breadcrumb-trail.php:170
57
  msgid "F"
58
  msgstr ""
59
 
60
- #: breadcrumb-trail.php:160
61
  msgid "j"
62
  msgstr ""
63
 
64
- #: breadcrumb-trail.php:165
65
  #, php-format
66
  msgid "Week %1$s"
67
  msgstr ""
68
 
69
- #: breadcrumb-trail.php:165
70
  msgid "W"
71
  msgstr ""
72
 
73
- #: breadcrumb-trail.php:180
74
  #, php-format
75
  msgid "Search results for &quot;%1$s&quot;"
76
  msgstr ""
77
 
78
- #: breadcrumb-trail.php:183
79
  msgid "404 Not Found"
80
  msgstr ""
81
 
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"
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
 
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_i
4
  Tags: navigation, menu, breadcrumb, breadcrumbs
5
  Requires at least: 3.0
6
  Tested up to: 3.0.1
7
- Stable tag: 0.3.1
8
 
9
  An easy-to-use template tag for showing a breadcrumb menu on your site.
10
 
@@ -58,6 +58,17 @@ There are no screenshots for this plugin.
58
 
59
  **Version 0.3.1**
60
 
 
 
 
 
 
 
 
 
 
 
 
61
  * Undefined index error fixes.
62
  * Fixes for trying to get a property of a non-object.
63
 
4
  Tags: navigation, menu, breadcrumb, breadcrumbs
5
  Requires at least: 3.0
6
  Tested up to: 3.0.1
7
+ Stable tag: 0.3.2
8
 
9
  An easy-to-use template tag for showing a breadcrumb menu on your site.
10
 
58
 
59
  **Version 0.3.1**
60
 
61
+ * Smarter logic in certain areas.
62
+ * Removed localization for things that shouldn't be localized with time formats.
63
+ * `single_tax` set to `null` instead of `false`.
64
+ * Better escaping of element attributes.
65
+ * Use `$wp_query->get_queried_object()` and `$wp_query->get_queried_object_id()`.
66
+ * Add in initial support of WordPress 3.1's post type archives.
67
+ * Better formatting and organization of the output late in the function.
68
+ * Added `trail-before` and `trail-after` CSS classes if `$before` or `$after` is set.
69
+
70
+ **Version 0.3.1**
71
+
72
  * Undefined index error fixes.
73
  * Fixes for trying to get a property of a non-object.
74