Skip to:
Content

BuddyPress.org

Ticket #3414: 3414.01.patch

File 3414.01.patch, 3.3 KB (added by r-a-y, 13 years ago)
  • bp-core/bp-core-buddybar.php

    function bp_core_new_nav_item( $args = '' ) { 
    8282                if ( !empty( $default_subnav_slug ) )
    8383                        $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r );
    8484        }
    85        
     85
    8686        do_action( 'bp_core_new_nav_item', $r, $args, $defaults );
    8787}
    8888
    function bp_core_new_subnav_item( $args = '' ) { 
    204204                'user_has_access' => $user_has_access,
    205205                'screen_function' => &$screen_function
    206206        );
    207        
     207
    208208        /**
    209209         * The last step is to hook the screen function for the added subnav item. But this only
    210210         * needs to be done if this subnav item is the current view, and the user has access to the
    function bp_core_new_subnav_item( $args = '' ) { 
    221221         *           parent nav item in $bp->bp_nav). This condition only arises when viewing a
    222222         *           user, since groups should always have an action set.
    223223         */
    224        
     224
    225225        // If we *don't* meet condition (1), return
    226226        if ( $bp->current_component != $parent_slug && $bp->current_item != $parent_slug )
    227227                return;
    228                
     228
    229229        // If we *do* meet condition (2), then the added subnav item is currently being requested
    230230        if ( ( !empty( $bp->current_action ) && $slug == $bp->current_action ) || ( bp_is_user() && empty( $bp->current_action ) && $screen_function == $bp->bp_nav[$parent_slug]['screen_function'] ) ) {
    231        
     231
    232232                // Before hooking the screen function, check user access
    233233                if ( $user_has_access ) {
    234234                        if ( !is_object( $screen_function[0] ) )
    function bp_core_new_subnav_item( $args = '' ) { 
    239239                        // When the content is off-limits, we handle the situation differently
    240240                        // depending on whether the current user is logged in
    241241                        if ( is_user_logged_in() ) {
    242                                 // Off-limits to this user. Throw an error and redirect to the displayed user's domain                 
     242                                // Off-limits to this user. Throw an error and redirect to the displayed user's domain
    243243                                bp_core_no_access( array(
    244244                                        'message'       => __( 'You do not have access to this page.', 'buddypress' ),
    245245                                        'root'          => bp_displayed_user_domain(),
    add_action( 'admin_head', 'bp_core_sort_subnav_items' ); 
    294294 */
    295295function bp_nav_item_has_subnav( $nav_item = '' ) {
    296296        global $bp;
    297        
     297
    298298        if ( !$nav_item )
    299299                $nav_item = bp_current_component();
    300        
     300
    301301        $has_subnav = isset( $bp->bp_options_nav[$nav_item] ) && count( $bp->bp_options_nav[$nav_item] ) > 0;
    302        
     302
    303303        return apply_filters( 'bp_nav_item_has_subnav', $has_subnav, $nav_item );
    304304}
    305305
    function bp_core_remove_nav_item( $parent_id ) { 
    341341function bp_core_remove_subnav_item( $parent_id, $slug ) {
    342342        global $bp;
    343343
    344         $screen_function = $bp->bp_options_nav[$parent_id][$slug]['screen_function'];
     344        $screen_function = ( isset( $bp->bp_options_nav[$parent_id][$slug]['screen_function'] ) ) ? $bp->bp_options_nav[$parent_id][$slug]['screen_function'] : false;
    345345
    346346        if ( $screen_function ) {
    347347                if ( !is_object( $screen_function[0] ) )
    function bp_core_remove_subnav_item( $parent_id, $slug ) { 
    352352
    353353        unset( $bp->bp_options_nav[$parent_id][$slug] );
    354354
    355         if ( !count( $bp->bp_options_nav[$parent_id] ) )
     355        if ( isset( $bp->bp_options_nav[$parent_id] ) && !count( $bp->bp_options_nav[$parent_id] ) )
    356356                unset($bp->bp_options_nav[$parent_id]);
    357357}
    358358