Skip to:
Content

bbPress.org

Changeset 3901


Ignore:
Timestamp:
05/15/2012 04:27:06 AM (12 years ago)
Author:
johnjamesjacoby
Message:

Breadcrumbs:

  • Wrap separator in a span if it exists.
  • Shorten $breadcrumbs variable to $crumbs for improved readability.
  • Fixes #1821 again.
  • Props netweb for original patch.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/plugin/bbp-includes/bbp-common-template.php

    r3898 r3901  
    16761676        // Define variables
    16771677        $front_id         = $root_id                                 = 0;
    1678         $ancestors        = $breadcrumbs      = $tag_data            = array();
     1678        $ancestors        = $crumbs           = $tag_data            = array();
    16791679        $pre_root_text    = $pre_front_text   = $pre_current_text    = '';
    16801680        $pre_include_root = $pre_include_home = $pre_include_current = true;
     
    18041804        // Do we want to include a link to home?
    18051805        if ( !empty( $include_home ) || empty( $home_text ) )
    1806             $breadcrumbs[] = '<a href="' . trailingslashit( home_url() ) . '" class="bbp-breadcrumb-home">' . $home_text . '</a>';
     1806            $crumbs[] = '<a href="' . trailingslashit( home_url() ) . '" class="bbp-breadcrumb-home">' . $home_text . '</a>';
    18071807
    18081808        // Do we want to include a link to the forum root?
     
    18201820
    18211821            // Add the breadcrumb
    1822             $breadcrumbs[] = '<a href="' . $root_url . '" class="bbp-breadcrumb-root">' . $root_text . '</a>';
     1822            $crumbs[] = '<a href="' . $root_url . '" class="bbp-breadcrumb-root">' . $root_text . '</a>';
    18231823        }
    18241824
     
    18371837                    // Forum
    18381838                    case bbp_get_forum_post_type() :
    1839                         $breadcrumbs[] = '<a href="' . bbp_get_forum_permalink( $parent->ID ) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title( $parent->ID ) . '</a>';
     1839                        $crumbs[] = '<a href="' . bbp_get_forum_permalink( $parent->ID ) . '" class="bbp-breadcrumb-forum">' . bbp_get_forum_title( $parent->ID ) . '</a>';
    18401840                        break;
    18411841
    18421842                    // Topic
    18431843                    case bbp_get_topic_post_type() :
    1844                         $breadcrumbs[] = '<a href="' . bbp_get_topic_permalink( $parent->ID ) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title( $parent->ID ) . '</a>';
     1844                        $crumbs[] = '<a href="' . bbp_get_topic_permalink( $parent->ID ) . '" class="bbp-breadcrumb-topic">' . bbp_get_topic_title( $parent->ID ) . '</a>';
    18451845                        break;
    18461846
    18471847                    // Reply (Note: not in most themes)
    18481848                    case bbp_get_reply_post_type() :
    1849                         $breadcrumbs[] = '<a href="' . bbp_get_reply_permalink( $parent->ID ) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title( $parent->ID ) . '</a>';
     1849                        $crumbs[] = '<a href="' . bbp_get_reply_permalink( $parent->ID ) . '" class="bbp-breadcrumb-reply">' . bbp_get_reply_title( $parent->ID ) . '</a>';
    18501850                        break;
    18511851
    18521852                    // WordPress Post/Page/Other
    18531853                    default :
    1854                         $breadcrumbs[] = '<a href="' . get_permalink( $parent->ID ) . '" class="bbp-breadcrumb-item">' . get_the_title( $parent->ID ) . '</a>';
     1854                        $crumbs[] = '<a href="' . get_permalink( $parent->ID ) . '" class="bbp-breadcrumb-item">' . get_the_title( $parent->ID ) . '</a>';
    18551855                        break;
    18561856                }
     
    18591859        // Edit topic tag
    18601860        } elseif ( bbp_is_topic_tag_edit() ) {
    1861             $breadcrumbs[] = '<a href="' . get_term_link( bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id() ) . '" class="bbp-breadcrumb-topic-tag">' . sprintf( __( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() ) . '</a>';
     1861            $crumbs[] = '<a href="' . get_term_link( bbp_get_topic_tag_id(), bbp_get_topic_tag_tax_id() ) . '" class="bbp-breadcrumb-topic-tag">' . sprintf( __( 'Topic Tag: %s', 'bbpress' ), bbp_get_topic_tag_name() ) . '</a>';
    18621862        }
    18631863
     
    18661866        // Add current page to breadcrumb
    18671867        if ( !empty( $include_current ) || empty( $pre_current_text ) )
    1868             $breadcrumbs[] = '<span class="bbp-breadcrumb-current">' . $current_text . '</span>';
    1869 
    1870         /** Finish Up *********************************************************/
     1868            $crumbs[] = '<span class="bbp-breadcrumb-current">' . $current_text . '</span>';
     1869
     1870        /** Separator *********************************************************/
     1871
     1872        // Wrap the separator in a span before padding and filter
     1873        if ( !empty( $sep ) )
     1874            $sep = '<span class="bbp-breadcrumb-separator">' . $sep . '</span>';
    18711875
    18721876        // Pad the separator
     
    18741878            $sep = str_pad( $sep, strlen( $sep ) + ( (int) $pad_sep * 2 ), ' ', STR_PAD_BOTH );
    18751879
    1876         // Allow the separator of the breadcrumb to be easily changed
    1877         $sep = apply_filters( 'bbp_breadcrumb_separator', $sep );
    1878 
    1879         // Filter breadcrumbs before imploding them
    1880         $breadcrumbs = apply_filters( 'bbp_breadcrumbs', $breadcrumbs );
     1880        /** Finish Up *********************************************************/
     1881
     1882        // Filter the separator and breadcrumb
     1883        $sep    = apply_filters( 'bbp_breadcrumb_separator', $sep    );
     1884        $crumbs = apply_filters( 'bbp_breadcrumbs',          $crumbs );
    18811885
    18821886        // Build the trail
    1883         $trail = !empty( $breadcrumbs ) ? ( $before . implode( $sep, $breadcrumbs ) . $after ) : '';
    1884 
    1885         return apply_filters( 'bbp_get_breadcrumb', $trail, $breadcrumbs, $r );
     1887        $trail = !empty( $crumbs ) ? ( $before . implode( $sep, $crumbs ) . $after ) : '';
     1888
     1889        return apply_filters( 'bbp_get_breadcrumb', $trail, $crumbs, $r );
    18861890    }
    18871891
Note: See TracChangeset for help on using the changeset viewer.