Skip to:
Content

BuddyPress.org

Changeset 4904


Ignore:
Timestamp:
07/30/2011 11:53:25 AM (13 years ago)
Author:
boonebgorges
Message:

Avoid PHP notices in bp_core_remove_nav_item() and bp_core_remove_subnav_item(). Fixes #3414. Props r-a-y

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-core/bp-core-buddybar.php

    r4867 r4904  
    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}
     
    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
     
    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 ) {
     
    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' ),
     
    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}
     
    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 ) {
     
    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}
Note: See TracChangeset for help on using the changeset viewer.