Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/04/2024 02:32:30 AM (21 months ago)
Author:
espellcaste
Message:

WPCS: Part XI: miscellaneous fixes for some of the files of the core component.

Follow-up to [13903]

See #9164 and #7228

File:
1 edited

Legend:

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

    r13878 r13904  
    7272    // Then, hook the screen function for the added nav item.
    7373    $hooked = bp_core_register_nav_screen_function( $nav_item );
    74     if ( false === $hooked ){
     74    if ( false === $hooked ) {
    7575        return false;
    7676    }
     
    129129        'position'                => 99,    // Index of where this nav item should be positioned.
    130130        '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.
    132132    );
    133133
     
    163163        'position'                => $r['position'],
    164164        'screen_function'         => &$r['screen_function'],
    165         'default_subnav_slug'     => $r['default_subnav_slug']
     165        'default_subnav_slug'     => $r['default_subnav_slug'],
    166166    );
    167167
     
    218218        'position'                => 99,    // Index of where this nav item should be positioned.
    219219        '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.
    221221    );
    222222
     
    253253     * directory or something else.
    254254     */
    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() ) {
    256256        return;
    257257    }
     
    307307 *
    308308 * @param array|string $args {
     309 *     Optional. Array describing the new default subnav item.
     310 *
    309311 *     @type string   $parent_slug     The slug of the nav item whose default is being changed.
    310312 *     @type callable $screen_function The new default callback function that will run when the nav item is clicked.
     
    318320        'parent_slug'     => false, // Slug of the parent.
    319321        '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.
    321323    );
    322324
     
    330332
    331333    if ( ! $parent_nav ) {
    332         return ;
     334        return;
    333335    }
    334336
     
    381383        // The only way to tell whether to set the subnav is to peek at the unfiltered_uri
    382384        // 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 );
    384386
    385387        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 ];
    388390            }
    389391        }
     
    415417            }
    416418
    417         // The URL is explicitly requesting the new subnav item, but should be
    418         // 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'] ) {
    420422            unset( $bp->canonical_stack['action'] );
    421423
    422         // In all other cases (including the case where the original subnav item
    423         // is explicitly called in the URL), the canonical URL will contain the
    424         // 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.
    425427        } else {
    426428            $bp->canonical_stack['action'] = bp_current_action();
    427429        }
    428430    }
    429 
    430     return;
    431431}
    432432
     
    459459 *                                          Admin Bar menu for group admins. Default: false.
    460460 * }
    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'.
    462462 * @return null|false Returns false on failure.
    463463 */
     
    637637        $args,
    638638        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.
    645645        )
    646646    );
     
    674674
    675675    // 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 ) ) {
    677677
    678678        // If this is for site admins only and the user is not one, don't create the subnav item.
     
    719719            $retval['status'] = 'failure';
    720720
    721         // Success - hook to bp_screens.
     721            // Success - hook to bp_screens.
    722722        } else {
    723723            add_action( 'bp_screens', $subnav_item['screen_function'], 3 );
     
    725725        }
    726726
    727     // User doesn't have access. Determine redirect arguments based on
    728     // user status.
     727        // User doesn't have access. Determine redirect arguments based on
     728        // user status.
    729729    } else {
    730730        $retval['status'] = 'failure';
     
    739739                $redirect_to = trailingslashit( $subnav_item['no_access_url'] );
    740740
    741             // In the case of a user page, we try to assume a
    742             // redirect URL.
     741                // In the case of a user page, we try to assume a
     742                // redirect URL.
    743743            } elseif ( bp_is_user() ) {
    744744
     
    755755                    $redirect_to = bp_displayed_user_url();
    756756
    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.
     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.
    760760                } else {
    761761                    // Try 'activity' first.
     
    771771                }
    772772
    773             // Fall back to the home page.
     773                // Fall back to the home page.
    774774            } else {
    775775                $message     = __( 'You do not have access to this page.', 'buddypress' );
     
    781781                'root'     => $redirect_to,
    782782                'redirect' => false,
    783                 'mode'     => 1
     783                'mode'     => 1,
    784784            );
    785785
     
    987987function bp_get_admin_bar_pref( $context, $user = 0 ) {
    988988    $pref = get_user_option( "show_admin_bar_{$context}", $user );
    989     if ( false === $pref )
     989    if ( false === $pref ) {
    990990        return true;
     991    }
    991992
    992993    return 'true' === $pref;
Note: See TracChangeset for help on using the changeset viewer.