Changeset 1105595
- Timestamp:
- 03/05/2015 01:37:55 AM (11 years ago)
- Location:
- simple-crumbs-redux/trunk
- Files:
-
- 2 edited
-
readme.txt (modified) (3 diffs)
-
simple-crumbs-redux.php (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
simple-crumbs-redux/trunk/readme.txt
r779041 r1105595 4 4 Tags: breadcrumbs, navigation 5 5 Requires at least: 2.7 6 Tested up to: 3.6.17 Stable tag: 1. 0.26 Tested up to: 4.1.1 7 Stable tag: 1.1.0 8 8 License: GPLv2 or later 9 9 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 70 70 == Changelog == 71 71 72 = 1.1.0 = 73 * Changed titles array to class property. 74 75 = 1.0.2 = 76 * Changed contributers name to my WordPress.org username. 77 78 = 1.0.1 = 79 * Upated readme to pass validation. 80 72 81 = 1.0.0 = 73 74 82 * Initial Release. 75 83 * Fixed 'PHP Fatal error: Call-time pass-by-reference has been removed' with PHP 5.4 and greater. … … 77 85 * Repaced sc_unpack_query_string function with WordPress core function wp_parse_args(). 78 86 79 = 1.0.1 =80 81 * Upated readme to pass validation.82 83 84 87 == Upgrade Notice == 85 88 86 = 1.0.1 = 87 88 Updated readme to pass validation. 89 90 91 = 1.0.2 = 92 93 Changed contributers name to my WordPress.org username. 89 = 1.1.0 = 90 * All crumbs between root page and current page now display page title instead of permalink. -
simple-crumbs-redux/trunk/simple-crumbs-redux.php
r779041 r1105595 3 3 Plugin Name: Simple Crumbs Redux 4 4 Plugin URI: http://plugins.svn.wordpress.org/simple-crumbs-redux 5 Description: Simple Crumbs Redux- Generates a breadcrumb trail for pages and blog entries. Requires use of permalinks and php > 4.1.0, tested up to WP 3.6.5 Description: Simple Crumbs Redux- Generates a breadcrumb trail for pages and blog entries. Requires use of permalinks and php > 4.1.0, tested up to WP 4.1.1. 6 6 Author: Doug Sparling 7 Version: 1. 0.27 Version: 1.1.0 8 8 Author URI: http://www.dougsparling.org 9 9 Note: link/crumb information from $query_string … … 27 27 28 28 class SimpleCrumbsRedux { 29 private $titles = array(); 30 29 31 public function __construct() { 30 32 add_shortcode( 'simple_crumbs', array( $this, 'simplecrumbs_shortcode' ) ); … … 34 36 public function simplecrumbs_shortcode( $attr ) { 35 37 $divider = ' > '; 36 $titles = '';37 $titles_divider = '|^|';38 $theCrumb = array();39 38 $strCrumb = ''; 40 39 $baseURL = get_bloginfo( 'url' ); 41 42 40 43 41 //use post id to get original title … … 51 49 ), $attr ) ); 52 50 53 54 51 $postID = ( int ) $post->ID; 55 52 $post_name = $post->post_name; … … 60 57 $pattern = array( '/\[__1__\]/','/\[__2__\]/' ); 61 58 62 63 59 //make permalink from query string 64 60 $permalink = $this->make_permalink( $query_array, $post_type ); 65 61 66 $t itles[$post_name] = get_the_title( $postID );67 $this->get_path_titles( $post , $titles);62 $this->titles[$post_name] = get_the_title( $postID ); 63 $this->get_path_titles( $post ); 68 64 69 70 65 //populate crumb structure 71 66 if ( $root ) { 72 $replace = array( $baseURL, ucfirst( $root ) );67 $replace = array( $baseURL, ucfirst( $root ) ); 73 68 $strCrumb = preg_replace( $pattern, $replace, $htmlTemplate ); 74 69 } 75 76 70 77 71 $tok = strtok( $permalink, '/'); 78 79 80 while($tok) { 72 73 while( $tok ) { 81 74 $baseURL .= sprintf( "/$tok" ); 82 75 83 if ( $tok<>'category' ) $strCrumb .= ( $strCrumb ) ? $divider : ''; 76 if ( $tok <> 'category' ) $strCrumb .= ( $strCrumb ) ? $divider : ''; 77 84 78 switch ( $tok ) { 85 86 79 // breadcrumb components which are not linked 87 // can be customi sed80 // can be customized 88 81 case 'attachment': 89 82 case 'share': 90 83 case 'tag': 91 84 case 'Search Results': 92 $strCrumb .= ucfirst( $tok);85 $strCrumb .= ucfirst( $tok ); 93 86 break; 94 95 87 case 'category': 96 88 break; 97 98 89 default: 99 if ( isset( $query_array['tag'] ) ) $t itles[$tok] = single_tag_title( "", false );90 if ( isset( $query_array['tag'] ) ) $this->titles[$tok] = single_tag_title( "", false ); 100 91 //if (isset($query_array['category_name'])) $titles[$tok] = $query_array['category_name']; 101 $replace = ( isset( $t itles[$tok] ) ) ? array( $baseURL . '/', $titles[$tok] ) : array( $baseURL . '/', ucfirst( $tok ) );92 $replace = ( isset( $this->titles[$tok] ) ) ? array( $baseURL . '/', $this->titles[$tok] ) : array( $baseURL . '/', ucfirst( $tok ) ); 102 93 $strCrumb .= preg_replace( $pattern, $replace, $htmlTemplate ); 103 94 } … … 106 97 107 98 } 99 100 return $strCrumb; 101 102 } 108 103 109 return $strCrumb; 110 111 } 112 113 function get_path_titles( $post, $titles ) { 104 function get_path_titles( $post ) { 114 105 $post_parent; 115 116 if ( $post->post_parent ) {117 $post_parent = get_post( $post->post_parent );118 $t itles[$post_parent->post_name] = get_the_title( $post_parent );119 $this->get_path_titles( $post_parent , $titles);106 107 if ( $post->post_parent ) { 108 $post_parent = get_post( $post->post_parent ); 109 $this->titles[$post_parent->post_name] = get_the_title( $post_parent ); 110 $this->get_path_titles( $post_parent ); 120 111 } 112 121 113 return; 122 114 } 123 115 124 116 // mimics get_permalink, does not parse 125 117 // page numbers 126 118 // returns ordered string 127 119 function make_permalink( $array, $post_type ) { 128 120 129 121 if ( isset( $array['s'] ) ) return 'Search Results'; 130 122 131 123 $base_URL = get_bloginfo( 'url' ); 132 124 $permalink = get_permalink(); 133 125 134 126 switch ( $post_type ) { 135 136 127 //reconstruct permalink to match link selection 137 128 case 'post': … … 144 135 145 136 if ( isset($array['tag'] ) ) $permalink .= 'tag/' . urldecode( $array['tag'] ) . '/'; 146 147 137 break; 148 149 138 case 'page': 150 139 case 'attachment': 151 140 default: 152 141 $permalink = str_replace( $base_URL, '', $permalink ); 153 154 142 } 155 143
Note: See TracChangeset
for help on using the changeset viewer.