Plugin Directory

Changeset 1105595


Ignore:
Timestamp:
03/05/2015 01:37:55 AM (11 years ago)
Author:
scriptrunner
Message:

fixed bug that caused crumbs between root page and current page to display permalink instead of page title

Location:
simple-crumbs-redux/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • simple-crumbs-redux/trunk/readme.txt

    r779041 r1105595  
    44Tags: breadcrumbs, navigation
    55Requires at least: 2.7
    6 Tested up to: 3.6.1
    7 Stable tag: 1.0.2
     6Tested up to: 4.1.1
     7Stable tag: 1.1.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    7070== Changelog ==
    7171
     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
    7281= 1.0.0 =
    73 
    7482* Initial Release.
    7583* Fixed 'PHP Fatal error: Call-time pass-by-reference has been removed' with PHP 5.4 and greater.
     
    7785* Repaced sc_unpack_query_string function with WordPress core function wp_parse_args().
    7886
    79 = 1.0.1 =
    80 
    81 * Upated readme to pass validation.
    82 
    83 
    8487== Upgrade Notice ==
    8588
    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  
    33Plugin Name: Simple Crumbs Redux
    44Plugin 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.
     5Description: 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.
    66Author: Doug Sparling
    7 Version: 1.0.2
     7Version: 1.1.0
    88Author URI: http://www.dougsparling.org
    99Note: link/crumb information from $query_string
     
    2727
    2828class SimpleCrumbsRedux {
     29    private $titles = array();
     30   
    2931    public function __construct() {
    3032        add_shortcode( 'simple_crumbs', array( $this, 'simplecrumbs_shortcode' ) );
     
    3436    public function simplecrumbs_shortcode( $attr ) {
    3537        $divider = ' > ';
    36         $titles = '';
    37         $titles_divider = '|^|';
    38         $theCrumb = array();
    3938        $strCrumb = '';
    4039        $baseURL = get_bloginfo( 'url' );
    41    
    4240   
    4341        //use post id to get original title
     
    5149        ), $attr ) );
    5250       
    53        
    5451        $postID = ( int ) $post->ID;
    5552        $post_name = $post->post_name;
     
    6057        $pattern = array( '/\[__1__\]/','/\[__2__\]/' );
    6158       
    62        
    6359        //make permalink from query string
    6460        $permalink = $this->make_permalink( $query_array, $post_type );
    6561       
    66         $titles[$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 );
    6864       
    69    
    7065        //populate crumb structure
    7166        if ( $root ) {
    72             $replace = array( $baseURL,ucfirst( $root ) );
     67            $replace = array( $baseURL, ucfirst( $root ) );
    7368            $strCrumb = preg_replace( $pattern, $replace, $htmlTemplate );
    7469        }
    75    
    7670       
    7771        $tok = strtok( $permalink, '/');
    78    
    79    
    80         while($tok) {
     72       
     73        while( $tok ) {
    8174            $baseURL .= sprintf( "/$tok" );
    8275           
    83             if ( $tok<>'category' ) $strCrumb .= ( $strCrumb ) ? $divider : '';
     76            if ( $tok <> 'category' ) $strCrumb .= ( $strCrumb ) ? $divider : '';
     77           
    8478            switch ( $tok ) {
    85                
    8679                // breadcrumb components which are not linked
    87                 // can be customised
     80                // can be customized
    8881                case 'attachment':
    8982                case 'share':
    9083                case 'tag':
    9184                case 'Search Results':
    92                     $strCrumb .= ucfirst($tok);
     85                    $strCrumb .= ucfirst( $tok );
    9386                    break;
    94    
    9587                case 'category':
    9688                    break;
    97            
    9889                default:
    99                     if ( isset( $query_array['tag'] ) ) $titles[$tok] = single_tag_title( "", false );
     90                    if ( isset( $query_array['tag'] ) ) $this->titles[$tok] = single_tag_title( "", false );
    10091                    //if (isset($query_array['category_name'])) $titles[$tok] = $query_array['category_name'];
    101                     $replace = ( isset( $titles[$tok] ) ) ? array( $baseURL . '/', $titles[$tok] ) : array( $baseURL . '/', ucfirst( $tok ) );
     92                    $replace = ( isset( $this->titles[$tok] ) ) ? array( $baseURL . '/', $this->titles[$tok] ) : array( $baseURL . '/', ucfirst( $tok ) );
    10293                    $strCrumb .= preg_replace( $pattern, $replace, $htmlTemplate );
    10394            }
     
    10697               
    10798        }
     99       
     100        return $strCrumb;
     101       
     102    }
    108103   
    109         return $strCrumb;
    110    
    111     }
    112 
    113     function get_path_titles( $post, $titles ) {
     104    function get_path_titles( $post ) {
    114105        $post_parent;
    115    
    116     if ( $post->post_parent ) {
    117         $post_parent = get_post( $post->post_parent );
    118             $titles[$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 );
    120111        }
     112       
    121113        return;
    122114    }
    123 
     115   
    124116    // mimics get_permalink, does not parse
    125117    // page numbers
    126118    // returns ordered string
    127119    function make_permalink( $array, $post_type ) {
    128    
     120       
    129121        if ( isset( $array['s'] ) ) return 'Search Results';
    130    
     122       
    131123        $base_URL = get_bloginfo( 'url' );
    132124        $permalink = get_permalink();
    133    
     125       
    134126        switch ( $post_type ) {
    135    
    136127            //reconstruct permalink to match link selection
    137128            case 'post':
     
    144135               
    145136                if ( isset($array['tag'] ) ) $permalink .= 'tag/' . urldecode( $array['tag'] ) . '/';
    146                
    147137                break;
    148        
    149138            case 'page':
    150139            case 'attachment':
    151140            default:
    152141                $permalink = str_replace( $base_URL, '', $permalink );
    153    
    154142        }
    155143       
Note: See TracChangeset for help on using the changeset viewer.