Make WordPress Core


Ignore:
Timestamp:
11/30/2017 11:09:33 PM (7 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/class-wp-network.php

    r42043 r42343  
    126126     */
    127127    public function __construct( $network ) {
    128         foreach( get_object_vars( $network ) as $key => $value ) {
     128        foreach ( get_object_vars( $network ) as $key => $value ) {
    129129            $this->$key = $value;
    130130        }
     
    255255            $main_site_id = wp_cache_get( $cache_key, 'site-options' );
    256256            if ( false === $main_site_id ) {
    257                 $_sites = get_sites( array(
    258                     'fields'     => 'ids',
    259                     'number'     => 1,
    260                     'domain'     => $this->domain,
    261                     'path'       => $this->path,
    262                     'network_id' => $this->id,
    263                 ) );
     257                $_sites       = get_sites(
     258                    array(
     259                        'fields'     => 'ids',
     260                        'number'     => 1,
     261                        'domain'     => $this->domain,
     262                        'path'       => $this->path,
     263                        'network_id' => $this->id,
     264                    )
     265                );
    264266                $main_site_id = ! empty( $_sites ) ? array_shift( $_sites ) : 0;
    265267
     
    283285        }
    284286
    285         $default = ucfirst( $this->domain );
     287        $default         = ucfirst( $this->domain );
    286288        $this->site_name = get_network_option( $this->id, 'site_name', $default );
    287289    }
     
    351353            $using_paths = wp_cache_get( 'networks_have_paths', 'site-options' );
    352354            if ( false === $using_paths ) {
    353                 $using_paths = get_networks( array(
    354                     'number'       => 1,
    355                     'count'        => true,
    356                     'path__not_in' => '/',
    357                 ) );
    358                 wp_cache_add( 'networks_have_paths', $using_paths, 'site-options'  );
     355                $using_paths = get_networks(
     356                    array(
     357                        'number'       => 1,
     358                        'count'        => true,
     359                        'path__not_in' => '/',
     360                    )
     361                );
     362                wp_cache_add( 'networks_have_paths', $using_paths, 'site-options' );
    359363            }
    360364        }
     
    414418
    415419        if ( ! $using_paths ) {
    416             $networks = get_networks( array(
    417                 'number'     => 1,
     420            $networks = get_networks(
     421                array(
     422                    'number'     => 1,
     423                    'orderby'    => array(
     424                        'domain_length' => 'DESC',
     425                    ),
     426                    'domain__in' => $domains,
     427                )
     428            );
     429
     430            if ( ! empty( $networks ) ) {
     431                return array_shift( $networks );
     432            }
     433
     434            return false;
     435        }
     436
     437        $networks = get_networks(
     438            array(
    418439                'orderby'    => array(
    419440                    'domain_length' => 'DESC',
     441                    'path_length'   => 'DESC',
    420442                ),
    421443                'domain__in' => $domains,
    422             ) );
    423 
    424             if ( ! empty( $networks ) ) {
    425                 return array_shift( $networks );
    426             }
    427 
    428             return false;
    429         }
    430 
    431         $networks = get_networks( array(
    432             'orderby'    => array(
    433                 'domain_length' => 'DESC',
    434                 'path_length'   => 'DESC',
    435             ),
    436             'domain__in' => $domains,
    437             'path__in'   => $paths,
    438         ) );
     444                'path__in'   => $paths,
     445            )
     446        );
    439447
    440448        /*
Note: See TracChangeset for help on using the changeset viewer.