Skip to:
Content

BuddyPress.org

Changeset 13904


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

Location:
trunk/src/bp-core
Files:
5 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;
  • trunk/src/bp-core/bp-core-cache.php

    r13890 r13904  
    6565        delete_transient( 'bp_active_member_count' );
    6666}
    67 add_action( 'bp_core_activated_user',         'bp_core_clear_member_count_caches' );
     67add_action( 'bp_core_activated_user', 'bp_core_clear_member_count_caches' );
    6868add_action( 'bp_core_process_spammer_status', 'bp_core_clear_member_count_caches' );
    69 add_action( 'bp_core_deleted_account',        'bp_core_clear_member_count_caches' );
    70 add_action( 'bp_first_activity_for_member',   'bp_core_clear_member_count_caches' );
    71 add_action( 'deleted_user',                   'bp_core_clear_member_count_caches' );
     69add_action( 'bp_core_deleted_account', 'bp_core_clear_member_count_caches' );
     70add_action( 'bp_first_activity_for_member', 'bp_core_clear_member_count_caches' );
     71add_action( 'deleted_user', 'bp_core_clear_member_count_caches' );
    7272
    7373/**
     
    9393
    9494        // Bail if post ID is not a directory page.
    95         if ( ! in_array( $post_id, $page_ids ) ) {
     95        if ( ! in_array( $post_id, $page_ids, true ) ) {
    9696                return;
    9797        }
     
    134134        }
    135135
    136         $keys = array_merge( $keys, array(
    137                 'registration',
    138                 'avatar_default',
    139                 'tags_blog_id',
    140                 'sitewide_tags_blog',
    141                 'registration',
    142                 'fileupload_mask',
    143         ) );
    144 
    145         if ( in_array( $option, $keys ) ) {
     136        $keys = array_merge(
     137                $keys,
     138                array(
     139                        'registration',
     140                        'avatar_default',
     141                        'tags_blog_id',
     142                        'sitewide_tags_blog',
     143                        'registration',
     144                        'fileupload_mask',
     145                )
     146        );
     147
     148        if ( in_array( $option, $keys, true ) ) {
    146149                wp_cache_delete( 'root_blog_options', 'bp' );
    147150        }
     
    207210                $args,
    208211                array(
    209                         'object_ids'       => array(), // Comma-separated list or array of item ids.
    210                         'object_type'      => '',      // Canonical component id: groups, members, etc.
     212                        'object_ids'       => array(), // Comma-separated list or array of item ids.
     213                        'object_type'      => '',      // Canonical component id: groups, members, etc.
    211214                        'cache_group'      => '',      // Cache group.
    212                         'meta_table'       => '',      // Name of the table containing the metadata.
     215                        'meta_table'       => '',      // Name of the table containing the metadata.
    213216                        'object_column'    => '',      // DB column for the object ids (group_id, etc).
    214217                        'cache_key_prefix' => '',      // Prefix to use when creating cache key names. Eg 'bp_groups_groupmeta'.
     
    246249                if ( ! empty( $meta_list ) ) {
    247250                        foreach ( $meta_list as $metarow ) {
    248                                 $mpid = intval( $metarow[$object_column] );
     251                                $mpid = intval( $metarow[ $object_column ] );
    249252                                $mkey = $metarow['meta_key'];
    250253                                $mval = $metarow['meta_value'];
    251254
    252255                                // Force subkeys to be array type.
    253                                 if ( !isset( $cache[$mpid] ) || !is_array( $cache[$mpid] ) )
    254                                         $cache[$mpid] = array();
    255                                 if ( !isset( $cache[$mpid][$mkey] ) || !is_array( $cache[$mpid][$mkey] ) )
    256                                         $cache[$mpid][$mkey] = array();
     256                                if ( ! isset( $cache[ $mpid ] ) || ! is_array( $cache[ $mpid ] ) ) {
     257                                        $cache[ $mpid ] = array();
     258                                }
     259                                if ( ! isset( $cache[ $mpid ][ $mkey ] ) || ! is_array( $cache[ $mpid ][ $mkey ] ) ) {
     260                                        $cache[ $mpid ][ $mkey ] = array();
     261                                }
    257262
    258263                                // Add a value to the current pid/key.
    259                                 $cache[$mpid][$mkey][] = $mval;
     264                                $cache[ $mpid ][ $mkey ][] = $mval;
    260265                        }
    261266                }
     
    345350function bp_core_get_incremented_cache_key( $key, $group ) {
    346351        $incrementor = bp_core_get_incrementor( $group );
    347         $cache_key = md5( $key . $incrementor );
     352        $cache_key   = md5( $key . $incrementor );
    348353        return $cache_key;
    349354}
     
    414419 * @since 7.0.0
    415420 *
    416  * @param int $type_id The Type's term ID.
     421 * @param int    $type_id The Type's term ID.
    417422 * @param string $taxonomy The Type's taxonomy name.
    418423 */
  • 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
  • trunk/src/bp-core/bp-core-dependency.php

    r13741 r13904  
    796796         * @param string $action The action being run.
    797797         */
    798         do_action( 'bp_post_request',   $action );
     798        do_action( 'bp_post_request', $action );
    799799}
    800800
     
    838838         * @param string $action The action being run.
    839839         */
    840         do_action( 'bp_get_request',   $action );
    841 }
     840        do_action( 'bp_get_request', $action );
     841}
  • trunk/src/bp-core/bp-core-filters.php

    r13878 r13904  
    4141 *           v--WordPress Actions       v--BuddyPress Sub-actions
    4242 */
    43 add_filter( 'request',                 'bp_request',             10    );
    44 add_filter( 'template_include',        'bp_template_include',    10    );
    45 add_filter( 'login_redirect',          'bp_login_redirect',      10, 3 );
    46 add_filter( 'map_meta_cap',            'bp_map_meta_caps',      10, 4 );
     43add_filter( 'request', 'bp_request', 10 );
     44add_filter( 'template_include', 'bp_template_include', 10 );
     45add_filter( 'login_redirect', 'bp_login_redirect', 10, 3 );
     46add_filter( 'map_meta_cap', 'bp_map_meta_caps', 10, 4 );
    4747
    4848// Add some filters to feedback messages.
    49 add_filter( 'bp_core_render_message_content', 'wptexturize'       );
    50 add_filter( 'bp_core_render_message_content', 'convert_smilies'   );
    51 add_filter( 'bp_core_render_message_content', 'convert_chars'     );
    52 add_filter( 'bp_core_render_message_content', 'wpautop'           );
     49add_filter( 'bp_core_render_message_content', 'wptexturize' );
     50add_filter( 'bp_core_render_message_content', 'convert_smilies' );
     51add_filter( 'bp_core_render_message_content', 'convert_chars' );
     52add_filter( 'bp_core_render_message_content', 'wpautop' );
    5353add_filter( 'bp_core_render_message_content', 'shortcode_unautop' );
    54 add_filter( 'bp_core_render_message_content', 'wp_kses_data', 5   );
     54add_filter( 'bp_core_render_message_content', 'wp_kses_data', 5 );
    5555
    5656// Emails.
     
    7070 * bp_template_include() works and do something similar. :)
    7171 */
    72 add_filter( 'bp_template_include',   'bp_template_include_theme_supports', 2, 1 );
    73 add_filter( 'bp_template_include',   'bp_template_include_theme_compat',  4, 2 );
     72add_filter( 'bp_template_include', 'bp_template_include_theme_supports', 2, 1 );
     73add_filter( 'bp_template_include', 'bp_template_include_theme_compat', 4, 2 );
    7474
    7575// Filter BuddyPress template locations.
     
    132132
    133133        // Bail if not the root blog.
    134         if ( ! bp_is_root_blog() )
     134        if ( ! bp_is_root_blog() ) {
    135135                return $pages;
     136        }
    136137
    137138        $bp = buddypress();
    138139
    139         if ( !empty( $bp->pages->activate ) )
     140        if ( ! empty( $bp->pages->activate ) ) {
    140141                $pages[] = $bp->pages->activate->id;
    141 
    142         if ( !empty( $bp->pages->register ) )
     142        }
     143
     144        if ( ! empty( $bp->pages->register ) ) {
    143145                $pages[] = $bp->pages->register->id;
     146        }
    144147
    145148        /**
     
    169172        }
    170173
    171         if ( 'page' != $object->name ) {
     174        if ( 'page' !== $object->name ) {
    172175                return $object;
    173176        }
    174177
    175         $bp = buddypress();
     178        $bp    = buddypress();
    176179        $pages = array();
    177180
     
    270273
    271274        // Get the WP page.
    272         $page   = get_post( $item->object_id );
     275        $page = get_post( $item->object_id );
    273276
    274277        // See if we should add our highlight CSS classes for the page.
     
    285288 *
    286289 * @param array $comments The array of comments supplied to the comments template.
    287  * @param int   $post_id  The post ID.
    288290 * @return array $comments The modified comment array.
    289291 */
    290 function bp_core_filter_comments( $comments, $post_id ) {
     292function bp_core_filter_comments( $comments ) {
    291293        global $wpdb;
    292294
     
    303305        $user_ids = implode( ',', wp_parse_id_list( $user_ids ) );
    304306
    305         if ( ! $userdata = $wpdb->get_results( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" ) ) {
     307        $userdata = $wpdb->get_results( "SELECT ID as user_id, user_login, user_nicename FROM {$wpdb->users} WHERE ID IN ({$user_ids})" );
     308        if ( ! $userdata ) {
    306309                return $comments;
    307310        }
    308311
    309312        foreach ( (array) $userdata as $user ) {
    310                 $users[$user->user_id] = bp_members_get_user_url( $user->user_id );
     313                $users[ $user->user_id ] = bp_members_get_user_url( $user->user_id );
    311314        }
    312315
    313316        foreach ( (array) $comments as $i => $comment ) {
    314317                if ( ! empty( $comment->user_id ) ) {
    315                         if ( ! empty( $users[$comment->user_id] ) ) {
    316                                 $comments[$i]->comment_author_url = $users[$comment->user_id];
     318                        if ( ! empty( $users[ $comment->user_id ] ) ) {
     319                                $comments[ $i ]->comment_author_url = $users[ $comment->user_id ];
    317320                        }
    318321                }
     
    321324        return $comments;
    322325}
    323 add_filter( 'comments_array', 'bp_core_filter_comments', 10, 2 );
     326add_filter( 'comments_array', 'bp_core_filter_comments' );
    324327
    325328/**
     
    339342
    340343        // Only modify the redirect if we're on the main BP blog.
    341         if ( !bp_is_root_blog() ) {
     344        if ( ! bp_is_root_blog() ) {
    342345                return $redirect_to;
    343346        }
    344347
    345348        // Only modify the redirect once the user is logged in.
    346         if ( !is_a( $user, 'WP_User' ) ) {
     349        if ( ! is_a( $user, 'WP_User' ) ) {
    347350                return $redirect_to;
    348351        }
     
    369372        // logged-in user has any business to conduct in the Dashboard before allowing the
    370373        // redirect to go through.
    371         if ( !empty( $redirect_to ) && ( false === strpos( $redirect_to, 'wp-admin' ) || user_can( $user, 'edit_posts' ) ) ) {
     374        if ( ! empty( $redirect_to ) && ( false === strpos( $redirect_to, 'wp-admin' ) || user_can( $user, 'edit_posts' ) ) ) {
    372375                return $redirect_to;
    373376        }
     
    400403function bp_email_plaintext_entity_decode( $retval, $prop, $transform ) {
    401404        switch ( $prop ) {
    402                 case 'content_plaintext' :
    403                 case 'subject' :
     405                case 'content_plaintext':
     406                case 'subject':
    404407                        // Only decode if 'replace-tokens' is the current type.
    405408                        if ( 'replace-tokens' === $transform ) {
     
    408411                                return $retval;
    409412                        }
    410                         break;
    411 
    412                 default :
     413                default:
    413414                        return $retval;
    414                         break;
    415415        }
    416416}
     
    435435
    436436        // Don't touch the email when a user is registered by the site admin.
    437         if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page != get_current_screen()->id ) {
     437        if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page !== get_current_screen()->id ) {
    438438                return $welcome_email;
    439439        }
     
    473473
    474474        // Don't touch the email when a user is registered by the site admin.
    475         if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page != get_current_screen()->id ) {
     475        if ( ( is_admin() || is_network_admin() ) && buddypress()->members->admin->signups_page !== get_current_screen()->id ) {
    476476                return $welcome_email;
    477477        }
    478478
    479479        // Don't touch the email if we don't have a custom registration template.
    480         if ( ! bp_has_custom_signup_page() )
     480        if ( ! bp_has_custom_signup_page() ) {
    481481                return $welcome_email;
     482        }
    482483
    483484        // [User Set] Replaces $password in welcome email; Represents value set by user.
     
    506507function bp_core_activation_signup_blog_notification( $domain, $path, $title, $user, $user_email, $key ) {
    507508        $is_signup_resend = false;
    508         if ( is_admin() && buddypress()->members->admin->signups_page == get_current_screen()->id ) {
     509        if ( is_admin() && buddypress()->members->admin->signups_page === get_current_screen()->id ) {
    509510                // The admin is just approving/sending/resending the verification email.
    510511                $is_signup_resend = true;
     
    571572
    572573                // If the user is created from the WordPress Add User screen, don't send BuddyPress signup notifications.
    573                 if( in_array( get_current_screen()->id, array( 'user', 'user-network' ) ) ) {
     574                if ( in_array( get_current_screen()->id, array( 'user', 'user-network' ), true ) ) {
    574575                        // If the Super Admin want to skip confirmation email.
    575                         if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
     576                        if ( isset( $_POST['noconfirmation'] ) && is_super_admin() ) {
    576577                                return false;
    577578
    578                         // WordPress will manage the signup process.
     579                                // WordPress will manage the signup process.
    579580                        } else {
    580581                                return $user;
    581582                        }
    582583
    583                 // The site admin is approving/resending from the "manage signups" screen.
    584                 } elseif ( buddypress()->members->admin->signups_page == get_current_screen()->id ) {
     584                        // The site admin is approving/resending from the "manage signups" screen.
     585                } elseif ( buddypress()->members->admin->signups_page === get_current_screen()->id ) {
    585586                        /*
    586587                         * There can be a case where the user was created without the skip confirmation
     
    599600        }
    600601
    601         $user_id = 0;
     602        $user_id     = 0;
    602603        $user_object = get_user_by( 'login', $user );
    603604        if ( $user_object ) {
     
    732733        return apply_filters( 'bp_modify_page_title', $new_title, $title, $sep, $seplocation );
    733734}
    734 add_filter( 'wp_title',             'bp_modify_page_title', 20, 3 );
    735 add_filter( 'bp_modify_page_title', 'wptexturize'                 );
    736 add_filter( 'bp_modify_page_title', 'convert_chars'               );
    737 add_filter( 'bp_modify_page_title', 'esc_html'                    );
     735add_filter( 'wp_title', 'bp_modify_page_title', 20, 3 );
     736add_filter( 'bp_modify_page_title', 'wptexturize' );
     737add_filter( 'bp_modify_page_title', 'convert_chars' );
     738add_filter( 'bp_modify_page_title', 'esc_html' );
    738739
    739740/**
     
    760761        // We don't need to sanitize this as WordPress will take care of it.
    761762        $bp_title = array(
    762                 'title' => join( " $sep ", $bp_title_parts )
     763                'title' => join( " $sep ", $bp_title_parts ),
    763764        );
    764765
     
    799800                        $menu_item->url  = $menu_item->guid;
    800801
    801                         if ( ! in_array( array( 'bp-menu', 'bp-'. $menu_item->post_excerpt .'-nav' ), $menu_item->classes ) ) {
     802                        if ( ! in_array( array( 'bp-menu', 'bp-' . $menu_item->post_excerpt . '-nav' ), $menu_item->classes ) ) {
    802803                                $menu_item->classes[] = 'bp-menu';
    803                                 $menu_item->classes[] = 'bp-'. $menu_item->post_excerpt .'-nav';
     804                                $menu_item->classes[] = 'bp-' . $menu_item->post_excerpt . '-nav';
    804805                        }
    805806                }
     
    812813
    813814        if ( is_array( $menu_classes ) ) {
    814                 $menu_classes = implode( ' ', $menu_item->classes);
     815                $menu_classes = implode( ' ', $menu_item->classes );
    815816        }
    816817
     
    825826
    826827        switch ( $matches[1] ) {
    827                 case 'login' :
     828                case 'login':
    828829                        if ( is_user_logged_in() ) {
    829830                                $menu_item->_invalid = true;
     
    834835                        break;
    835836
    836                 case 'logout' :
     837                case 'logout':
    837838                        if ( ! is_user_logged_in() ) {
    838839                                $menu_item->_invalid = true;
     
    844845
    845846                // Don't show the Register link to logged-in users.
    846                 case 'register' :
     847                case 'register':
    847848                        if ( is_user_logged_in() ) {
    848849                                $menu_item->_invalid = true;
     
    867868                $menu_item->_invalid = true;
    868869
    869         // Highlight the current page.
     870                // Highlight the current page.
    870871        } else {
    871872                $current = bp_get_requested_url();
     
    930931 */
    931932function bp_customizer_nav_menus_set_item_types( $item_types = array() ) {
    932         $item_types = array_merge( $item_types, array(
    933                 'bp_loggedin_nav' => array(
    934                         'title'  => _x( 'BuddyPress (logged-in)', 'customizer menu section title', 'buddypress' ),
    935                         'type'   => 'bp_nav',
    936                         'object' => 'bp_loggedin_nav',
    937                 ),
    938                 'bp_loggedout_nav' => array(
    939                         'title'  => _x( 'BuddyPress (logged-out)', 'customizer menu section title', 'buddypress' ),
    940                         'type'   => 'bp_nav',
    941                         'object' => 'bp_loggedout_nav',
    942                 ),
    943         ) );
     933        $item_types = array_merge(
     934                $item_types,
     935                array(
     936                        'bp_loggedin_nav'  => array(
     937                                'title'  => _x( 'BuddyPress (logged-in)', 'customizer menu section title', 'buddypress' ),
     938                                'type'   => 'bp_nav',
     939                                'object' => 'bp_loggedin_nav',
     940                        ),
     941                        'bp_loggedout_nav' => array(
     942                                'title'  => _x( 'BuddyPress (logged-out)', 'customizer menu section title', 'buddypress' ),
     943                                'type'   => 'bp_nav',
     944                                'object' => 'bp_loggedout_nav',
     945                        ),
     946                )
     947        );
    944948
    945949        return $item_types;
     
    10531057                for ( $i = 0; $i < count( $quoted_matches[0] ); $i++ ) {
    10541058                        $quote_pos = strpos( $q, '__QUOTE__' );
    1055                         $q = substr_replace( $q, $quoted_matches[0][ $i ], $quote_pos, 9 );
     1059                        $q         = substr_replace( $q, $quoted_matches[0][ $i ], $quote_pos, 9 );
    10561060                }
    10571061        }
     
    10831087 * @since 7.0.0
    10841088 *
    1085  * @string $content Content to inject attribute into.
     1089 * @param string $content Content to inject attribute into.
    10861090 * @return string
    10871091 */
     
    10911095        }
    10921096
    1093         $content = str_replace( '<img ',    '<img loading="lazy" ',    $content );
     1097        $content = str_replace( '<img ', '<img loading="lazy" ', $content );
    10941098        $content = str_replace( '<iframe ', '<iframe loading="lazy" ', $content );
    10951099
     
    11491153        preg_match_all( '#<a[^>]+>#i', $value, $links, PREG_SET_ORDER );
    11501154        foreach ( $links as $link ) {
    1151                 $new_link = $link = array_shift( $link );
     1155                $link     = array_shift( $link );
     1156                $new_link = $link;
    11521157
    11531158                // Add/modify style property.
     
    12321237
    12331238        // Default values for tokens set conditionally below.
    1234         $tokens['email.preheader']     = '';
    1235         $tokens['recipient.email']     = '';
    1236         $tokens['recipient.name']      = '';
    1237         $tokens['recipient.username']  = '';
     1239        $tokens['email.preheader']    = '';
     1240        $tokens['recipient.email']    = '';
     1241        $tokens['recipient.name']     = '';
     1242        $tokens['recipient.username'] = '';
    12381243
    12391244        // Who is the email going to?
     
    13051310         * @param string $template Path to current template (probably single.php).
    13061311         */
    1307         $email_template = apply_filters( 'bp_core_render_email_template',
     1312        $email_template = apply_filters(
     1313                'bp_core_render_email_template',
    13081314                bp_locate_template( bp_email_get_template( get_queried_object() ), false ),
    13091315                $template
     
    13151321
    13161322        ob_start();
    1317         include( $email_template );
     1323        include $email_template;
    13181324        $template = ob_get_contents();
    13191325        ob_end_clean();
     
    13641370 */
    13651371function bp_get_post_type_link( $link = '', $post = null ) {
    1366         if (  'rewrites' === bp_core_get_query_parser() && 'buddypress' === get_post_type( $post ) ) {
     1372        if ( 'rewrites' === bp_core_get_query_parser() && 'buddypress' === get_post_type( $post ) ) {
    13671373                $bp_pages = (array) buddypress()->pages;
    13681374
Note: See TracChangeset for help on using the changeset viewer.