Ticket #3414: 3414.01.patch
File 3414.01.patch, 3.3 KB (added by , 13 years ago) |
---|
-
bp-core/bp-core-buddybar.php
function bp_core_new_nav_item( $args = '' ) { 82 82 if ( !empty( $default_subnav_slug ) ) 83 83 $bp->current_action = apply_filters( 'bp_default_component_subnav', $default_subnav_slug, $r ); 84 84 } 85 85 86 86 do_action( 'bp_core_new_nav_item', $r, $args, $defaults ); 87 87 } 88 88 … … function bp_core_new_subnav_item( $args = '' ) { 204 204 'user_has_access' => $user_has_access, 205 205 'screen_function' => &$screen_function 206 206 ); 207 207 208 208 /** 209 209 * The last step is to hook the screen function for the added subnav item. But this only 210 210 * 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 = '' ) { 221 221 * parent nav item in $bp->bp_nav). This condition only arises when viewing a 222 222 * user, since groups should always have an action set. 223 223 */ 224 224 225 225 // If we *don't* meet condition (1), return 226 226 if ( $bp->current_component != $parent_slug && $bp->current_item != $parent_slug ) 227 227 return; 228 228 229 229 // If we *do* meet condition (2), then the added subnav item is currently being requested 230 230 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 232 232 // Before hooking the screen function, check user access 233 233 if ( $user_has_access ) { 234 234 if ( !is_object( $screen_function[0] ) ) … … function bp_core_new_subnav_item( $args = '' ) { 239 239 // When the content is off-limits, we handle the situation differently 240 240 // depending on whether the current user is logged in 241 241 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 243 243 bp_core_no_access( array( 244 244 'message' => __( 'You do not have access to this page.', 'buddypress' ), 245 245 'root' => bp_displayed_user_domain(), … … add_action( 'admin_head', 'bp_core_sort_subnav_items' ); 294 294 */ 295 295 function bp_nav_item_has_subnav( $nav_item = '' ) { 296 296 global $bp; 297 297 298 298 if ( !$nav_item ) 299 299 $nav_item = bp_current_component(); 300 300 301 301 $has_subnav = isset( $bp->bp_options_nav[$nav_item] ) && count( $bp->bp_options_nav[$nav_item] ) > 0; 302 302 303 303 return apply_filters( 'bp_nav_item_has_subnav', $has_subnav, $nav_item ); 304 304 } 305 305 … … function bp_core_remove_nav_item( $parent_id ) { 341 341 function bp_core_remove_subnav_item( $parent_id, $slug ) { 342 342 global $bp; 343 343 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; 345 345 346 346 if ( $screen_function ) { 347 347 if ( !is_object( $screen_function[0] ) ) … … function bp_core_remove_subnav_item( $parent_id, $slug ) { 352 352 353 353 unset( $bp->bp_options_nav[$parent_id][$slug] ); 354 354 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] ) ) 356 356 unset($bp->bp_options_nav[$parent_id]); 357 357 } 358 358