Version Description
Download this release
Release Info
Developer | greenshady |
Plugin | Breadcrumb Trail |
Version | 0.3.1 |
Comparing to | |
See all releases |
Code changes from version 0.3 to 0.3.1
- breadcrumb-trail.php +27 -18
- readme.txt +7 -2
breadcrumb-trail.php
CHANGED
@@ -3,16 +3,16 @@
|
|
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
|
7 |
* Author: Justin Tadlock
|
8 |
* Author URI: http://justintadlock.com
|
9 |
*
|
10 |
-
* A script for showing a breadcrumb
|
11 |
-
*
|
12 |
-
*
|
13 |
*
|
14 |
* @copyright 2008 - 2010
|
15 |
-
* @version 0.3
|
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
|
@@ -48,8 +48,12 @@ function breadcrumb_trail( $args = array() ) {
|
|
48 |
/* Get the textdomain. */
|
49 |
$textdomain = 'breadcrumb-trail';
|
50 |
|
|
|
|
|
|
|
51 |
/* Create an empty array for the trail. */
|
52 |
$trail = array();
|
|
|
53 |
|
54 |
/* Set up the default arguments for the breadcrumb. */
|
55 |
$defaults = array(
|
@@ -114,7 +118,7 @@ function breadcrumb_trail( $args = array() ) {
|
|
114 |
|
115 |
/* If $front has been set, add it to the $path. */
|
116 |
if ( 'post' == $post_type || 'attachment' == $post_type || ( $post_type_object->rewrite['with_front'] && $wp_rewrite->front ) )
|
117 |
-
$path
|
118 |
|
119 |
/* If there's a slug, add it to the $path. */
|
120 |
if ( !empty( $post_type_object->rewrite['slug'] ) )
|
@@ -125,16 +129,18 @@ function breadcrumb_trail( $args = array() ) {
|
|
125 |
$trail = array_merge( $trail, breadcrumb_trail_get_parents( '', $path ) );
|
126 |
}
|
127 |
|
128 |
-
/* If the post type
|
129 |
-
if (
|
130 |
$trail = array_merge( $trail, breadcrumb_trail_get_parents( $parent, '' ) );
|
131 |
|
132 |
/* Display terms for specific post type taxonomy if requested. */
|
133 |
-
if ( $args["singular_{$post_type}_taxonomy"] && $terms = get_the_term_list( $post_id, $args["singular_{$post_type}_taxonomy"], '', ', ', '' ) )
|
134 |
$trail[] = $terms;
|
135 |
|
136 |
/* End with the post title. */
|
137 |
-
$
|
|
|
|
|
138 |
}
|
139 |
|
140 |
/* If we're viewing any type of archive. */
|
@@ -217,7 +223,7 @@ function breadcrumb_trail( $args = array() ) {
|
|
217 |
|
218 |
elseif ( get_query_var( 'w' ) ) {
|
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['trail_end'] = sprintf( __( 'Week %1$s',
|
221 |
}
|
222 |
|
223 |
elseif ( is_month() ) {
|
@@ -277,7 +283,8 @@ function breadcrumb_trail_get_parents( $post_id = '', $path = '' ) {
|
|
277 |
|
278 |
if ( empty( $post_id ) ) {
|
279 |
$parent_page = get_page_by_path( $path );
|
280 |
-
|
|
|
281 |
}
|
282 |
|
283 |
if ( $post_id == 0 ) {
|
@@ -289,12 +296,14 @@ function breadcrumb_trail_get_parents( $post_id = '', $path = '' ) {
|
|
289 |
|
290 |
foreach ( $matches as $match ) {
|
291 |
|
292 |
-
|
293 |
-
|
|
|
294 |
|
295 |
-
|
296 |
-
|
297 |
-
|
|
|
298 |
}
|
299 |
}
|
300 |
}
|
@@ -306,7 +315,7 @@ function breadcrumb_trail_get_parents( $post_id = '', $path = '' ) {
|
|
306 |
$post_id = $page->post_parent;
|
307 |
}
|
308 |
|
309 |
-
if ( $parents )
|
310 |
$trail = array_reverse( $parents );
|
311 |
|
312 |
return $trail;
|
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
|
48 |
/* Get the textdomain. */
|
49 |
$textdomain = 'breadcrumb-trail';
|
50 |
|
51 |
+
/* Create an empty variable for the breadcrumb. */
|
52 |
+
$breadcrumb = '';
|
53 |
+
|
54 |
/* Create an empty array for the trail. */
|
55 |
$trail = array();
|
56 |
+
$path = '';
|
57 |
|
58 |
/* Set up the default arguments for the breadcrumb. */
|
59 |
$defaults = array(
|
118 |
|
119 |
/* If $front has been set, add it to the $path. */
|
120 |
if ( 'post' == $post_type || 'attachment' == $post_type || ( $post_type_object->rewrite['with_front'] && $wp_rewrite->front ) )
|
121 |
+
$path .= trailingslashit( $wp_rewrite->front );
|
122 |
|
123 |
/* If there's a slug, add it to the $path. */
|
124 |
if ( !empty( $post_type_object->rewrite['slug'] ) )
|
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. */
|
133 |
+
if ( empty( $path ) && 0 !== $parent || 'attachment' == $post_type )
|
134 |
$trail = array_merge( $trail, breadcrumb_trail_get_parents( $parent, '' ) );
|
135 |
|
136 |
/* Display terms for specific post type taxonomy if requested. */
|
137 |
+
if ( isset( $args["singular_{$post_type}_taxonomy"] ) && $terms = get_the_term_list( $post_id, $args["singular_{$post_type}_taxonomy"], '', ', ', '' ) )
|
138 |
$trail[] = $terms;
|
139 |
|
140 |
/* End with the post title. */
|
141 |
+
$post_title = get_the_title();
|
142 |
+
if ( !empty( $post_title ) )
|
143 |
+
$trail['trail_end'] = $post_title;
|
144 |
}
|
145 |
|
146 |
/* If we're viewing any type of archive. */
|
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() ) {
|
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 ) {
|
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;
|
306 |
+
}
|
307 |
}
|
308 |
}
|
309 |
}
|
315 |
$post_id = $page->post_parent;
|
316 |
}
|
317 |
|
318 |
+
if ( isset( $parents ) )
|
319 |
$trail = array_reverse( $parents );
|
320 |
|
321 |
return $trail;
|
readme.txt
CHANGED
@@ -3,8 +3,8 @@ 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.0
|
6 |
-
Tested up to: 3.0
|
7 |
-
Stable tag: 0.3
|
8 |
|
9 |
An easy-to-use template tag for showing a breadcrumb menu on your site.
|
10 |
|
@@ -56,6 +56,11 @@ There are no screenshots for this plugin.
|
|
56 |
|
57 |
== Changelog ==
|
58 |
|
|
|
|
|
|
|
|
|
|
|
59 |
**Version 0.3**
|
60 |
|
61 |
* Added more support for custom post types and taxonomies.
|
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.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 |
|
56 |
|
57 |
== Changelog ==
|
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 |
+
|
64 |
**Version 0.3**
|
65 |
|
66 |
* Added more support for custom post types and taxonomies.
|