Skip to:
Content

bbPress.org


Ignore:
Timestamp:
05/10/2011 04:31:29 AM (15 years ago)
Author:
johnjamesjacoby
Message:

Add forum root to breadcrumb if root slug is equal to the path of an existing page. Update field CSS styling to play more nicely with theme compatibility. Replace breadcrumb titles with breadcrumb template part.

File:
1 edited

Legend:

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

    r3118 r3130  
    10861086 *
    10871087 * @param string $sep Separator. Defaults to '←'
     1088 * @param bool $current_page Include the current item
     1089 * @param bool $root Include the root page if one exists
    10881090 * @uses bbp_get_breadcrumb() To get the breadcrumb
    10891091 */
     
    10981100 *
    10991101 * @param string $sep Separator. Defaults to '←'
     1102 * @param bool $current_page Include the current item
     1103 * @param bool $root Include the root page if one exists
    11001104 * @uses bbp_get_breadcrumb() To get the breadcrumb
    11011105 */
    1102 function bbp_breadcrumb( $sep = ' › ', $current_page = true ) {
    1103     echo bbp_get_breadcrumb( $sep );
     1106function bbp_breadcrumb( $sep = ' › ', $current_page = true, $root = true ) {
     1107    echo bbp_get_breadcrumb( $sep, $current_page, $root );
    11041108}
    11051109    /**
     
    11091113     *
    11101114     * @param string $sep Separator. Defaults to '←'
     1115     * @param bool $current_page Include the current item
     1116     * @param bool $root Include the root page if one exists
     1117     *
    11111118     * @uses get_post() To get the post
    11121119     * @uses bbp_get_forum_permalink() To get the forum link
     
    11241131     * @return string Breadcrumbs
    11251132     */
    1126     function bbp_get_breadcrumb( $sep = ' › ', $current_page = true ) {
     1133    function bbp_get_breadcrumb( $sep = ' › ', $current_page = true, $root = true ) {
    11271134        global $post, $bbp;
    11281135
     
    11321139
    11331140        // Get post ancestors
    1134         $ancestors   = array_reverse( get_post_ancestors( $post->ID ) );
     1141        $ancestors = array_reverse( get_post_ancestors( $post->ID ) );
     1142
     1143        // Do we want to include the forum root?
     1144        if ( !empty( $root ) && ( get_option( '_bbp_include_root' ) ) && ( $root_slug = get_option( '_bbp_root_slug' ) ) ) {
     1145
     1146            // Page exists at the root slug location, so add it to the breadcrumb
     1147            if ( $page = get_page_by_path( $root_slug ) ) {
     1148                $breadcrumbs[] = '<a href="' . trailingslashit( home_url( $root_slug ) ) . '">' . get_the_title( $page->ID ) . '</a>';
     1149            }
     1150        }
    11351151
    11361152        // Loop through parents
Note: See TracChangeset for help on using the changeset viewer.