Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (8 years ago)
Author:
pento
Message:

Code is Poetry.
WordPress' code just... wasn't.
This is now dealt with.

Props jrf, pento, netweb, GaryJ, jdgrimes, westonruter, Greg Sherwood from PHPCS, and everyone who's ever contributed to WPCS and PHPCS.
Fixes #41057.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ms-load.php

    r41718 r42343  
    1717 */
    1818function is_subdomain_install() {
    19     if ( defined('SUBDOMAIN_INSTALL') )
     19    if ( defined( 'SUBDOMAIN_INSTALL' ) ) {
    2020        return SUBDOMAIN_INSTALL;
     21    }
    2122
    2223    return ( defined( 'VHOST' ) && VHOST == 'yes' );
     
    3637function wp_get_active_network_plugins() {
    3738    $active_plugins = (array) get_site_option( 'active_sitewide_plugins', array() );
    38     if ( empty( $active_plugins ) )
     39    if ( empty( $active_plugins ) ) {
    3940        return array();
    40 
    41     $plugins = array();
     41    }
     42
     43    $plugins        = array();
    4244    $active_plugins = array_keys( $active_plugins );
    4345    sort( $active_plugins );
     
    4749            && '.php' == substr( $plugin, -4 ) // $plugin must end with '.php'
    4850            && file_exists( WP_PLUGIN_DIR . '/' . $plugin ) // $plugin must exist
    49             )
    50         $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
     51            ) {
     52            $plugins[] = WP_PLUGIN_DIR . '/' . $plugin;
     53        }
    5154    }
    5255    return $plugins;
     
    7679     *
    7780     * @param bool null Whether to skip the blog status check. Default null.
    78     */
     81     */
    7982    $check = apply_filters( 'ms_site_check', null );
    80     if ( null !== $check )
     83    if ( null !== $check ) {
    8184        return true;
     85    }
    8286
    8387    // Allow super admins to see blocked sites
    84     if ( is_super_admin() )
     88    if ( is_super_admin() ) {
    8589        return true;
     90    }
    8691
    8792    $blog = get_site();
    8893
    8994    if ( '1' == $blog->deleted ) {
    90         if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) )
     95        if ( file_exists( WP_CONTENT_DIR . '/blog-deleted.php' ) ) {
    9196            return WP_CONTENT_DIR . '/blog-deleted.php';
    92         else
     97        } else {
    9398            wp_die( __( 'This site is no longer available.' ), '', array( 'response' => 410 ) );
     99        }
    94100    }
    95101
     
    101107            wp_die(
    102108                /* translators: %s: admin email link */
    103                 sprintf( __( 'This site has not been activated yet. If you are having problems activating your site, please contact %s.' ),
     109                sprintf(
     110                    __( 'This site has not been activated yet. If you are having problems activating your site, please contact %s.' ),
    104111                    sprintf( '<a href="mailto:%s">%s</a>', $admin_email )
    105112                )
     
    109116
    110117    if ( $blog->archived == '1' || $blog->spam == '1' ) {
    111         if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) )
     118        if ( file_exists( WP_CONTENT_DIR . '/blog-suspended.php' ) ) {
    112119            return WP_CONTENT_DIR . '/blog-suspended.php';
    113         else
     120        } else {
    114121            wp_die( __( 'This site has been archived or suspended.' ), '', array( 'response' => 410 ) );
     122        }
    115123    }
    116124
     
    228236    $args = array(
    229237        'domain__in' => $domains,
    230         'path__in' => $paths,
    231         'number' => 1,
     238        'path__in'   => $paths,
     239        'number'     => 1,
    232240    );
    233241
     
    241249
    242250    $result = get_sites( $args );
    243     $site = array_shift( $result );
     251    $site   = array_shift( $result );
    244252
    245253    if ( $site ) {
     
    285293    // If the network is defined in wp-config.php, we can simply use that.
    286294    if ( defined( 'DOMAIN_CURRENT_SITE' ) && defined( 'PATH_CURRENT_SITE' ) ) {
    287         $current_site = new stdClass;
    288         $current_site->id = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
     295        $current_site         = new stdClass;
     296        $current_site->id     = defined( 'SITE_ID_CURRENT_SITE' ) ? SITE_ID_CURRENT_SITE : 1;
    289297        $current_site->domain = DOMAIN_CURRENT_SITE;
    290         $current_site->path = PATH_CURRENT_SITE;
     298        $current_site->path   = PATH_CURRENT_SITE;
    291299        if ( defined( 'BLOG_ID_CURRENT_SITE' ) ) {
    292300            $current_site->blog_id = BLOG_ID_CURRENT_SITE;
     
    305313            $current_blog = get_site_by_path( $domain, $path, 1 );
    306314        }
    307 
    308315    } elseif ( ! $subdomain ) {
    309316        /*
     
    375382    // During activation of a new subdomain, the requested site does not yet exist.
    376383    if ( empty( $current_blog ) && wp_installing() ) {
    377         $current_blog = new stdClass;
     384        $current_blog          = new stdClass;
    378385        $current_blog->blog_id = $blog_id = 1;
    379         $current_blog->public = 1;
     386        $current_blog->public  = 1;
    380387    }
    381388
     
    383390    if ( empty( $current_blog ) ) {
    384391        // We're going to redirect to the network URL, with some possible modifications.
    385         $scheme = is_ssl() ? 'https' : 'http';
     392        $scheme      = is_ssl() ? 'https' : 'http';
    386393        $destination = "$scheme://{$current_site->domain}{$current_site->path}";
    387394
     
    455462    $title = __( 'Error establishing a database connection' );
    456463
    457     $msg  = '<h1>' . $title . '</h1>';
    458     $msg .= '<p>' . __( 'If your site does not display, please contact the owner of this network.' ) . '';
    459     $msg .= ' ' . __( 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' ) . '</p>';
    460     $query = $wpdb->prepare( "SHOW TABLES LIKE %s", $wpdb->esc_like( $wpdb->site ) );
     464    $msg   = '<h1>' . $title . '</h1>';
     465    $msg  .= '<p>' . __( 'If your site does not display, please contact the owner of this network.' ) . '';
     466    $msg  .= ' ' . __( 'If you are the owner of this network please check that MySQL is running properly and all tables are error free.' ) . '</p>';
     467    $query = $wpdb->prepare( 'SHOW TABLES LIKE %s', $wpdb->esc_like( $wpdb->site ) );
    461468    if ( ! $wpdb->get_var( $query ) ) {
    462469        $msg .= '<p>' . sprintf(
     
    476483    $msg .= '<p><strong>' . __( 'What do I do now?' ) . '</strong> ';
    477484    /* translators: %s: Codex URL */
    478     $msg .= sprintf( __( 'Read the <a href="%s" target="_blank">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.' ),
     485    $msg .= sprintf(
     486        __( 'Read the <a href="%s" target="_blank">bug report</a> page. Some of the guidelines there may help you figure out what went wrong.' ),
    479487        __( 'https://codex.wordpress.org/Debugging_a_WordPress_Network' )
    480488    );
    481489    $msg .= ' ' . __( 'If you&#8217;re still stuck with this message, then check that your database contains the following tables:' ) . '</p><ul>';
    482     foreach ( $wpdb->tables('global') as $t => $table ) {
    483         if ( 'sitecategories' == $t )
     490    foreach ( $wpdb->tables( 'global' ) as $t => $table ) {
     491        if ( 'sitecategories' == $t ) {
    484492            continue;
     493        }
    485494        $msg .= '<li>' . $table . '</li>';
    486495    }
Note: See TracChangeset for help on using the changeset viewer.