Skip to:
Content

BuddyPress.org

Changeset 13903


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

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

Follow-up to [13901]

See #9164 and #7228

Location:
trunk/src/bp-core
Files:
7 edited

Legend:

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

    r13878 r13903  
    2626function bp_core_check_for_flood( $user_id = 0 ) {
    2727
     28    $throttle_time = bp_get_option( '_bp_throttle_time' );
     29
    2830    // Option disabled. No flood checks.
    29     if ( !$throttle_time = bp_get_option( '_bp_throttle_time' ) ) {
     31    if ( ! $throttle_time ) {
    3032        return true;
    3133    }
     
    3739
    3840    $last_posted = get_user_meta( $user_id, '_bp_last_posted', true );
    39     if ( isset( $last_posted ) && ( time() < ( $last_posted + $throttle_time ) ) && !current_user_can( 'throttle' ) ) {
     41    if ( isset( $last_posted ) && ( time() < ( $last_posted + $throttle_time ) ) && ! current_user_can( 'throttle' ) ) {
    4042        return false;
    4143    }
     
    7981    // Define local variable(s).
    8082    $_post   = array();
    81     $matches = '';
     83    $matches = array();
    8284
    8385    /** User Data ************************************************************
     
    119121            foreach ( $matches[0] as $found_url ) {
    120122                if ( 0 === strpos( $found_url, home_url() ) ) {
    121                     $num_links -=1;
     123                    --$num_links;
    122124                }
    123125            }
     
    298300
    299301        // Skip empty lines.
    300         if ( empty( $word ) ) { continue; }
     302        if ( empty( $word ) ) {
     303            continue;
     304        }
    301305
    302306        // Do some escaping magic so that '#' chars in the
     
    332336function bp_core_current_user_ip() {
    333337    $retval = '';
     338
    334339    if ( isset( $_SERVER['REMOTE_ADDR'] ) ) {
    335340        $retval = preg_replace( '/[^0-9a-fA-F:., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) );
     
    354359 */
    355360function bp_core_current_user_ua() {
     361    $retval = '';
    356362
    357363    // Sanity check the user agent.
    358364    if ( ! empty( $_SERVER['HTTP_USER_AGENT'] ) ) {
    359365        $retval = substr( $_SERVER['HTTP_USER_AGENT'], 0, 254 );
    360     } else {
    361         $retval = '';
    362366    }
    363367
  • trunk/src/bp-core/bp-core-options.php

    r13890 r13903  
    2424
    2525    // Default options.
    26     $options = array (
     26    $options = array(
    2727
    2828        /* Components ********************************************************/
     
    6464
    6565        // Allow Group Activity Deletions.
    66         'bp-disable-group-activity-deletions'   => false,
     66        'bp-disable-group-activity-deletions'  => false,
    6767
    6868        // Allow users to delete their own accounts.
     
    312312function bp_core_activate_site_options( $keys = array() ) {
    313313
    314     if ( !empty( $keys ) && is_array( $keys ) ) {
     314    if ( ! empty( $keys ) && is_array( $keys ) ) {
    315315        $bp = buddypress();
    316316
     
    321321                $bp->site_options[ $key ] = bp_get_option( $key, $default );
    322322
    323                 if ( !bp_update_option( $key, $bp->site_options[ $key ] ) ) {
     323                if ( ! bp_update_option( $key, $bp->site_options[ $key ] ) ) {
    324324                    $errors = true;
    325325                }
     
    365365    if ( false === $root_blog_options_meta ) {
    366366        $blog_options_keys      = "'" . join( "', '", (array) $root_blog_option_keys ) . "'";
    367         $blog_options_table     = bp_is_multiblog_mode() ? $wpdb->options : $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'options';
     367        $blog_options_table     = bp_is_multiblog_mode() ? $wpdb->options : $wpdb->get_blog_prefix( bp_get_root_blog_id() ) . 'options';
    368368        $blog_options_query     = "SELECT option_name AS name, option_value AS value FROM {$blog_options_table} WHERE option_name IN ( {$blog_options_keys} )";
    369369        $root_blog_options_meta = $wpdb->get_results( $blog_options_query );
     
    379379             * @param array $value Array of multisite options from sitemeta table.
    380380             */
    381             $network_options = apply_filters( 'bp_core_network_options', array(
    382                 'tags_blog_id'       => '0',
    383                 'sitewide_tags_blog' => '',
    384                 'registration'       => '0',
    385                 'fileupload_maxk'    => '1500'
    386             ) );
     381            $network_options = apply_filters(
     382                'bp_core_network_options',
     383                array(
     384                    'tags_blog_id'       => '0',
     385                    'sitewide_tags_blog' => '',
     386                    'registration'       => '0',
     387                    'fileupload_maxk'    => '1500',
     388                )
     389            );
    387390
    388391            $current_site           = get_current_site();
     
    398401        // Loop through our results and make them usable.
    399402        foreach ( $root_blog_options_meta as $root_blog_option ) {
    400             $root_blog_options[$root_blog_option->name] = $root_blog_option->value;
     403            $root_blog_options[ $root_blog_option->name ] = $root_blog_option->value;
    401404        }
    402405
     
    594597 * @since 14.0.0
    595598 *
    596  * @param bool $default Optional. Fallback value if not found in the database.
    597  *                      Default: false.
     599 * @param bool $retval Optional. Fallback value if not found in the database.
     600 *                     Default: false.
    598601 * @return bool True if group activity deletions are disabled, otherwise false.
    599602 */
    600 function bp_disable_group_activity_deletions( $default = false ) {
     603function bp_disable_group_activity_deletions( $retval = false ) {
    601604
    602605    /**
     
    605608     * @since 14.0.0
    606609     *
    607      * @param bool $value Whether or not group creator, group admin or group mod are able to delete group activity post.
    608      */
    609     return (bool) apply_filters( 'bp_disable_group_activity_deletions', (bool) bp_get_option( 'bp-disable-group-activity-deletions', $default ) );
     610     * @param bool $disable_group_deletions Whether or not group creator,
     611     *                                      group admin or group mod are able to delete group activity post.
     612     */
     613    return (bool) apply_filters( 'bp_disable_group_activity_deletions', (bool) bp_get_option( 'bp-disable-group-activity-deletions', $retval ) );
    610614}
    611615
     
    615619 * @since 1.6.0
    616620 *
    617  * @param bool $default Optional. Fallback value if not found in the database.
    618  *                      Default: true.
     621 * @param bool $retval Optional. Fallback value if not found in the database.
     622 *                     Default: true.
    619623 * @return bool True if users are able to delete their own accounts, otherwise
    620624 *              false.
    621625 */
    622 function bp_disable_account_deletion( $default = false ) {
     626function bp_disable_account_deletion( $retval = false ) {
    623627
    624628    /**
     
    627631     * @since 1.6.0
    628632     *
    629      * @param bool $value Whether or not members are able to delete their own accounts.
    630      */
    631     return apply_filters( 'bp_disable_account_deletion', (bool) bp_get_option( 'bp-disable-account-deletion', $default ) );
     633     * @param bool $disable_account_deletion Whether or not members are able to delete their own accounts.
     634     */
     635    return apply_filters( 'bp_disable_account_deletion', (bool) bp_get_option( 'bp-disable-account-deletion', $retval ) );
    632636}
    633637
     
    639643 * @todo split and move into blog and forum components.
    640644 *
    641  * @param bool $default Optional. Fallback value if not found in the database.
    642  *                      Default: false.
     645 * @param bool $retval Optional. Fallback value if not found in the database.
     646 *                     Default: false.
    643647 * @return bool True if activity comments are disabled for blog and forum
    644648 *              items, otherwise false.
    645649 */
    646 function bp_disable_blogforum_comments( $default = false ) {
     650function bp_disable_blogforum_comments( $retval = false ) {
    647651
    648652    /**
     
    651655     * @since 1.6.0
    652656     *
    653      * @param bool $value Whether or not blog and forum activity stream comments are disabled.
    654      */
    655     return (bool) apply_filters( 'bp_disable_blogforum_comments', (bool) bp_get_option( 'bp-disable-blogforum-comments', $default ) );
     657     * @param bool $disable_blog_forum_comments Whether or not blog and forum activity stream comments are disabled.
     658     */
     659    return (bool) apply_filters( 'bp_disable_blogforum_comments', (bool) bp_get_option( 'bp-disable-blogforum-comments', $retval ) );
    656660}
    657661
     
    663667 * @todo Move into groups component.
    664668 *
    665  * @param bool $default Optional. Fallback value if not found in the database.
    666  *                      Default: true.
     669 * @param bool $retval Optional. Fallback value if not found in the database.
     670 *                     Default: true.
    667671 * @return bool True if group creation is restricted, otherwise false.
    668672 */
    669 function bp_restrict_group_creation( $default = true ) {
     673function bp_restrict_group_creation( $retval = true ) {
    670674
    671675    /**
     
    674678     * @since 1.6.0
    675679     *
    676      * @param bool $value Whether or not group creation is turned off.
    677      */
    678     return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $default ) );
     680     * @param bool $group_creation Whether or not group creation is turned off.
     681     */
     682    return (bool) apply_filters( 'bp_restrict_group_creation', (bool) bp_get_option( 'bp_restrict_group_creation', $retval ) );
    679683}
    680684
     
    684688 * @since 1.6.0
    685689 *
    686  * @param bool $default Optional. Fallback value if not found in the database.
    687  *                      Default: true.
     690 * @param bool $retval Optional. Fallback value if not found in the database.
     691 *                     Default: true.
    688692 * @return bool True if Akismet is enabled, otherwise false.
    689693 */
    690 function bp_is_akismet_active( $default = true ) {
     694function bp_is_akismet_active( $retval = true ) {
    691695
    692696    /**
     
    695699     * @since 1.6.0
    696700     *
    697      * @param bool $value Whether or not Akismet is enabled.
    698      */
    699     return (bool) apply_filters( 'bp_is_akismet_active', (bool) bp_get_option( '_bp_enable_akismet', $default ) );
     701     * @param bool $akismet Whether or not Akismet is enabled.
     702     */
     703    return (bool) apply_filters( 'bp_is_akismet_active', (bool) bp_get_option( '_bp_enable_akismet', $retval ) );
    700704}
    701705
     
    705709 * @since 2.0.0
    706710 *
    707  * @param bool $default Optional. Fallback value if not found in the database.
    708  *                      Default: true.
     711 * @param bool $retval Optional. Fallback value if not found in the database.
     712 *                     Default: true.
    709713 * @return bool True if Heartbeat refresh is enabled, otherwise false.
    710714 */
    711 function bp_is_activity_heartbeat_active( $default = true ) {
     715function bp_is_activity_heartbeat_active( $retval = true ) {
    712716
    713717    /**
     
    716720     * @since 2.0.0
    717721     *
    718      * @param bool $value Whether or not Activity Heartbeat refresh is enabled.
    719      */
    720     return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $default ) );
     722     * @param bool $heartbeat_active Whether or not Activity Heartbeat refresh is enabled.
     723     */
     724    return (bool) apply_filters( 'bp_is_activity_heartbeat_active', (bool) bp_get_option( '_bp_enable_heartbeat_refresh', $retval ) );
    721725}
    722726
     
    739743     * @param string $package_id The current theme package ID.
    740744     */
    741     return apply_filters( 'bp_get_theme_package_id', bp_get_option( '_bp_theme_package_id', $package_id ) );
    742 }
     745    return apply_filters( 'bp_get_theme_package_id', (string) bp_get_option( '_bp_theme_package_id', $package_id ) );
     746}
  • trunk/src/bp-core/bp-core-rest-api.php

    r13890 r13903  
    302302 * @since 5.0.0
    303303 *
    304  * @param array|string $list List of strings.
     304 * @param array|string $collection List of strings.
    305305 * @return array Sanitized array of strings.
    306306 */
    307 function bp_rest_sanitize_string_list( $list ) {
    308     if ( ! is_array( $list ) ) {
    309         $list = preg_split( '/[\s,]+/', $list );
    310     }
    311 
    312     return array_unique( array_map( 'sanitize_text_field', $list ) );
     307function bp_rest_sanitize_string_list( $collection ) {
     308    if ( ! is_array( $collection ) ) {
     309        $collection = preg_split( '/[\s,]+/', $collection );
     310    }
     311
     312    return array_unique( array_map( 'sanitize_text_field', $collection ) );
    313313}
    314314
  • trunk/src/bp-core/bp-core-taxonomy.php

    r12728 r13903  
    154154    $taxonomy_site_map = array();
    155155    foreach ( (array) $taxonomies as $taxonomy ) {
    156         $taxonomy_site_id = bp_get_taxonomy_term_site_id( $taxonomy );
     156        $taxonomy_site_id                         = bp_get_taxonomy_term_site_id( $taxonomy );
    157157        $taxonomy_site_map[ $taxonomy_site_id ][] = $taxonomy;
    158158    }
     
    242242    $taxonomy_site_map = array();
    243243    foreach ( (array) $taxonomies as $taxonomy ) {
    244         $taxonomy_site_id = bp_get_taxonomy_term_site_id( $taxonomy );
     244        $taxonomy_site_id                         = bp_get_taxonomy_term_site_id( $taxonomy );
    245245        $taxonomy_site_map[ $taxonomy_site_id ][] = $taxonomy;
    246246    }
     
    276276 * @see get_term_by() for a full description of function and parameters.
    277277 *
    278  * @param string     $field    Either 'slug', 'name', 'id' (term_id), or 'term_taxonomy_id'
    279  * @param string|int $value    Search for this term value
     278 * @param string     $field    Either 'slug', 'name', 'id' (term_id), or 'term_taxonomy_id'.
     279 * @param string|int $value    Search for this term value.
    280280 * @param string     $taxonomy Taxonomy name. Optional, if `$field` is 'term_taxonomy_id'.
    281  * @param string     $output   Constant OBJECT, ARRAY_A, or ARRAY_N
     281 * @param string     $output   Constant OBJECT, ARRAY_A, or ARRAY_N.
    282282 * @param string     $filter   Optional, default is raw or no WordPress defined filter will applied.
    283283 *
     
    386386 * @since 7.0.0
    387387 *
    388  * @param array  $args {
    389  *     Array of arguments to query BP Terms.
     388 * @param array $args {
     389 *    Array of arguments to query BP Terms.
    390390 *     @see `get_terms()` for full description of arguments in case of a member type.
    391391 * }
     
    442442 * @since 7.0.0
    443443 *
    444  * @param int     $term_id  The BP Term ID. Required.
    445  * @param string  $taxonomy The BP Taxonomy Name. Required.
     444 * @param int    $term_id  The BP Term ID. Required.
     445 * @param string $taxonomy The BP Taxonomy Name. Required.
    446446 * @return bool|WP_Error True on success, WP_Error on failure.
    447447 */
  • trunk/src/bp-core/bp-core-template-loader.php

    r13878 r13903  
    186186
    187187        // Trim off any slashes from the template name.
    188         $template_name  = ltrim( $template_name, '/' );
     188        $template_name = ltrim( $template_name, '/' );
    189189
    190190        // Loop through template stack.
     
    253253
    254254    // Set up data array.
    255     $data = array();
     255    $data         = array();
    256256    $data['file'] = $data['uri'] = $located;
    257257
    258258    $find = array(
    259259        get_theme_root(),
    260         bp_get_theme_compat_dir()
     260        bp_get_theme_compat_dir(),
    261261    );
    262262
    263263    $replace = array(
    264264        get_theme_root_uri(),
    265         bp_get_theme_compat_url()
     265        bp_get_theme_compat_url(),
    266266    );
    267267
     
    340340
    341341    // Setup some default variables.
    342     $tag  = 'bp_template_stack';
    343     $args = $stack = array();
     342    $tag   = 'bp_template_stack';
     343    $args  = array();
     344    $stack = array();
    344345
    345346    // Add 'bp_template_stack' to the current filter array.
     
    384385     * @param array $stack Array of registered directories for template locations.
    385386     */
    386     return (array) apply_filters( 'bp_get_template_stack', $stack ) ;
     387    return (array) apply_filters( 'bp_get_template_stack', $stack );
    387388}
    388389
     
    397398 * @param string      $slug See {@link bp_get_template_part()}.
    398399 * @param string|null $name See {@link bp_get_template_part()}.
    399  * @param bool        $echo If true, template content will be echoed. If false,
     400 * @param bool        $ret If true, template content will be echoed. If false,
    400401 *                          returned. Default: true.
    401402 * @param array       $args See {@link bp_get_template_part()}.
    402403 * @return string|null If $echo, returns the template content.
    403404 */
    404 function bp_buffer_template_part( $slug, $name = null, $echo = true, $args = array() ) {
     405function bp_buffer_template_part( $slug, $name = null, $ret = true, $args = array() ) {
    405406    ob_start();
    406407
     
    417418
    418419    // Echo or return the output buffer contents.
    419     if ( true === $echo ) {
     420    if ( true === $ret ) {
    420421        // phpcs:ignore WordPress.Security.EscapeOutput
    421422        echo $output;
     
    500501        'buddypress',
    501502        'community',
    502         ''
     503        '',
    503504    );
    504505
     
    565566
    566567    // Bail if filters are suppressed on this query.
    567     if ( true == $posts_query->get( 'suppress_filters' ) ) {
     568    if ( true === $posts_query->get( 'suppress_filters' ) ) {
    568569        return;
    569570    }
     
    831832 */
    832833function bp_get_theme_compat_templates() {
    833     return bp_get_query_template( 'buddypress', array(
    834         'plugin-buddypress.php',
    835         'buddypress.php',
    836         'community.php',
    837         'generic.php',
    838         'page.php',
    839         'single.php',
    840         'singular.php',
    841         'index.php'
    842     ) );
     834    return bp_get_query_template(
     835        'buddypress',
     836        array(
     837            'plugin-buddypress.php',
     838            'buddypress.php',
     839            'community.php',
     840            'generic.php',
     841            'page.php',
     842            'single.php',
     843            'singular.php',
     844            'index.php',
     845        )
     846    );
    843847}
    844848
  • trunk/src/bp-core/bp-core-theme-compatibility.php

    r13890 r13903  
    3636
    3737    // Make sure theme package is available, set to default if not.
    38     if ( ! isset( $bp->theme_compat->packages[$theme] ) || ! is_a( $bp->theme_compat->packages[$theme], 'BP_Theme_Compat' ) ) {
     38    if ( ! isset( $bp->theme_compat->packages[ $theme ] ) || ! is_a( $bp->theme_compat->packages[ $theme ], 'BP_Theme_Compat' ) ) {
    3939        $theme = 'legacy';
    4040    }
    4141
    4242    // Set the active theme compat theme.
    43     $bp->theme_compat->theme = $bp->theme_compat->packages[$theme];
     43    $bp->theme_compat->theme = $bp->theme_compat->packages[ $theme ];
    4444}
    4545
     
    208208        $theme_compat = false;
    209209
    210     // If the theme doesn't support BP, do some additional checks.
    211     } else {
     210        // If the theme doesn't support BP, do some additional checks.
     211    } elseif ( in_array( 'bp-default', array( get_template(), get_stylesheet() ), true ) ) {
    212212        // Bail if theme is a derivative of bp-default.
    213         if ( in_array( 'bp-default', array( get_template(), get_stylesheet() ) ) ) {
    214             $theme_compat = false;
     213        $theme_compat = false;
    215214
    216215        // Brute-force check for a BP template.
    217216        // Examples are clones of bp-default.
    218         } elseif ( locate_template( 'members/members-loop.php', false, false ) ) {
    219             $theme_compat = false;
    220         }
     217    } elseif ( locate_template( 'members/members-loop.php', false, false ) ) {
     218        $theme_compat = false;
    221219    }
    222220
     
    250248 *
    251249 * @param bool $set True to set the flag to true, false to set it to false.
    252  * @return bool Returns the value of $set.
     250 * @return bool
    253251 */
    254252function bp_set_theme_compat_active( $set = true ) {
     
    462460    }
    463461
    464     bp_set_theme_compat_feature( 'legacy', array(
    465         'name'     => 'cover_image',
    466         'settings' => array(
    467             'components'   => array( 'members', 'groups' ),
    468             'width'        => $bp_content_width,
    469             'height'       => $top_offset + round( $avatar_height / 2 ),
    470             'callback'     => 'bp_legacy_theme_cover_image',
    471             'theme_handle' => $bp_handle,
    472         ),
    473     ) );
     462    bp_set_theme_compat_feature(
     463        'legacy',
     464        array(
     465            'name'     => 'cover_image',
     466            'settings' => array(
     467                'components'   => array( 'members', 'groups' ),
     468                'width'        => $bp_content_width,
     469                'height'       => $top_offset + round( $avatar_height / 2 ),
     470                'callback'     => 'bp_legacy_theme_cover_image',
     471                'theme_handle' => $bp_handle,
     472            ),
     473        )
     474    );
    474475}
    475476
     
    490491    }
    491492
    492     return (bool) ( $bp->theme_compat->original_template == $template );
     493    return (bool) ( $bp->theme_compat->original_template === $template );
    493494}
    494495
     
    524525    // Only set if the theme package was not previously registered or if the
    525526    // override flag is set.
    526     if ( empty( $bp->theme_compat->packages[$theme->id] ) || ( true === $override ) ) {
    527         $bp->theme_compat->packages[$theme->id] = $theme;
     527    if ( empty( $bp->theme_compat->packages[ $theme->id ] ) || ( true === $override ) ) {
     528        $bp->theme_compat->packages[ $theme->id ] = $theme;
    528529    }
    529530}
     
    632633
    633634    // Copy the new post global into the main $wp_query.
    634     $wp_query->post       = $post;
    635     $wp_query->posts      = array( $post );
     635    $wp_query->post  = $post;
     636    $wp_query->posts = array( $post );
    636637
    637638    // Prevent comments form from appearing.
     
    821822
    822823    // Filters exist.
    823     if ( isset( $wp_filter[$tag] ) ) {
     824    if ( isset( $wp_filter[ $tag ] ) ) {
    824825
    825826        // Filters exist in this priority.
    826         if ( ! empty( $priority ) && isset( $wp_filter[$tag][$priority] ) ) {
     827        if ( ! empty( $priority ) && isset( $wp_filter[ $tag ][ $priority ] ) ) {
    827828
    828829            // Store filters in a backup.
    829             $bp->filters->wp_filter[$tag][$priority] = $wp_filter[$tag][$priority];
     830            $bp->filters->wp_filter[ $tag ][ $priority ] = $wp_filter[ $tag ][ $priority ];
    830831
    831832            // Unset the filters.
    832             unset( $wp_filter[$tag][$priority] );
    833 
    834         // Priority is empty.
     833            unset( $wp_filter[ $tag ][ $priority ] );
     834
     835            // Priority is empty.
    835836        } else {
    836837
    837838            // Store filters in a backup.
    838             $bp->filters->wp_filter[$tag] = $wp_filter[$tag];
     839            $bp->filters->wp_filter[ $tag ] = $wp_filter[ $tag ];
    839840
    840841            // Unset the filters.
    841             unset( $wp_filter[$tag] );
     842            unset( $wp_filter[ $tag ] );
    842843        }
    843844    }
    844845
    845846    // Check merged filters.
    846     if ( isset( $merged_filters[$tag] ) ) {
     847    if ( isset( $merged_filters[ $tag ] ) ) {
    847848
    848849        // Store filters in a backup.
    849         $bp->filters->merged_filters[$tag] = $merged_filters[$tag];
     850        $bp->filters->merged_filters[ $tag ] = $merged_filters[ $tag ];
    850851
    851852        // Unset the filters.
    852         unset( $merged_filters[$tag] );
     853        unset( $merged_filters[ $tag ] );
    853854    }
    854855
     
    876877
    877878    // Filters exist.
    878     if ( isset( $bp->filters->wp_filter[$tag] ) ) {
     879    if ( isset( $bp->filters->wp_filter[ $tag ] ) ) {
    879880
    880881        // Filters exist in this priority.
    881         if ( ! empty( $priority ) && isset( $bp->filters->wp_filter[$tag][$priority] ) ) {
     882        if ( ! empty( $priority ) && isset( $bp->filters->wp_filter[ $tag ][ $priority ] ) ) {
    882883
    883884            // Store filters in a backup.
    884             $wp_filter[$tag][$priority] = $bp->filters->wp_filter[$tag][$priority];
     885            $wp_filter[ $tag ][ $priority ] = $bp->filters->wp_filter[ $tag ][ $priority ];
    885886
    886887            // Unset the filters.
    887             unset( $bp->filters->wp_filter[$tag][$priority] );
    888 
    889         // Priority is empty.
     888            unset( $bp->filters->wp_filter[ $tag ][ $priority ] );
     889
     890            // Priority is empty.
    890891        } else {
    891892
    892893            // Store filters in a backup.
    893             $wp_filter[$tag] = $bp->filters->wp_filter[$tag];
     894            $wp_filter[ $tag ] = $bp->filters->wp_filter[ $tag ];
    894895
    895896            // Unset the filters.
    896             unset( $bp->filters->wp_filter[$tag] );
     897            unset( $bp->filters->wp_filter[ $tag ] );
    897898        }
    898899    }
    899900
    900901    // Check merged filters.
    901     if ( isset( $bp->filters->merged_filters[$tag] ) ) {
     902    if ( isset( $bp->filters->merged_filters[ $tag ] ) ) {
    902903
    903904        // Store filters in a backup.
    904         $merged_filters[$tag] = $bp->filters->merged_filters[$tag];
     905        $merged_filters[ $tag ] = $bp->filters->merged_filters[ $tag ];
    905906
    906907        // Unset the filters.
    907         unset( $bp->filters->merged_filters[$tag] );
     908        unset( $bp->filters->merged_filters[ $tag ] );
    908909    }
    909910
  • trunk/src/bp-core/bp-core-update.php

    r13637 r13903  
    6060    $action = false;
    6161
    62     if ( ! empty( $_REQUEST['action'] ) && ( '-1' != $_REQUEST['action'] ) ) {
     62    if ( ! empty( $_REQUEST['action'] ) && ( '-1' !== $_REQUEST['action'] ) ) {
    6363        $action = $_REQUEST['action'];
    64     } elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' != $_REQUEST['action2'] ) ) {
     64    } elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' !== $_REQUEST['action2'] ) ) {
    6565        $action = $_REQUEST['action2'];
    6666    }
    6767
    6868    // Bail if not activating.
    69     if ( empty( $action ) || !in_array( $action, array( 'activate', 'activate-selected' ) ) ) {
     69    if ( empty( $action ) || ! in_array( $action, array( 'activate', 'activate-selected' ), true ) ) {
    7070        return false;
    7171    }
    7272
    7373    // The plugin(s) being activated.
    74     if ( $action == 'activate' ) {
     74    if ( $action === 'activate' ) {
    7575        $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array();
    7676    } else {
     
    7979
    8080    // Set basename if empty.
    81     if ( empty( $basename ) && !empty( $bp->basename ) ) {
     81    if ( empty( $basename ) && ! empty( $bp->basename ) ) {
    8282        $basename = $bp->basename;
    8383    }
     
    8989
    9090    // Is BuddyPress being activated?
    91     return in_array( $basename, $plugins );
     91    return in_array( $basename, $plugins, true );
    9292}
    9393
     
    104104    $action = false;
    105105
    106     if ( ! empty( $_REQUEST['action'] ) && ( '-1' != $_REQUEST['action'] ) ) {
     106    if ( ! empty( $_REQUEST['action'] ) && ( '-1' !== $_REQUEST['action'] ) ) {
    107107        $action = $_REQUEST['action'];
    108     } elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' != $_REQUEST['action2'] ) ) {
     108    } elseif ( ! empty( $_REQUEST['action2'] ) && ( '-1' !== $_REQUEST['action2'] ) ) {
    109109        $action = $_REQUEST['action2'];
    110110    }
    111111
    112112    // Bail if not deactivating.
    113     if ( empty( $action ) || !in_array( $action, array( 'deactivate', 'deactivate-selected' ) ) ) {
     113    if ( empty( $action ) || ! in_array( $action, array( 'deactivate', 'deactivate-selected' ), true ) ) {
    114114        return false;
    115115    }
    116116
    117117    // The plugin(s) being deactivated.
    118     if ( 'deactivate' == $action ) {
     118    if ( 'deactivate' === $action ) {
    119119        $plugins = isset( $_GET['plugin'] ) ? array( $_GET['plugin'] ) : array();
    120120    } else {
     
    123123
    124124    // Set basename if empty.
    125     if ( empty( $basename ) && !empty( $bp->basename ) ) {
     125    if ( empty( $basename ) && ! empty( $bp->basename ) ) {
    126126        $basename = $bp->basename;
    127127    }
     
    133133
    134134    // Is bbPress being deactivated?
    135     return in_array( $basename, $plugins );
     135    return in_array( $basename, $plugins, true );
    136136}
    137137
     
    184184     * @param array $value Array of default components to activate.
    185185     */
    186     $default_components = apply_filters( 'bp_new_install_default_components', array(
    187         'activity'      => 1,
    188         'members'       => 1,
    189         'settings'      => 1,
    190         'xprofile'      => 1,
    191         'notifications' => 1,
    192     ) );
    193 
    194     require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    195     require_once( buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php' );
     186    $default_components = apply_filters(
     187        'bp_new_install_default_components',
     188        array(
     189            'activity'      => 1,
     190            'members'       => 1,
     191            'settings'      => 1,
     192            'xprofile'      => 1,
     193            'notifications' => 1,
     194        )
     195    );
     196
     197    require_once ABSPATH . 'wp-admin/includes/upgrade.php';
     198    require_once buddypress()->plugin_dir . '/bp-core/admin/bp-core-admin-schema.php';
    196199    $switched_to_root_blog = false;
    197200
     
    226229        bp_delete_rewrite_rules();
    227230
    228     // Upgrades.
     231        // Upgrades.
    229232    } else {
    230233
     
    351354        foreach ( $tables as $table_name => $indexes ) {
    352355            foreach ( $indexes as $index ) {
    353                 if ( $wpdb->query( $wpdb->prepare( "SHOW TABLES LIKE %s", bp_esc_like( $table_name ) ) ) ) {
     356                if ( $wpdb->query( $wpdb->prepare( 'SHOW TABLES LIKE %s', bp_esc_like( $table_name ) ) ) ) {
    354357                    $wpdb->query( "ALTER TABLE {$table_name} DROP INDEX {$index}" );
    355358                }
     
    372375    // Delete old database version options.
    373376    delete_site_option( 'bp-activity-db-version' );
    374     delete_site_option( 'bp-blogs-db-version'    );
    375     delete_site_option( 'bp-friends-db-version'  );
    376     delete_site_option( 'bp-groups-db-version'   );
     377    delete_site_option( 'bp-blogs-db-version' );
     378    delete_site_option( 'bp-friends-db-version' );
     379    delete_site_option( 'bp-groups-db-version' );
    377380    delete_site_option( 'bp-messages-db-version' );
    378381    delete_site_option( 'bp-xprofile-db-version' );
     
    389392
    390393    // Delete possible site options.
    391     delete_site_option( 'bp-db-version'       );
    392     delete_site_option( '_bp_db_version'      );
    393     delete_site_option( 'bp-core-db-version'  );
     394    delete_site_option( 'bp-db-version' );
     395    delete_site_option( '_bp_db_version' );
     396    delete_site_option( 'bp-core-db-version' );
    394397    delete_site_option( '_bp-core-db-version' );
    395398
    396399    // Delete possible blog options.
    397     delete_blog_option( bp_get_root_blog_id(), 'bp-db-version'       );
    398     delete_blog_option( bp_get_root_blog_id(), 'bp-core-db-version'  );
     400    delete_blog_option( bp_get_root_blog_id(), 'bp-db-version' );
     401    delete_blog_option( bp_get_root_blog_id(), 'bp-core-db-version' );
    399402    delete_site_option( bp_get_root_blog_id(), '_bp-core-db-version' );
    400     delete_site_option( bp_get_root_blog_id(), '_bp_db_version'      );
     403    delete_site_option( bp_get_root_blog_id(), '_bp_db_version' );
    401404}
    402405
     
    417420
    418421    // Get the active components.
    419     $active_components          = bp_get_option( $active_components_key );
     422    $active_components = bp_get_option( $active_components_key );
    420423
    421424    // Add notifications.
    422     if ( ! in_array( $notifications_component_id, $active_components ) ) {
     425    if ( ! in_array( $notifications_component_id, $active_components, true ) ) {
    423426        $active_components[ $notifications_component_id ] = 1;
    424427    }
     
    629632            'object_type' => 'field',
    630633            'meta_key'    => 'allow_custom_visibility',
    631             'meta_value'  => 'disabled'
     634            'meta_value'  => 'disabled',
    632635        ),
    633636        array(
     
    635638            '%s',
    636639            '%s',
    637             '%s'
     640            '%s',
    638641        )
    639642    );
     
    693696            $signup_position = 0;
    694697            foreach ( $signup_fields as $signup_field_id ) {
    695                 $signup_position += 1;
     698                ++$signup_position;
    696699
    697700                $wpdb->insert(
     
    964967        array(
    965968            '%s',
    966             '%s'
     969            '%s',
    967970        )
    968971    );
     
    975978 */
    976979function bp_cleanup_friendship_activities() {
    977     bp_activity_delete( array(
    978         'component'     => buddypress()->friends->id,
    979         'type'          => 'friendship_created',
    980         'hide_sitewide' => true,
    981     ) );
     980    bp_activity_delete(
     981        array(
     982            'component'     => buddypress()->friends->id,
     983            'type'          => 'friendship_created',
     984            'hide_sitewide' => true,
     985        )
     986    );
    982987}
    983988
     
    10191024
    10201025        // If the saved page title is the same as the legacy title, there's nothing to do.
    1021         if ( $legacy_titles[ $component ] == $page->post_title ) {
     1026        if ( $legacy_titles[ $component ] === $page->post_title ) {
    10221027            continue;
    10231028        }
    10241029
    10251030        // Update the page with the legacy title.
    1026         wp_update_post( array(
    1027             'ID' => $page_id,
    1028             'post_title' => $legacy_titles[ $component ],
    1029         ) );
     1031        wp_update_post(
     1032            array(
     1033                'ID'         => $page_id,
     1034                'post_title' => $legacy_titles[ $component ],
     1035            )
     1036        );
    10301037    }
    10311038}
     
    10711078
    10721079    // Suppress errors because users shouldn't see what happens next.
    1073     $old_suppress  = $wpdb->suppress_errors();
     1080    $old_suppress = $wpdb->suppress_errors();
    10741081
    10751082    // Never use bp_core_get_table_prefix() for any global users tables.
    1076     $table_exists  = (bool) $wpdb->get_results( "DESCRIBE {$signups_table};" );
     1083    $table_exists = (bool) $wpdb->get_results( "DESCRIBE {$signups_table};" );
    10771084
    10781085    // Table already exists, so maybe upgrade instead?
     
    10871094        }
    10881095
    1089     // Table does not exist, and we are a single site, so install the multisite
    1090     // signups table using WordPress core's database schema.
     1096        // Table does not exist, and we are a single site, so install the multisite
     1097        // signups table using WordPress core's database schema.
    10911098    } elseif ( ! is_multisite() ) {
    10921099        bp_core_install_signups();
Note: See TracChangeset for help on using the changeset viewer.