Skip to:
Content

BuddyPress.org


Ignore:
Timestamp:
07/23/2024 01:13:42 AM (22 months ago)
Author:
espellcaste
Message:

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

Follow-up to [13904]

See #9174 and #9173

File:
1 edited

Legend:

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

    r13395 r13968  
    1010 *
    1111 * @package BuddyPress
    12  * @subpackage WPAbstraction
     12 * @subpackage Core
    1313 * @since 1.2.0
    1414 */
     
    2424 * @global string $wp_version WP Version number.
    2525 *
    26  * @return double
     26 * @return float
    2727 */
    2828function bp_get_major_wp_version() {
     
    3535 * Only add MS-specific abstraction functions if WordPress is not in multisite mode.
    3636 */
    37 if ( !is_multisite() ) {
     37if ( ! is_multisite() ) {
    3838    global $wpdb;
    3939
     
    4141    $wpdb->blogid      = BP_ROOT_BLOG;
    4242
    43     if ( !function_exists( 'get_blog_option' ) ) {
     43    if ( ! function_exists( 'get_blog_option' ) ) {
    4444
    4545        /**
     
    5252         * @param int    $blog_id     Blog ID to fetch for. Not used.
    5353         * @param string $option_name Option name to fetch.
    54          * @param bool   $default     Whether or not default.
     54         * @param bool   $default     Optional. Default value to return if the option does not exist.
    5555         * @return mixed
    5656         */
     
    7272         * @param string $option_name  Option name to add.
    7373         * @param mixed  $option_value Option value to add.
    74          * @return mixed
     74         * @return bool
    7575         */
    7676        function add_blog_option( $blog_id, $option_name, $option_value ) {
     
    7979    }
    8080
    81     if ( !function_exists( 'update_blog_option' ) ) {
     81    if ( ! function_exists( 'update_blog_option' ) ) {
    8282
    8383        /**
     
    8888         * @see update_blog_option()
    8989         *
    90          * @param int    $blog_id     Blog ID to update for. Not used.
    91          * @param string $option_name Option name to update.
    92          * @param mixed  $value      Option value to update.
    93          * @return mixed
    94          */
    95         function update_blog_option( $blog_id, $option_name, $value ) {
    96             return update_option( $option_name, $value );
    97         }
    98     }
    99 
    100     if ( !function_exists( 'delete_blog_option' ) ) {
     90         * @param int    $blog_id      Blog ID to update for. Not used.
     91         * @param string $option_name  Option name to update.
     92         * @param mixed  $option_value Option value to update.
     93         * @return bool
     94         */
     95        function update_blog_option( $blog_id, $option_name, $option_value ) {
     96            return update_option( $option_name, $option_value );
     97        }
     98    }
     99
     100    if ( ! function_exists( 'delete_blog_option' ) ) {
    101101
    102102        /**
     
    109109         * @param int    $blog_id     Blog ID to delete for. Not used.
    110110         * @param string $option_name Option name to delete.
    111          * @return mixed
     111         * @return bool
    112112         */
    113113        function delete_blog_option( $blog_id, $option_name ) {
     
    116116    }
    117117
    118     if ( !function_exists( 'switch_to_blog' ) ) {
     118    if ( ! function_exists( 'switch_to_blog' ) ) {
    119119
    120120        /**
     
    126126         *
    127127         * @param mixed $new_blog   New blog to switch to. Not used.
    128          * @param null  $deprecated Whether or not deprecated. Not used.
     128         * @param null  $deprecated Not used.
    129129         * @return int
    130130         */
     
    134134    }
    135135
    136     if ( !function_exists( 'restore_current_blog' ) ) {
     136    if ( ! function_exists( 'restore_current_blog' ) ) {
    137137
    138138        /**
     
    150150    }
    151151
    152     if ( !function_exists( 'get_blogs_of_user' ) ) {
    153 
    154         /**
    155          * Retrive blogs associated with user.
     152    if ( ! function_exists( 'get_blogs_of_user' ) ) {
     153
     154        /**
     155         * Retrieve blogs associated with user.
    156156         *
    157157         * @since 1.2.0
     
    160160         *
    161161         * @param int  $user_id ID of the user. Not used.
    162          * @param bool $all     Whether or not to return all. Not used.
    163          * @return bool
     162         * @param bool $all     Whether to return all. Not used.
     163         * @return false
    164164         */
    165165        function get_blogs_of_user( $user_id, $all = false ) {
     
    168168    }
    169169
    170     if ( !function_exists( 'update_blog_status' ) ) {
     170    if ( ! function_exists( 'update_blog_status' ) ) {
    171171
    172172        /**
     
    181181         * @param string $value      Value. Not used.
    182182         * @param null   $deprecated Whether or not deprecated. Not used.
    183          * @return bool
     183         * @return true
    184184         */
    185185        function update_blog_status( $blog_id, $pref, $value, $deprecated = null ) {
     
    188188    }
    189189
    190     if ( !function_exists( 'is_subdomain_install' ) ) {
     190    if ( ! function_exists( 'is_subdomain_install' ) ) {
    191191
    192192        /**
     
    200200         */
    201201        function is_subdomain_install() {
    202             if ( ( defined( 'VHOST' ) && 'yes' == VHOST ) || ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) )
    203                 return true;
    204 
    205             return false;
     202            return ( ( defined( 'VHOST' ) && 'yes' === VHOST ) || ( defined( 'SUBDOMAIN_INSTALL' ) && SUBDOMAIN_INSTALL ) );
    206203        }
    207204    }
     
    218215 */
    219216function bp_core_get_status_sql( $prefix = false ) {
    220     if ( !is_multisite() )
     217    if ( ! is_multisite() ) {
    221218        return "{$prefix}user_status = 0";
    222     else
    223         return "{$prefix}spam = 0 AND {$prefix}deleted = 0 AND {$prefix}user_status = 0";
     219    }
     220
     221    return "{$prefix}spam = 0 AND {$prefix}deleted = 0 AND {$prefix}user_status = 0";
    224222}
    225223
     
    232230 * Borrowed from MediaWiki, under the GPLv2. Thanks!
    233231 */
    234 if ( !function_exists( 'mb_strlen' ) ) {
     232if ( ! function_exists( 'mb_strlen' ) ) {
    235233
    236234    /**
     
    243241    function mb_strlen( $str, $enc = '' ) {
    244242        $counts = count_chars( $str );
    245         $total = 0;
     243        $total  = 0;
    246244
    247245        // Count ASCII bytes.
    248         for( $i = 0; $i < 0x80; $i++ ) {
    249             $total += $counts[$i];
     246        for ( $i = 0; $i < 0x80; $i++ ) {
     247            $total += $counts[ $i ];
    250248        }
    251249
    252250        // Count multibyte sequence heads.
    253         for( $i = 0xc0; $i < 0xff; $i++ ) {
    254             $total += $counts[$i];
     251        for ( $i = 0xc0; $i < 0xff; $i++ ) {
     252            $total += $counts[ $i ];
    255253        }
    256254        return $total;
     
    258256}
    259257
    260 if ( !function_exists( 'mb_strpos' ) ) {
     258if ( ! function_exists( 'mb_strpos' ) ) {
    261259
    262260    /**
     
    275273        preg_match( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
    276274
    277         if( isset( $ar[0][1] ) ) {
     275        if ( isset( $ar[0][1] ) ) {
    278276            return $ar[0][1];
    279         } else {
    280             return false;
    281         }
    282     }
    283 }
    284 
    285 if ( !function_exists( 'mb_strrpos' ) ) {
     277        }
     278
     279        return false;
     280    }
     281}
     282
     283if ( ! function_exists( 'mb_strrpos' ) ) {
    286284
    287285    /**
     
    300298        preg_match_all( '/' . $needle . '/u', $haystack, $ar, PREG_OFFSET_CAPTURE, $offset );
    301299
    302         if( isset( $ar[0] ) && count( $ar[0] ) > 0 &&
    303             isset( $ar[0][count( $ar[0] ) - 1][1] ) ) {
    304             return $ar[0][count( $ar[0] ) - 1][1];
    305         } else {
    306             return false;
    307         }
     300        if ( isset( $ar[0] ) && count( $ar[0] ) > 0 &&
     301            isset( $ar[0][ count( $ar[0] ) - 1 ][1] ) ) {
     302            return $ar[0][ count( $ar[0] ) - 1 ][1];
     303        }
     304
     305        return false;
    308306    }
    309307}
     
    313311 *
    314312 * @since 6.0.0
     313 *
     314 * @param WP_Error|null $errors The WP_Error object.
     315 * @param array         $data   Associative array of complete site data. See {@see wp_insert_site()}.
    315316 */
    316317function bp_catch_site_data( $errors = null, $data = array() ) {
     
    390391function bp_delete_site_no_tables_drop( $site ) {
    391392    if ( isset( $site->deleted ) && 1 === (int) $site->deleted ) {
    392         return bp_delete_site( $site->id, false );
    393     }
    394 }
    395 add_action( 'wp_update_site', 'bp_delete_site_no_tables_drop', 10, 1 );
     393        bp_delete_site( $site->id );
     394    }
     395}
     396add_action( 'wp_update_site', 'bp_delete_site_no_tables_drop' );
    396397
    397398/**
Note: See TracChangeset for help on using the changeset viewer.