Changeset 13904 for trunk/src/bp-core/bp-core-buddybar.php
- Timestamp:
- 06/04/2024 02:32:30 AM (21 months ago)
- File:
-
- 1 edited
-
trunk/src/bp-core/bp-core-buddybar.php (modified) (20 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/bp-core/bp-core-buddybar.php
r13878 r13904 72 72 // Then, hook the screen function for the added nav item. 73 73 $hooked = bp_core_register_nav_screen_function( $nav_item ); 74 if ( false === $hooked ) {74 if ( false === $hooked ) { 75 75 return false; 76 76 } … … 129 129 'position' => 99, // Index of where this nav item should be positioned. 130 130 'screen_function' => false, // The name of the function to run when clicked. 131 'default_subnav_slug' => false // The slug of the default subnav item to select when clicked.131 'default_subnav_slug' => false, // The slug of the default subnav item to select when clicked. 132 132 ); 133 133 … … 163 163 'position' => $r['position'], 164 164 'screen_function' => &$r['screen_function'], 165 'default_subnav_slug' => $r['default_subnav_slug']165 'default_subnav_slug' => $r['default_subnav_slug'], 166 166 ); 167 167 … … 218 218 'position' => 99, // Index of where this nav item should be positioned. 219 219 'screen_function' => false, // The name of the function to run when clicked. 220 'default_subnav_slug' => false // The slug of the default subnav item to select when clicked.220 'default_subnav_slug' => false, // The slug of the default subnav item to select when clicked. 221 221 ); 222 222 … … 253 253 * directory or something else. 254 254 */ 255 if ( ( -1 != $r['position'] ) && bp_is_root_component( $r['slug'] ) && ! bp_displayed_user_id() ) {255 if ( ( -1 !== $r['position'] ) && bp_is_root_component( $r['slug'] ) && ! bp_displayed_user_id() ) { 256 256 return; 257 257 } … … 307 307 * 308 308 * @param array|string $args { 309 * Optional. Array describing the new default subnav item. 310 * 309 311 * @type string $parent_slug The slug of the nav item whose default is being changed. 310 312 * @type callable $screen_function The new default callback function that will run when the nav item is clicked. … … 318 320 'parent_slug' => false, // Slug of the parent. 319 321 'screen_function' => false, // The name of the function to run when clicked. 320 'subnav_slug' => false // The slug of the subnav item to select when clicked.322 'subnav_slug' => false, // The slug of the subnav item to select when clicked. 321 323 ); 322 324 … … 330 332 331 333 if ( ! $parent_nav ) { 332 return ;334 return; 333 335 } 334 336 … … 381 383 // The only way to tell whether to set the subnav is to peek at the unfiltered_uri 382 384 // Find the component. 383 $component_uri_key = array_search( $parent_nav->slug, $bp->unfiltered_uri );385 $component_uri_key = array_search( $parent_nav->slug, $bp->unfiltered_uri, true ); 384 386 385 387 if ( false !== $component_uri_key ) { 386 if ( ! empty( $bp->unfiltered_uri[ $component_uri_key + 1] ) ) {387 $unfiltered_action = $bp->unfiltered_uri[ $component_uri_key + 1];388 if ( ! empty( $bp->unfiltered_uri[ $component_uri_key + 1 ] ) ) { 389 $unfiltered_action = $bp->unfiltered_uri[ $component_uri_key + 1 ]; 388 390 } 389 391 } … … 415 417 } 416 418 417 // The URL is explicitly requesting the new subnav item, but should be418 // directed to the canonical URL.419 } elseif ( $unfiltered_action == $r['subnav_slug'] ) {419 // The URL is explicitly requesting the new subnav item, but should be 420 // directed to the canonical URL. 421 } elseif ( $unfiltered_action === $r['subnav_slug'] ) { 420 422 unset( $bp->canonical_stack['action'] ); 421 423 422 // In all other cases (including the case where the original subnav item423 // is explicitly called in the URL), the canonical URL will contain the424 // subnav slug.424 // In all other cases (including the case where the original subnav item 425 // is explicitly called in the URL), the canonical URL will contain the 426 // subnav slug. 425 427 } else { 426 428 $bp->canonical_stack['action'] = bp_current_action(); 427 429 } 428 430 } 429 430 return;431 431 } 432 432 … … 459 459 * Admin Bar menu for group admins. Default: false. 460 460 * } 461 * @param string|null $component The component the navigation is attached to. Defaults to 'members'.461 * @param string|null $component The component the navigation is attached to. Defaults to 'members'. 462 462 * @return null|false Returns false on failure. 463 463 */ … … 637 637 $args, 638 638 array( 639 'slug' => false, // URL slug for the screen.640 'parent_slug' => false, // URL slug of the parent screen.641 'user_has_access' => true, // Can the user visit this screen?642 'no_access_url' => '',643 'site_admin_only' => false, // Can only site admins visit this screen?644 'screen_function' => false, // The name of the function to run when clicked.639 'slug' => false, // URL slug for the screen. 640 'parent_slug' => false, // URL slug of the parent screen. 641 'user_has_access' => true, // Can the user visit this screen? 642 'no_access_url' => '', 643 'site_admin_only' => false, // Can only site admins visit this screen? 644 'screen_function' => false, // The name of the function to run when clicked. 645 645 ) 646 646 ); … … 674 674 675 675 // If we *do* meet condition (2), then the added subnav item is currently being requested. 676 if ( ( bp_current_action() && bp_is_current_action( $r['slug'] ) ) || ( bp_is_user() && ! bp_current_action() && ! empty( $parent_nav->screen_function ) && $r['screen_function'] == $parent_nav->screen_function ) ) {676 if ( ( bp_current_action() && bp_is_current_action( $r['slug'] ) ) || ( bp_is_user() && ! bp_current_action() && ! empty( $parent_nav->screen_function ) && $r['screen_function'] === $parent_nav->screen_function ) ) { 677 677 678 678 // If this is for site admins only and the user is not one, don't create the subnav item. … … 719 719 $retval['status'] = 'failure'; 720 720 721 // Success - hook to bp_screens.721 // Success - hook to bp_screens. 722 722 } else { 723 723 add_action( 'bp_screens', $subnav_item['screen_function'], 3 ); … … 725 725 } 726 726 727 // User doesn't have access. Determine redirect arguments based on728 // user status.727 // User doesn't have access. Determine redirect arguments based on 728 // user status. 729 729 } else { 730 730 $retval['status'] = 'failure'; … … 739 739 $redirect_to = trailingslashit( $subnav_item['no_access_url'] ); 740 740 741 // In the case of a user page, we try to assume a742 // redirect URL.741 // In the case of a user page, we try to assume a 742 // redirect URL. 743 743 } elseif ( bp_is_user() ) { 744 744 … … 755 755 $redirect_to = bp_displayed_user_url(); 756 756 757 // In some cases, the default tab is not accessible to758 // the logged-in user. So we fall back on a tab that we759 // know will be accessible.757 // In some cases, the default tab is not accessible to 758 // the logged-in user. So we fall back on a tab that we 759 // know will be accessible. 760 760 } else { 761 761 // Try 'activity' first. … … 771 771 } 772 772 773 // Fall back to the home page.773 // Fall back to the home page. 774 774 } else { 775 775 $message = __( 'You do not have access to this page.', 'buddypress' ); … … 781 781 'root' => $redirect_to, 782 782 'redirect' => false, 783 'mode' => 1 783 'mode' => 1, 784 784 ); 785 785 … … 987 987 function bp_get_admin_bar_pref( $context, $user = 0 ) { 988 988 $pref = get_user_option( "show_admin_bar_{$context}", $user ); 989 if ( false === $pref ) 989 if ( false === $pref ) { 990 990 return true; 991 } 991 992 992 993 return 'true' === $pref;
Note: See TracChangeset
for help on using the changeset viewer.