Skip to:
Content

BuddyPress.org

Ticket #3652: 3652.01.patch

File 3652.01.patch, 2.7 KB (added by boonebgorges, 13 years ago)
  • bp-core/bp-core-buddybar.php

    diff --git bp-core/bp-core-buddybar.php bp-core/bp-core-buddybar.php
    index 81c9f98..010824e 100644
    function bp_core_new_nav_item( $args = '' ) { 
    6262        if ( ( -1 != $position ) && bp_is_root_component( $slug ) && !bp_displayed_user_id() )
    6363                return;
    6464
     65        do_action( 'bp_core_nav_default', $slug );
     66       
     67        extract( $bp->bp_nav[$slug] );
     68
    6569        // Look for current component
    6670        if ( bp_is_current_component( $slug ) && !bp_current_action() ) {
    6771                if ( !is_object( $screen_function[0] ) )
    function bp_core_new_nav_item( $args = '' ) { 
    7882                        if ( apply_filters( 'bp_guarantee_unique_uris', true ) ) {
    7983                                bp_core_redirect( bp_displayed_user_domain() . $slug . '/' . apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r ) );
    8084                        } else {
    81                                  $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r );
     85                                $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r );
    8286                        }
    8387                }
    8488
    function bp_core_new_nav_default( $args = '' ) { 
    124128        $r = wp_parse_args( $args, $defaults );
    125129        extract( $r, EXTR_SKIP );
    126130
    127         if ( $function = $bp->bp_nav[$parent_slug]['screen_function'] ) {
    128                 if ( !is_object( $function[0] ) )
    129                         remove_action( 'bp_screens', $function, 3 );
    130                 else
    131                         remove_action( 'bp_screens', array( &$function[0], $function[1] ), 3 );
    132         }
    133 
    134         $bp->bp_nav[$parent_slug]['screen_function'] = &$screen_function;
    135 
    136         if ( $bp->current_component == $parent_slug && !$bp->current_action ) {
    137                 if ( !is_object( $screen_function[0] ) )
    138                         add_action( 'bp_screens', $screen_function );
    139                 else
    140                         add_action( 'bp_screens', array( &$screen_function[0], $screen_function[1] ) );
     131        $bp->nav_default_resets[$parent_slug] = $r;
     132}
    141133
    142                 if ( $subnav_slug )
    143                         $bp->current_action = $subnav_slug;
     134/**
     135 * Checks to see whether the subnav default has been changed by a plugin before redirecting to
     136 * the default.
     137 *
     138 * @since 1.6
     139 * @see bp_core_new_nav_default(), where $bp->nav_default_resets is populated
     140 * @see bp_core_new_nav_item(), where the bp_core_nav_default hook is located
     141 *
     142 * @param str $slug The parent nav slug being modified
     143 */
     144function bp_core_reset_nav_default( $slug ) {
     145        global $bp;
     146       
     147        if ( isset( $bp->bp_nav[$slug] ) && isset( $bp->nav_default_resets[$slug] ) ) {
     148                $bp->bp_nav[$slug]['screen_function'] = $bp->nav_default_resets[$slug]['screen_function'];
     149                $bp->bp_nav[$slug]['default_subnav_slug'] = $bp->nav_default_resets[$slug]['subnav_slug'];
    144150        }
    145151}
     152add_action( 'bp_core_nav_default', 'bp_core_reset_nav_default' );
    146153
    147154/**
    148155 * We can only sort nav items by their position integer at a later point in time, once all