Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/04/2024 02:32:30 AM (2 years 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-catchuri.php

    r13767 r13904  
    4646 * @since 1.6.0
    4747 *
    48  * @return bool True if yes, false if no.
     48 * @return bool
    4949 */
    5050function bp_core_enable_root_profiles() {
    … …  
    5252        $retval = false;
    5353
    54         if ( defined( 'BP_ENABLE_ROOT_PROFILES' ) && ( true == BP_ENABLE_ROOT_PROFILES ) )
     54        if ( defined( 'BP_ENABLE_ROOT_PROFILES' ) && ( true === BP_ENABLE_ROOT_PROFILES ) ) {
    5555                $retval = true;
     56        }
    5657
    5758        /**
    … …  
    8283
    8384        // Reset the post.
    84         bp_theme_compat_reset_post( array(
    85                 'ID'          => 0,
    86                 'is_404'      => true,
    87                 'post_status' => 'publish',
    88         ) );
     85        bp_theme_compat_reset_post(
     86                array(
     87                        'ID'          => 0,
     88                        'is_404'      => true,
     89                        'post_status' => 'publish',
     90                )
     91        );
    8992
    9093        // Set theme compat to false since the reset post function automatically sets
    … …  
    118121                }
    119122
    120         // Theme compat doesn't require a template lookup.
     123                // Theme compat doesn't require a template lookup.
    121124        } else {
    122125                $template = '';
    … …  
    185188                exit();
    186189
    187         // No template found, so setup theme compatibility.
    188         // @todo Some other 404 handling if theme compat doesn't kick in.
     190                // No template found, so setup theme compatibility.
     191                // @todo Some other 404 handling if theme compat doesn't kick in.
    189192        } else {
    190193
    … …  
    291294        // If coming from bp_core_redirect() and $bp_no_status_set is true,
    292295        // we are redirecting to an accessible page so skip this check.
    293         if ( !empty( $bp->no_status_set ) )
     296        if ( ! empty( $bp->no_status_set ) ) {
    294297                return false;
    295 
    296         if ( !isset( $wp_query->queried_object ) && !bp_is_blog_page() ) {
     298        }
     299
     300        if ( ! isset( $wp_query->queried_object ) && ! bp_is_blog_page() ) {
    297301                bp_do_404();
    298302        }
    … …  
    310314 *
    311315 * @param array|string $args {
     316 *     Optional. Array of arguments for redirecting user when visiting access controlled areas.
    312317 *     @type int    $mode     Specifies the destination of the redirect. 1 will
    313318 *                            direct to the root domain (home page), which assumes you have a
    … …  
    332337                'redirect' => $redirect_url,        // the URL you get redirected to when a user successfully logs in.
    333338                'root'     => bp_get_root_url(),    // the landing page you get redirected to when a user doesn't have access.
    334                 'message'  => __( 'You must log in to access the page you requested.', 'buddypress' )
     339                'message'  => __( 'You must log in to access the page you requested.', 'buddypress' ),
    335340        );
    336341
    … …  
    348353         */
    349354        $r = apply_filters( 'bp_core_no_access', $r );
     355
    350356        extract( $r, EXTR_SKIP );
    351357
    … …  
    353359         * @ignore Ignore these filters and use 'bp_core_no_access' above.
    354360         */
    355         $mode     = apply_filters( 'bp_no_access_mode',     $mode,     $root,    $redirect, $message );
    356         $redirect = apply_filters( 'bp_no_access_redirect', $redirect, $root,     $message,  $mode    );
    357         $root     = apply_filters( 'bp_no_access_root',     $root,     $redirect, $message,  $mode    );
    358         $message  = apply_filters( 'bp_no_access_message',  $message,  $root,     $redirect, $mode    );
     361        $mode     = apply_filters( 'bp_no_access_mode', $mode, $root, $redirect, $message );
     362        $redirect = apply_filters( 'bp_no_access_redirect', $redirect, $root, $message, $mode );
     363        $root     = apply_filters( 'bp_no_access_root', $root, $redirect, $message, $mode );
     364        $message  = apply_filters( 'bp_no_access_message', $message, $root, $redirect, $mode );
    359365        $root     = trailingslashit( $root );
    360366
    … …  
    363369                // Option to redirect to wp-login.php.
    364370                // Error message is displayed with bp_core_no_access_wp_login_error().
    365                 case 2 :
    366                         if ( !empty( $redirect ) ) {
    367                                 bp_core_redirect( add_query_arg( array(
    368                                         'bp-auth' => 1,
    369                                         'action'  => 'bpnoaccess'
    370                                 ), wp_login_url( $redirect ) ) );
     371                case 2:
     372                        if ( ! empty( $redirect ) ) {
     373                                bp_core_redirect(
     374                                        add_query_arg(
     375                                                array(
     376                                                        'bp-auth' => 1,
     377                                                        'action'  => 'bpnoaccess',
     378                                                ),
     379                                                wp_login_url( $redirect )
     380                                        )
     381                                );
    371382                        } else {
    372383                                bp_core_redirect( $root );
    … …  
    377388                // Redirect to root with "redirect_to" parameter.
    378389                // Error message is displayed with bp_core_add_message().
    379                 case 1 :
    380                 default :
    381 
     390                case 1:
     391                default:
    382392                        $url = $root;
    383                         if ( !empty( $redirect ) ) {
     393                        if ( ! empty( $redirect ) ) {
    384394                                $url = add_query_arg( 'redirect_to', urlencode( $redirect ), $root );
    385395                        }
    386396
    387                         if ( !empty( $message ) ) {
     397                        if ( ! empty( $message ) ) {
    388398                                bp_core_add_message( $message, 'error' );
    389399                        }
    … …  
    502512
    503513                // Build the URL in the address bar.
    504                 $requested_url  = bp_get_requested_url();
    505                 $query_args     = '';
     514                $requested_url = bp_get_requested_url();
     515                $query_args    = '';
    506516
    507517                // Stash query args.
    … …  
    582592        // is set to be the front page, ensure that the current canonical URL
    583593        // is the home page URL.
    584         if ( 'page' == get_option( 'show_on_front' ) && $page_on_front = (int) get_option( 'page_on_front' ) ) {
    585                 $front_page_component = array_search( $page_on_front, bp_core_get_directory_page_ids() );
     594        if ( 'page' === get_option( 'show_on_front' ) && $page_on_front = (int) get_option( 'page_on_front' ) ) {
     595                $front_page_component = array_search( $page_on_front, bp_core_get_directory_page_ids(), true );
    586596
    587597                /*
    … …  
    595605                        $bp->canonical_stack['canonical_url'] = trailingslashit( bp_get_root_url() );
    596606
    597                 // Except when the front page is set to the registration page
    598                 // and the current user is logged in. In this case we send to
    599                 // the members directory to avoid redirect loops.
    600                 } elseif ( bp_is_register_page() && 'register' == $front_page_component && is_user_logged_in() ) {
     607                        // Except when the front page is set to the registration page
     608                        // and the current user is logged in. In this case we send to
     609                        // the members directory to avoid redirect loops.
     610                } elseif ( bp_is_register_page() && 'register' === $front_page_component && is_user_logged_in() ) {
    601611
    602612                        /**
    … …  
    613623        if ( empty( $bp->canonical_stack['canonical_url'] ) ) {
    614624                // Build the URL in the address bar.
    615                 $requested_url  = bp_get_requested_url();
    616                 $base_url       = '';
    617                 $path_chunks    = array();
    618                 $component_id   = '';
     625                $requested_url = bp_get_requested_url();
     626                $base_url      = '';
     627                $path_chunks   = array();
     628                $component_id  = '';
    619629
    620630                // Get query args.
    … …  
    678688                } elseif ( isset( $query_args['bp_member_action'] ) && 'members' === $component_id ) {
    679689                        unset( $query_args['bp_member_action'] );
    680                 } elseif( isset( $query_args['bp_group_action'] ) && 'groups' === $component_id ) {
     690                } elseif ( isset( $query_args['bp_group_action'] ) && 'groups' === $component_id ) {
    681691                        unset( $query_args['bp_group_action'] );
    682692                }
    … …  
    750760 */
    751761function _bp_maybe_remove_redirect_canonical() {
    752         if ( ! bp_is_blog_page() )
     762        if ( ! bp_is_blog_page() ) {
    753763                remove_action( 'template_redirect', 'redirect_canonical' );
     764        }
    754765}
    755766
Note: See TracChangeset for help on using the changeset viewer.