Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
06/04/2024 02:30:49 AM (20 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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.