Skip to:
Content

BuddyPress.org

Changeset 3653


Ignore:
Timestamp:
01/04/2011 07:10:08 PM (14 years ago)
Author:
djpaul
Message:

Use wp_page_menu's show_home parameter to create the "home" item in the main nav. Fixes #2994

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-themes/bp-default/functions.php

    r3631 r3653  
    474474 * Used when the custom menus haven't been configured.
    475475 *
     476 * @global $bp The global BuddyPress settings variable created in bp_core_setup_globals()
    476477 * @param array Menu arguments from wp_nav_menu()
    477  * @package BuddyPress Theme
    478478 * @see wp_nav_menu()
    479479 * @since 1.3
     
    483483
    484484    $pages_args = array(
    485         'title_li' => '',
    486         'depth' => '0',
    487         'exclude' => bp_dtheme_page_on_front()
     485        'depth'      => 0,
     486        'echo'       => false,
     487        'exclude'    => '',
     488        'title_li'   => ''
    488489    );
    489490
     
    494495        $pages_args['exclude'] .= $bp->pages->forums->id;
    495496    }
    496 ?>
    497     <ul id="nav">
    498         <li<?php if ( is_front_page() ) : ?> class="selected"<?php endif; ?>>
    499             <a href="<?php echo home_url() ?>" title="<?php _e( 'Home', 'buddypress' ) ?>"><?php _e( 'Home', 'buddypress' ) ?></a>
    500         </li>
    501 
    502         <?php wp_list_pages( $pages_args ) ?>
    503         <?php do_action( 'bp_nav_items' ) ?>
    504     </ul><!-- #nav -->
    505 <?php
     497
     498    $menu = wp_page_menu( $pages_args );
     499    $menu = str_replace( array( '<div class="menu"><ul>', '</ul></div>' ), array( '<ul id="nav">', '</ul><!-- #nav -->' ), $menu );
     500    echo $menu;
     501
     502    do_action( 'bp_nav_items' );
    506503}
    507504endif;
     505
     506/**
     507 * Get our wp_nav_menu() fallback, bp_dtheme_main_nav(), to show a home link.
     508 *
     509 * @param array $args Default values for wp_page_menu()
     510 * @see wp_page_menu()
     511 * @since 1.3
     512 */
     513function bp_dtheme_page_menu_args( $args ) {
     514    $args['show_home'] = true;
     515    return $args;
     516}
     517add_filter( 'wp_page_menu_args', 'bp_dtheme_page_menu_args' );
    508518
    509519/**
Note: See TracChangeset for help on using the changeset viewer.