Make WordPress Core


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

    r41753 r42343  
    4040function get_active_blog_for_user( $user_id ) {
    4141        $blogs = get_blogs_of_user( $user_id );
    42         if ( empty( $blogs ) )
     42        if ( empty( $blogs ) ) {
    4343                return;
     44        }
    4445
    4546        if ( ! is_multisite() ) {
     
    4849
    4950        $primary_blog = get_user_meta( $user_id, 'primary_blog', true );
    50         $first_blog = current($blogs);
     51        $first_blog   = current( $blogs );
    5152        if ( false !== $primary_blog ) {
    5253                if ( ! isset( $blogs[ $primary_blog ] ) ) {
     
    6869        if ( ( ! is_object( $primary ) ) || ( $primary->archived == 1 || $primary->spam == 1 || $primary->deleted == 1 ) ) {
    6970                $blogs = get_blogs_of_user( $user_id, true ); // if a user's primary blog is shut down, check their other blogs.
    70                 $ret = false;
     71                $ret   = false;
    7172                if ( is_array( $blogs ) && count( $blogs ) > 0 ) {
    7273                        foreach ( (array) $blogs as $blog_id => $blog ) {
    73                                 if ( $blog->site_id != get_current_network_id() )
     74                                if ( $blog->site_id != get_current_network_id() ) {
    7475                                        continue;
     76                                }
    7577                                $details = get_site( $blog_id );
    7678                                if ( is_object( $details ) && $details->archived == 0 && $details->spam == 0 && $details->deleted == 0 ) {
    7779                                        $ret = $blog;
    78                                         if ( get_user_meta( $user_id , 'primary_blog', true ) != $blog_id )
     80                                        if ( get_user_meta( $user_id, 'primary_blog', true ) != $blog_id ) {
    7981                                                update_user_meta( $user_id, 'primary_blog', $blog_id );
    80                                         if ( !get_user_meta($user_id , 'source_domain', true) )
     82                                        }
     83                                        if ( ! get_user_meta( $user_id, 'source_domain', true ) ) {
    8184                                                update_user_meta( $user_id, 'source_domain', $blog->domain );
     85                                        }
    8286                                        break;
    8387                                }
     
    153157 */
    154158function add_user_to_blog( $blog_id, $user_id, $role ) {
    155         switch_to_blog($blog_id);
     159        switch_to_blog( $blog_id );
    156160
    157161        $user = get_userdata( $user_id );
     
    185189        }
    186190
    187         if ( !get_user_meta($user_id, 'primary_blog', true) ) {
    188                 update_user_meta($user_id, 'primary_blog', $blog_id);
     191        if ( ! get_user_meta( $user_id, 'primary_blog', true ) ) {
     192                update_user_meta( $user_id, 'primary_blog', $blog_id );
    189193                $site = get_site( $blog_id );
    190194                update_user_meta( $user_id, 'source_domain', $site->domain );
    191195        }
    192196
    193         $user->set_role($role);
     197        $user->set_role( $role );
    194198
    195199        /**
     
    227231 * @return true|WP_Error
    228232 */
    229 function remove_user_from_blog($user_id, $blog_id = '', $reassign = '') {
     233function remove_user_from_blog( $user_id, $blog_id = '', $reassign = '' ) {
    230234        global $wpdb;
    231         switch_to_blog($blog_id);
     235        switch_to_blog( $blog_id );
    232236        $user_id = (int) $user_id;
    233237        /**
     
    243247        // If being removed from the primary blog, set a new primary if the user is assigned
    244248        // to multiple blogs.
    245         $primary_blog = get_user_meta($user_id, 'primary_blog', true);
     249        $primary_blog = get_user_meta( $user_id, 'primary_blog', true );
    246250        if ( $primary_blog == $blog_id ) {
    247                 $new_id = '';
     251                $new_id     = '';
    248252                $new_domain = '';
    249                 $blogs = get_blogs_of_user($user_id);
     253                $blogs      = get_blogs_of_user( $user_id );
    250254                foreach ( (array) $blogs as $blog ) {
    251                         if ( $blog->userblog_id == $blog_id )
     255                        if ( $blog->userblog_id == $blog_id ) {
    252256                                continue;
    253                         $new_id = $blog->userblog_id;
     257                        }
     258                        $new_id     = $blog->userblog_id;
    254259                        $new_domain = $blog->domain;
    255260                        break;
    256261                }
    257262
    258                 update_user_meta($user_id, 'primary_blog', $new_id);
    259                 update_user_meta($user_id, 'source_domain', $new_domain);
     263                update_user_meta( $user_id, 'primary_blog', $new_id );
     264                update_user_meta( $user_id, 'source_domain', $new_domain );
    260265        }
    261266
     
    264269        if ( ! $user ) {
    265270                restore_current_blog();
    266                 return new WP_Error('user_does_not_exist', __('That user does not exist.'));
     271                return new WP_Error( 'user_does_not_exist', __( 'That user does not exist.' ) );
    267272        }
    268273
    269274        $user->remove_all_caps();
    270275
    271         $blogs = get_blogs_of_user($user_id);
    272         if ( count($blogs) == 0 ) {
    273                 update_user_meta($user_id, 'primary_blog', '');
    274                 update_user_meta($user_id, 'source_domain', '');
     276        $blogs = get_blogs_of_user( $user_id );
     277        if ( count( $blogs ) == 0 ) {
     278                update_user_meta( $user_id, 'primary_blog', '' );
     279                update_user_meta( $user_id, 'source_domain', '' );
    275280        }
    276281
     
    331336function get_blog_id_from_url( $domain, $path = '/' ) {
    332337        $domain = strtolower( $domain );
    333         $path = strtolower( $path );
    334         $id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
    335 
    336         if ( $id == -1 ) // blog does not exist
     338        $path   = strtolower( $path );
     339        $id     = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
     340
     341        if ( $id == -1 ) { // blog does not exist
    337342                return 0;
    338         elseif ( $id )
     343        } elseif ( $id ) {
    339344                return (int) $id;
    340 
    341         $args = array(
     345        }
     346
     347        $args   = array(
    342348                'domain' => $domain,
    343                 'path' => $path,
     349                'path'   => $path,
    344350                'fields' => 'ids',
    345351                'number' => 1,
    346352        );
    347353        $result = get_sites( $args );
    348         $id = array_shift( $result );
     354        $id     = array_shift( $result );
    349355
    350356        if ( ! $id ) {
     
    375381function is_email_address_unsafe( $user_email ) {
    376382        $banned_names = get_site_option( 'banned_email_domains' );
    377         if ( $banned_names && ! is_array( $banned_names ) )
     383        if ( $banned_names && ! is_array( $banned_names ) ) {
    378384                $banned_names = explode( "\n", $banned_names );
     385        }
    379386
    380387        $is_email_address_unsafe = false;
    381388
    382389        if ( $banned_names && is_array( $banned_names ) && false !== strpos( $user_email, '@', 1 ) ) {
    383                 $banned_names = array_map( 'strtolower', $banned_names );
     390                $banned_names     = array_map( 'strtolower', $banned_names );
    384391                $normalized_email = strtolower( $user_email );
    385392
     
    387394
    388395                foreach ( $banned_names as $banned_domain ) {
    389                         if ( ! $banned_domain )
     396                        if ( ! $banned_domain ) {
    390397                                continue;
     398                        }
    391399
    392400                        if ( $email_domain == $banned_domain ) {
     
    434442 * @return array Contains username, email, and error messages.
    435443 */
    436 function wpmu_validate_user_signup($user_name, $user_email) {
     444function wpmu_validate_user_signup( $user_name, $user_email ) {
    437445        global $wpdb;
    438446
     
    440448
    441449        $orig_username = $user_name;
    442         $user_name = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
     450        $user_name     = preg_replace( '/\s+/', '', sanitize_user( $user_name, true ) );
    443451
    444452        if ( $user_name != $orig_username || preg_match( '/[^a-z0-9]/', $user_name ) ) {
     
    449457        $user_email = sanitize_email( $user_email );
    450458
    451         if ( empty( $user_name ) )
    452                 $errors->add('user_name', __( 'Please enter a username.' ) );
     459        if ( empty( $user_name ) ) {
     460                $errors->add( 'user_name', __( 'Please enter a username.' ) );
     461        }
    453462
    454463        $illegal_names = get_site_option( 'illegal_names' );
    455464        if ( ! is_array( $illegal_names ) ) {
    456                 $illegal_names = array(  'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
     465                $illegal_names = array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' );
    457466                add_site_option( 'illegal_names', $illegal_names );
    458467        }
    459468        if ( in_array( $user_name, $illegal_names ) ) {
    460                 $errors->add( 'user_name',  __( 'Sorry, that username is not allowed.' ) );
     469                $errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) );
    461470        }
    462471
     
    465474
    466475        if ( in_array( strtolower( $user_name ), array_map( 'strtolower', $illegal_logins ) ) ) {
    467                 $errors->add( 'user_name',  __( 'Sorry, that username is not allowed.' ) );
     476                $errors->add( 'user_name', __( 'Sorry, that username is not allowed.' ) );
    468477        }
    469478
     
    474483        }
    475484
    476         if ( strlen( $user_name ) < 4 )
    477                 $errors->add('user_name',  __( 'Username must be at least 4 characters.' ) );
     485        if ( strlen( $user_name ) < 4 ) {
     486                $errors->add( 'user_name', __( 'Username must be at least 4 characters.' ) );
     487        }
    478488
    479489        if ( strlen( $user_name ) > 60 ) {
     
    482492
    483493        // all numeric?
    484         if ( preg_match( '/^[0-9]*$/', $user_name ) )
    485                 $errors->add('user_name', __('Sorry, usernames must have letters too!'));
     494        if ( preg_match( '/^[0-9]*$/', $user_name ) ) {
     495                $errors->add( 'user_name', __( 'Sorry, usernames must have letters too!' ) );
     496        }
    486497
    487498        $limited_email_domains = get_site_option( 'limited_email_domains' );
     
    489500                $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
    490501                if ( ! in_array( $emaildomain, $limited_email_domains ) ) {
    491                         $errors->add('user_email', __('Sorry, that email address is not allowed!'));
     502                        $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!' ) );
    492503                }
    493504        }
    494505
    495506        // Check if the username has been used already.
    496         if ( username_exists($user_name) )
     507        if ( username_exists( $user_name ) ) {
    497508                $errors->add( 'user_name', __( 'Sorry, that username already exists!' ) );
     509        }
    498510
    499511        // Check if the email address has been used already.
    500         if ( email_exists($user_email) )
     512        if ( email_exists( $user_email ) ) {
    501513                $errors->add( 'user_email', __( 'Sorry, that email address is already used!' ) );
     514        }
    502515
    503516        // Has someone already signed up for this username?
    504         $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name) );
     517        $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_login = %s", $user_name ) );
    505518        if ( $signup != null ) {
    506                 $registered_at =  mysql2date('U', $signup->registered);
    507                 $now = current_time( 'timestamp', true );
    508                 $diff = $now - $registered_at;
     519                $registered_at = mysql2date( 'U', $signup->registered );
     520                $now           = current_time( 'timestamp', true );
     521                $diff          = $now - $registered_at;
    509522                // If registered more than two days ago, cancel registration and let this signup go through.
    510                 if ( $diff > 2 * DAY_IN_SECONDS )
     523                if ( $diff > 2 * DAY_IN_SECONDS ) {
    511524                        $wpdb->delete( $wpdb->signups, array( 'user_login' => $user_name ) );
    512                 else
    513                         $errors->add('user_name', __('That username is currently reserved but may be available in a couple of days.'));
    514         }
    515 
    516         $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email) );
     525                } else {
     526                        $errors->add( 'user_name', __( 'That username is currently reserved but may be available in a couple of days.' ) );
     527                }
     528        }
     529
     530        $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE user_email = %s", $user_email ) );
    517531        if ( $signup != null ) {
    518                 $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
     532                $diff = current_time( 'timestamp', true ) - mysql2date( 'U', $signup->registered );
    519533                // If registered more than two days ago, cancel registration and let this signup go through.
    520                 if ( $diff > 2 * DAY_IN_SECONDS )
     534                if ( $diff > 2 * DAY_IN_SECONDS ) {
    521535                        $wpdb->delete( $wpdb->signups, array( 'user_email' => $user_email ) );
    522                 else
    523                         $errors->add('user_email', __('That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.'));
    524         }
    525 
    526         $result = array('user_name' => $user_name, 'orig_username' => $orig_username, 'user_email' => $user_email, 'errors' => $errors);
     536                } else {
     537                        $errors->add( 'user_email', __( 'That email address has already been used. Please check your inbox for an activation email. It will become available in a couple of days if you do nothing.' ) );
     538                }
     539        }
     540
     541        $result = array(
     542                'user_name'     => $user_name,
     543                'orig_username' => $orig_username,
     544                'user_email'    => $user_email,
     545                'errors'        => $errors,
     546        );
    527547
    528548        /**
     
    574594
    575595        $current_network = get_network();
    576         $base = $current_network->path;
     596        $base            = $current_network->path;
    577597
    578598        $blog_title = strip_tags( $blog_title );
    579599
    580         $errors = new WP_Error();
     600        $errors        = new WP_Error();
    581601        $illegal_names = get_site_option( 'illegal_names' );
    582602        if ( $illegal_names == false ) {
     
    593613        }
    594614
    595         if ( empty( $blogname ) )
    596                 $errors->add('blogname', __( 'Please enter a site name.' ) );
     615        if ( empty( $blogname ) ) {
     616                $errors->add( 'blogname', __( 'Please enter a site name.' ) );
     617        }
    597618
    598619        if ( preg_match( '/[^a-z0-9]+/', $blogname ) ) {
     
    600621        }
    601622
    602         if ( in_array( $blogname, $illegal_names ) )
    603                 $errors->add('blogname',  __( 'That name is not allowed.' ) );
     623        if ( in_array( $blogname, $illegal_names ) ) {
     624                $errors->add( 'blogname', __( 'That name is not allowed.' ) );
     625        }
    604626
    605627        /**
     
    618640
    619641        // do not allow users to create a blog that conflicts with a page on the main blog.
    620         if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
     642        if ( ! is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( 'SELECT post_name FROM ' . $wpdb->get_blog_prefix( $current_network->site_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) {
    621643                $errors->add( 'blogname', __( 'Sorry, you may not use that site name.' ) );
     644        }
    622645
    623646        // all numeric?
    624         if ( preg_match( '/^[0-9]*$/', $blogname ) )
    625                 $errors->add('blogname', __('Sorry, site names must have letters too!'));
     647        if ( preg_match( '/^[0-9]*$/', $blogname ) ) {
     648                $errors->add( 'blogname', __( 'Sorry, site names must have letters too!' ) );
     649        }
    626650
    627651        /**
     
    637661        $blogname = apply_filters( 'newblogname', $blogname );
    638662
    639         $blog_title = wp_unslash(  $blog_title );
    640 
    641         if ( empty( $blog_title ) )
    642                 $errors->add('blog_title', __( 'Please enter a site title.' ) );
     663        $blog_title = wp_unslash( $blog_title );
     664
     665        if ( empty( $blog_title ) ) {
     666                $errors->add( 'blog_title', __( 'Please enter a site title.' ) );
     667        }
    643668
    644669        // Check if the domain/path has been used already.
    645670        if ( is_subdomain_install() ) {
    646671                $mydomain = $blogname . '.' . preg_replace( '|^www\.|', '', $domain );
    647                 $path = $base;
     672                $path     = $base;
    648673        } else {
    649674                $mydomain = "$domain";
    650                 $path = $base.$blogname.'/';
    651         }
    652         if ( domain_exists($mydomain, $path, $current_network->id) )
     675                $path     = $base . $blogname . '/';
     676        }
     677        if ( domain_exists( $mydomain, $path, $current_network->id ) ) {
    653678                $errors->add( 'blogname', __( 'Sorry, that site already exists!' ) );
     679        }
    654680
    655681        if ( username_exists( $blogname ) ) {
    656                 if ( ! is_object( $user ) || ( is_object($user) && ( $user->user_login != $blogname ) ) )
     682                if ( ! is_object( $user ) || ( is_object( $user ) && ( $user->user_login != $blogname ) ) ) {
    657683                        $errors->add( 'blogname', __( 'Sorry, that site is reserved!' ) );
     684                }
    658685        }
    659686
    660687        // Has someone already signed up for this domain?
    661         $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) ); // TODO: Check email too?
    662         if ( ! empty($signup) ) {
    663                 $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
     688        $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path ) ); // TODO: Check email too?
     689        if ( ! empty( $signup ) ) {
     690                $diff = current_time( 'timestamp', true ) - mysql2date( 'U', $signup->registered );
    664691                // If registered more than two days ago, cancel registration and let this signup go through.
    665                 if ( $diff > 2 * DAY_IN_SECONDS )
    666                         $wpdb->delete( $wpdb->signups, array( 'domain' => $mydomain , 'path' => $path ) );
    667                 else
    668                         $errors->add('blogname', __('That site is currently reserved but may be available in a couple days.'));
    669         }
    670 
    671         $result = array('domain' => $mydomain, 'path' => $path, 'blogname' => $blogname, 'blog_title' => $blog_title, 'user' => $user, 'errors' => $errors);
     692                if ( $diff > 2 * DAY_IN_SECONDS ) {
     693                        $wpdb->delete(
     694                                $wpdb->signups, array(
     695                                        'domain' => $mydomain,
     696                                        'path'   => $path,
     697                                )
     698                        );
     699                } else {
     700                        $errors->add( 'blogname', __( 'That site is currently reserved but may be available in a couple days.' ) );
     701                }
     702        }
     703
     704        $result = array(
     705                'domain'     => $mydomain,
     706                'path'       => $path,
     707                'blogname'   => $blogname,
     708                'blog_title' => $blog_title,
     709                'user'       => $user,
     710                'errors'     => $errors,
     711        );
    672712
    673713        /**
     
    704744 * @param array  $meta       Optional. Signup meta data. By default, contains the requested privacy setting and lang_id.
    705745 */
    706 function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = array() )  {
     746function wpmu_signup_blog( $domain, $path, $title, $user, $user_email, $meta = array() ) {
    707747        global $wpdb;
    708748
     
    726766        $meta = apply_filters( 'signup_site_meta', $meta, $domain, $path, $title, $user, $user_email, $key );
    727767
    728         $wpdb->insert( $wpdb->signups, array(
    729                 'domain' => $domain,
    730                 'path' => $path,
    731                 'title' => $title,
    732                 'user_login' => $user,
    733                 'user_email' => $user_email,
    734                 'registered' => current_time('mysql', true),
    735                 'activation_key' => $key,
    736                 'meta' => serialize( $meta )
    737         ) );
     768        $wpdb->insert(
     769                $wpdb->signups, array(
     770                        'domain'         => $domain,
     771                        'path'           => $path,
     772                        'title'          => $title,
     773                        'user_login'     => $user,
     774                        'user_email'     => $user_email,
     775                        'registered'     => current_time( 'mysql', true ),
     776                        'activation_key' => $key,
     777                        'meta'           => serialize( $meta ),
     778                )
     779        );
    738780
    739781        /**
     
    771813
    772814        // Format data
    773         $user = preg_replace( '/\s+/', '', sanitize_user( $user, true ) );
     815        $user       = preg_replace( '/\s+/', '', sanitize_user( $user, true ) );
    774816        $user_email = sanitize_email( $user_email );
    775         $key = substr( md5( time() . wp_rand() . $user_email ), 0, 16 );
     817        $key        = substr( md5( time() . wp_rand() . $user_email ), 0, 16 );
    776818
    777819        /**
     
    789831        $meta = apply_filters( 'signup_user_meta', $meta, $user, $user_email, $key );
    790832
    791         $wpdb->insert( $wpdb->signups, array(
    792                 'domain' => '',
    793                 'path' => '',
    794                 'title' => '',
    795                 'user_login' => $user,
    796                 'user_email' => $user_email,
    797                 'registered' => current_time('mysql', true),
    798                 'activation_key' => $key,
    799                 'meta' => serialize( $meta )
    800         ) );
     833        $wpdb->insert(
     834                $wpdb->signups, array(
     835                        'domain'         => '',
     836                        'path'           => '',
     837                        'title'          => '',
     838                        'user_login'     => $user,
     839                        'user_email'     => $user_email,
     840                        'registered'     => current_time( 'mysql', true ),
     841                        'activation_key' => $key,
     842                        'meta'           => serialize( $meta ),
     843                )
     844        );
    801845
    802846        /**
     
    857901
    858902        // Send email with activation link.
    859         if ( !is_subdomain_install() || get_current_network_id() != 1 )
    860                 $activate_url = network_site_url("wp-activate.php?key=$key");
    861         else
     903        if ( ! is_subdomain_install() || get_current_network_id() != 1 ) {
     904                $activate_url = network_site_url( "wp-activate.php?key=$key" );
     905        } else {
    862906                $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key"; // @todo use *_url() API
    863 
    864         $activate_url = esc_url($activate_url);
    865         $admin_email = get_site_option( 'admin_email' );
    866         if ( $admin_email == '' )
     907        }
     908
     909        $activate_url = esc_url( $activate_url );
     910        $admin_email  = get_site_option( 'admin_email' );
     911        if ( $admin_email == '' ) {
    867912                $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    868         $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
    869         $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    870 
    871         $user = get_user_by( 'login', $user_login );
     913        }
     914        $from_name       = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
     915        $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
     916
     917        $user            = get_user_by( 'login', $user_login );
    872918        $switched_locale = switch_to_locale( get_user_locale( $user ) );
    873919
     
    889935                 * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
    890936                 */
    891                 apply_filters( 'wpmu_signup_blog_notification_email',
    892                         __( "To activate your blog, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%s" ),
     937                apply_filters(
     938                        'wpmu_signup_blog_notification_email',
     939                        __( "To activate your blog, please click the following link:\n\n%1\$s\n\nAfter you activate, you will receive *another email* with your login.\n\nAfter you activate, you can visit your site here:\n\n%2\$s" ),
    893940                        $domain, $path, $title, $user_login, $user_email, $key, $meta
    894941                ),
     
    913960                 * @param array  $meta       Signup meta data. By default, contains the requested privacy setting and lang_id.
    914961                 */
    915                 apply_filters( 'wpmu_signup_blog_notification_subject',
     962                apply_filters(
     963                        'wpmu_signup_blog_notification_subject',
    916964                        /* translators: New site notification email subject. 1: Network name, 2: New site URL */
    917965                        _x( '[%1$s] Activate %2$s', 'New site notification email subject' ),
     
    9631011         * @param array  $meta       Signup meta data. Default empty array.
    9641012         */
    965         if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) )
     1013        if ( ! apply_filters( 'wpmu_signup_user_notification', $user_login, $user_email, $key, $meta ) ) {
    9661014                return false;
    967 
    968         $user = get_user_by( 'login', $user_login );
     1015        }
     1016
     1017        $user            = get_user_by( 'login', $user_login );
    9691018        $switched_locale = switch_to_locale( get_user_locale( $user ) );
    9701019
    9711020        // Send email with activation link.
    9721021        $admin_email = get_site_option( 'admin_email' );
    973         if ( $admin_email == '' )
     1022        if ( $admin_email == '' ) {
    9741023                $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    975         $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
    976         $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    977         $message = sprintf(
     1024        }
     1025        $from_name       = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
     1026        $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
     1027        $message         = sprintf(
    9781028                /**
    9791029                 * Filters the content of the notification email for new user sign-up.
     
    9891039                 * @param array  $meta       Signup meta data. Default empty array.
    9901040                 */
    991                 apply_filters( 'wpmu_signup_user_notification_email',
     1041                apply_filters(
     1042                        'wpmu_signup_user_notification_email',
    9921043                        __( "To activate your user, please click the following link:\n\n%s\n\nAfter you activate, you will receive *another email* with your login." ),
    9931044                        $user_login, $user_email, $key, $meta
     
    10081059                 * @param array  $meta       Signup meta data. Default empty array.
    10091060                 */
    1010                 apply_filters( 'wpmu_signup_user_notification_subject',
     1061                apply_filters(
     1062                        'wpmu_signup_user_notification_subject',
    10111063                        /* translators: New user notification email subject. 1: Network name, 2: New user login */
    10121064                        _x( '[%1$s] Activate %2$s', 'New user notification email subject' ),
     
    10401092 * @return array|WP_Error An array containing information about the activated user and/or blog
    10411093 */
    1042 function wpmu_activate_signup($key) {
     1094function wpmu_activate_signup( $key ) {
    10431095        global $wpdb;
    10441096
    1045         $signup = $wpdb->get_row( $wpdb->prepare("SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key) );
    1046 
    1047         if ( empty( $signup ) )
     1097        $signup = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->signups WHERE activation_key = %s", $key ) );
     1098
     1099        if ( empty( $signup ) ) {
    10481100                return new WP_Error( 'invalid_key', __( 'Invalid activation key.' ) );
     1101        }
    10491102
    10501103        if ( $signup->active ) {
    1051                 if ( empty( $signup->domain ) )
     1104                if ( empty( $signup->domain ) ) {
    10521105                        return new WP_Error( 'already_active', __( 'The user is already active.' ), $signup );
    1053                 else
     1106                } else {
    10541107                        return new WP_Error( 'already_active', __( 'The site is already active.' ), $signup );
    1055         }
    1056 
    1057         $meta = maybe_unserialize($signup->meta);
     1108                }
     1109        }
     1110
     1111        $meta     = maybe_unserialize( $signup->meta );
    10581112        $password = wp_generate_password( 12, false );
    10591113
    1060         $user_id = username_exists($signup->user_login);
    1061 
    1062         if ( ! $user_id )
    1063                 $user_id = wpmu_create_user($signup->user_login, $password, $signup->user_email);
    1064         else
     1114        $user_id = username_exists( $signup->user_login );
     1115
     1116        if ( ! $user_id ) {
     1117                $user_id = wpmu_create_user( $signup->user_login, $password, $signup->user_email );
     1118        } else {
    10651119                $user_already_exists = true;
    1066 
    1067         if ( ! $user_id )
    1068                 return new WP_Error('create_user', __('Could not create user'), $signup);
    1069 
    1070         $now = current_time('mysql', true);
    1071 
    1072         if ( empty($signup->domain) ) {
    1073                 $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
    1074 
    1075                 if ( isset( $user_already_exists ) )
    1076                         return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
     1120        }
     1121
     1122        if ( ! $user_id ) {
     1123                return new WP_Error( 'create_user', __( 'Could not create user' ), $signup );
     1124        }
     1125
     1126        $now = current_time( 'mysql', true );
     1127
     1128        if ( empty( $signup->domain ) ) {
     1129                $wpdb->update(
     1130                        $wpdb->signups, array(
     1131                                'active'    => 1,
     1132                                'activated' => $now,
     1133                        ), array( 'activation_key' => $key )
     1134                );
     1135
     1136                if ( isset( $user_already_exists ) ) {
     1137                        return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup );
     1138                }
    10771139
    10781140                /**
     
    10861148                 */
    10871149                do_action( 'wpmu_activate_user', $user_id, $password, $meta );
    1088                 return array( 'user_id' => $user_id, 'password' => $password, 'meta' => $meta );
     1150                return array(
     1151                        'user_id'  => $user_id,
     1152                        'password' => $password,
     1153                        'meta'     => $meta,
     1154                );
    10891155        }
    10901156
     
    10921158
    10931159        // TODO: What to do if we create a user but cannot create a blog?
    1094         if ( is_wp_error($blog_id) ) {
     1160        if ( is_wp_error( $blog_id ) ) {
    10951161                // If blog is taken, that means a previous attempt to activate this blog failed in between creating the blog and
    10961162                // setting the activation flag. Let's just set the active flag and instruct the user to reset their password.
    10971163                if ( 'blog_taken' == $blog_id->get_error_code() ) {
    10981164                        $blog_id->add_data( $signup );
    1099                         $wpdb->update( $wpdb->signups, array( 'active' => 1, 'activated' => $now ), array( 'activation_key' => $key ) );
     1165                        $wpdb->update(
     1166                                $wpdb->signups, array(
     1167                                        'active'    => 1,
     1168                                        'activated' => $now,
     1169                                ), array( 'activation_key' => $key )
     1170                        );
    11001171                }
    11011172                return $blog_id;
    11021173        }
    11031174
    1104         $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
     1175        $wpdb->update(
     1176                $wpdb->signups, array(
     1177                        'active'    => 1,
     1178                        'activated' => $now,
     1179                ), array( 'activation_key' => $key )
     1180        );
    11051181        /**
    11061182         * Fires immediately after a site is activated.
     
    11161192        do_action( 'wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta );
    11171193
    1118         return array('blog_id' => $blog_id, 'user_id' => $user_id, 'password' => $password, 'title' => $signup->title, 'meta' => $meta);
     1194        return array(
     1195                'blog_id'  => $blog_id,
     1196                'user_id'  => $user_id,
     1197                'password' => $password,
     1198                'title'    => $signup->title,
     1199                'meta'     => $meta,
     1200        );
    11191201}
    11201202
     
    11381220
    11391221        $user_id = wp_create_user( $user_name, $password, $email );
    1140         if ( is_wp_error( $user_id ) )
     1222        if ( is_wp_error( $user_id ) ) {
    11411223                return false;
     1224        }
    11421225
    11431226        // Newly created users have no roles or caps until they are added to a blog.
     
    11881271                'WPLANG' => get_network_option( $network_id, 'WPLANG' ),
    11891272        );
    1190         $meta = wp_parse_args( $meta, $defaults );
     1273        $meta     = wp_parse_args( $meta, $defaults );
    11911274
    11921275        $domain = preg_replace( '/\s+/', '', sanitize_user( $domain, true ) );
    11931276
    1194         if ( is_subdomain_install() )
     1277        if ( is_subdomain_install() ) {
    11951278                $domain = str_replace( '@', '', $domain );
    1196 
    1197         $title = strip_tags( $title );
     1279        }
     1280
     1281        $title   = strip_tags( $title );
    11981282        $user_id = (int) $user_id;
    11991283
    1200         if ( empty($path) )
     1284        if ( empty( $path ) ) {
    12011285                $path = '/';
     1286        }
    12021287
    12031288        // Check if the domain has been used already. We should return an error message.
    1204         if ( domain_exists($domain, $path, $network_id) )
     1289        if ( domain_exists( $domain, $path, $network_id ) ) {
    12051290                return new WP_Error( 'blog_taken', __( 'Sorry, that site already exists!' ) );
     1291        }
    12061292
    12071293        if ( ! wp_installing() ) {
     
    12091295        }
    12101296
    1211         if ( ! $blog_id = insert_blog($domain, $path, $network_id) )
    1212                 return new WP_Error('insert_blog', __('Could not create site.'));
    1213 
    1214         switch_to_blog($blog_id);
    1215         install_blog($blog_id, $title);
    1216         wp_install_defaults($user_id);
    1217 
    1218         add_user_to_blog($blog_id, $user_id, 'administrator');
     1297        if ( ! $blog_id = insert_blog( $domain, $path, $network_id ) ) {
     1298                return new WP_Error( 'insert_blog', __( 'Could not create site.' ) );
     1299        }
     1300
     1301        switch_to_blog( $blog_id );
     1302        install_blog( $blog_id, $title );
     1303        wp_install_defaults( $user_id );
     1304
     1305        add_user_to_blog( $blog_id, $user_id, 'administrator' );
    12191306
    12201307        foreach ( $meta as $key => $value ) {
    1221                 if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) )
     1308                if ( in_array( $key, array( 'public', 'archived', 'mature', 'spam', 'deleted', 'lang_id' ) ) ) {
    12221309                        update_blog_status( $blog_id, $key, $value );
    1223                 else
     1310                } else {
    12241311                        update_option( $key, $value );
     1312                }
    12251313        }
    12261314
    12271315        update_option( 'blog_public', (int) $meta['public'] );
    12281316
    1229         if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) )
     1317        if ( ! is_super_admin( $user_id ) && ! get_user_meta( $user_id, 'primary_blog', true ) ) {
    12301318                update_user_meta( $user_id, 'primary_blog', $blog_id );
     1319        }
    12311320
    12321321        restore_current_blog();
     
    12631352 */
    12641353function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
    1265         if ( get_site_option( 'registrationnotification' ) != 'yes' )
     1354        if ( get_site_option( 'registrationnotification' ) != 'yes' ) {
    12661355                return false;
     1356        }
    12671357
    12681358        $email = get_site_option( 'admin_email' );
    1269         if ( is_email($email) == false )
     1359        if ( is_email( $email ) == false ) {
    12701360                return false;
    1271 
    1272         $options_site_url = esc_url(network_admin_url('settings.php'));
     1361        }
     1362
     1363        $options_site_url = esc_url( network_admin_url( 'settings.php' ) );
    12731364
    12741365        switch_to_blog( $blog_id );
    12751366        $blogname = get_option( 'blogname' );
    1276         $siteurl = site_url();
     1367        $siteurl  = site_url();
    12771368        restore_current_blog();
    12781369
    12791370        /* translators: New site notification email. 1: Site URL, 2: User IP address, 3: Settings screen URL */
    1280         $msg = sprintf( __( 'New Site: %1$s
     1371        $msg = sprintf(
     1372                __(
     1373                        'New Site: %1$s
    12811374URL: %2$s
    12821375Remote IP address: %3$s
    12831376
    1284 Disable these notifications: %4$s' ), $blogname, $siteurl, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url);
     1377Disable these notifications: %4$s'
     1378                ), $blogname, $siteurl, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url
     1379        );
    12851380        /**
    12861381         * Filters the message body of the new site activation email sent
     
    13091404 */
    13101405function newuser_notify_siteadmin( $user_id ) {
    1311         if ( get_site_option( 'registrationnotification' ) != 'yes' )
     1406        if ( get_site_option( 'registrationnotification' ) != 'yes' ) {
    13121407                return false;
     1408        }
    13131409
    13141410        $email = get_site_option( 'admin_email' );
    13151411
    1316         if ( is_email($email) == false )
     1412        if ( is_email( $email ) == false ) {
    13171413                return false;
     1414        }
    13181415
    13191416        $user = get_userdata( $user_id );
    13201417
    1321         $options_site_url = esc_url(network_admin_url('settings.php'));
     1418        $options_site_url = esc_url( network_admin_url( 'settings.php' ) );
    13221419        /* translators: New user notification email. 1: User login, 2: User IP address, 3: Settings screen URL */
    1323         $msg = sprintf(__('New User: %1$s
     1420        $msg = sprintf(
     1421                __(
     1422                        'New User: %1$s
    13241423Remote IP address: %2$s
    13251424
    1326 Disable these notifications: %3$s'), $user->user_login, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url);
     1425Disable these notifications: %3$s'
     1426                ), $user->user_login, wp_unslash( $_SERVER['REMOTE_ADDR'] ), $options_site_url
     1427        );
    13271428
    13281429        /**
     
    13361437         */
    13371438        $msg = apply_filters( 'newuser_notify_siteadmin', $msg, $user );
    1338         wp_mail( $email, sprintf(__('New User Registration: %s'), $user->user_login), $msg );
     1439        wp_mail( $email, sprintf( __( 'New User Registration: %s' ), $user->user_login ), $msg );
    13391440        return true;
    13401441}
     
    13571458 */
    13581459function domain_exists( $domain, $path, $network_id = 1 ) {
    1359         $path = trailingslashit( $path );
    1360         $args = array(
     1460        $path   = trailingslashit( $path );
     1461        $args   = array(
    13611462                'network_id' => $network_id,
    13621463                'domain'     => $domain,
     
    13991500 * @return int|false The ID of the new row
    14001501 */
    1401 function insert_blog($domain, $path, $network_id) {
     1502function insert_blog( $domain, $path, $network_id ) {
    14021503        global $wpdb;
    14031504
    1404         $path = trailingslashit($path);
     1505        $path       = trailingslashit( $path );
    14051506        $network_id = (int) $network_id;
    14061507
    1407         $result = $wpdb->insert( $wpdb->blogs, array('site_id' => $network_id, 'domain' => $domain, 'path' => $path, 'registered' => current_time('mysql')) );
    1408         if ( ! $result )
     1508        $result = $wpdb->insert(
     1509                $wpdb->blogs, array(
     1510                        'site_id'    => $network_id,
     1511                        'domain'     => $domain,
     1512                        'path'       => $path,
     1513                        'registered' => current_time( 'mysql' ),
     1514                )
     1515        );
     1516        if ( ! $result ) {
    14091517                return false;
     1518        }
    14101519
    14111520        $blog_id = $wpdb->insert_id;
     
    14411550
    14421551        $suppress = $wpdb->suppress_errors();
    1443         if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) )
     1552        if ( $wpdb->get_results( "DESCRIBE {$wpdb->posts}" ) ) {
    14441553                die( '<h1>' . __( 'Already Installed' ) . '</h1><p>' . __( 'You appear to have already installed WordPress. To reinstall please clear your old database tables first.' ) . '</p></body></html>' );
     1554        }
    14451555        $wpdb->suppress_errors( $suppress );
    14461556
     
    14591569        if ( ! is_subdomain_install() ) {
    14601570
    1461                 if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
    1462                         $siteurl = set_url_scheme( $siteurl, 'https' );
    1463                 }
    1464                 if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
    1465                         $home = set_url_scheme( $home, 'https' );
    1466                 }
    1467 
     1571                if ( 'https' === parse_url( get_site_option( 'siteurl' ), PHP_URL_SCHEME ) ) {
     1572                        $siteurl = set_url_scheme( $siteurl, 'https' );
     1573                }
     1574                if ( 'https' === parse_url( get_home_url( get_network()->site_id ), PHP_URL_SCHEME ) ) {
     1575                        $home = set_url_scheme( $home, 'https' );
     1576                }
    14681577        }
    14691578
     
    14711580        update_option( 'home', $home );
    14721581
    1473         if ( get_site_option( 'ms_files_rewriting' ) )
     1582        if ( get_site_option( 'ms_files_rewriting' ) ) {
    14741583                update_option( 'upload_path', UPLOADBLOGSDIR . "/$blog_id/files" );
    1475         else
     1584        } else {
    14761585                update_option( 'upload_path', get_blog_option( get_network()->site_id, 'upload_path' ) );
     1586        }
    14771587
    14781588        update_option( 'blogname', wp_unslash( $blog_title ) );
     
    14811591        // remove all perms
    14821592        $table_prefix = $wpdb->get_blog_prefix();
    1483         delete_metadata( 'user', 0, $table_prefix . 'user_level',   null, true ); // delete all
     1593        delete_metadata( 'user', 0, $table_prefix . 'user_level', null, true ); // delete all
    14841594        delete_metadata( 'user', 0, $table_prefix . 'capabilities', null, true ); // delete all
    14851595}
     
    14991609 * @param int $user_id
    15001610 */
    1501 function install_blog_defaults($blog_id, $user_id) {
     1611function install_blog_defaults( $blog_id, $user_id ) {
    15021612        global $wpdb;
    15031613
     
    15061616        $suppress = $wpdb->suppress_errors();
    15071617
    1508         wp_install_defaults($user_id);
     1618        wp_install_defaults( $user_id );
    15091619
    15101620        $wpdb->suppress_errors( $suppress );
     
    15441654         * @param array    $meta     Signup meta data. By default, contains the requested privacy setting and lang_id.
    15451655         */
    1546         if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) )
     1656        if ( ! apply_filters( 'wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta ) ) {
    15471657                return false;
     1658        }
    15481659
    15491660        $user = get_userdata( $user_id );
     
    15541665        if ( $welcome_email == false ) {
    15551666                /* translators: Do not translate USERNAME, SITE_NAME, BLOG_URL, PASSWORD: those are placeholders. */
    1556                 $welcome_email = __( 'Howdy USERNAME,
     1667                $welcome_email = __(
     1668                        'Howdy USERNAME,
    15571669
    15581670Your new SITE_NAME site has been successfully set up at:
     
    15671679We hope you enjoy your new site. Thanks!
    15681680
    1569 --The Team @ SITE_NAME' );
    1570         }
    1571 
    1572         $url = get_blogaddress_by_id($blog_id);
     1681--The Team @ SITE_NAME'
     1682                );
     1683        }
     1684
     1685        $url = get_blogaddress_by_id( $blog_id );
    15731686
    15741687        $welcome_email = str_replace( 'SITE_NAME', $current_network->site_name, $welcome_email );
     
    15931706         */
    15941707        $welcome_email = apply_filters( 'update_welcome_email', $welcome_email, $blog_id, $user_id, $password, $title, $meta );
    1595         $admin_email = get_site_option( 'admin_email' );
    1596 
    1597         if ( $admin_email == '' )
     1708        $admin_email   = get_site_option( 'admin_email' );
     1709
     1710        if ( $admin_email == '' ) {
    15981711                $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    1599 
    1600         $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
    1601         $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    1602         $message = $welcome_email;
    1603 
    1604         if ( empty( $current_network->site_name ) )
     1712        }
     1713
     1714        $from_name       = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
     1715        $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
     1716        $message         = $welcome_email;
     1717
     1718        if ( empty( $current_network->site_name ) ) {
    16051719                $current_network->site_name = 'WordPress';
     1720        }
    16061721
    16071722        /* translators: New site notification email subject. 1: Network name, 2: New site name */
     
    16441759
    16451760        /**
    1646          * Filters whether to bypass the welcome email after user activation.
     1761         * Filters whether to bypass the welcome email after user activation.
    16471762         *
    16481763         * Returning false disables the welcome email.
     
    16541769         * @param array  $meta     Signup meta data. Default empty array.
    16551770         */
    1656         if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) )
     1771        if ( ! apply_filters( 'wpmu_welcome_user_notification', $user_id, $password, $meta ) ) {
    16571772                return false;
     1773        }
    16581774
    16591775        $welcome_email = get_site_option( 'welcome_user_email' );
     
    16831799        $admin_email = get_site_option( 'admin_email' );
    16841800
    1685         if ( $admin_email == '' )
     1801        if ( $admin_email == '' ) {
    16861802                $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    1687 
    1688         $from_name = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
    1689         $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    1690         $message = $welcome_email;
    1691 
    1692         if ( empty( $current_network->site_name ) )
     1803        }
     1804
     1805        $from_name       = get_site_option( 'site_name' ) == '' ? 'WordPress' : esc_html( get_site_option( 'site_name' ) );
     1806        $message_headers = "From: \"{$from_name}\" <{$admin_email}>\n" . 'Content-Type: text/plain; charset="' . get_option( 'blog_charset' ) . "\"\n";
     1807        $message         = $welcome_email;
     1808
     1809        if ( empty( $current_network->site_name ) ) {
    16931810                $current_network->site_name = 'WordPress';
     1811        }
    16941812
    16951813        /* translators: New user notification email subject. 1: Network name, 2: New user login */
     
    17031821         * @param string $subject Subject of the email.
    17041822         */
    1705         $subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login) );
     1823        $subject = apply_filters( 'update_welcome_user_subject', sprintf( $subject, $current_network->site_name, $user->user_login ) );
    17061824        wp_mail( $user->user_email, wp_specialchars_decode( $subject ), $message, $message_headers );
    17071825
     
    17481866        global $wpdb;
    17491867
    1750         $user_blogs = get_blogs_of_user( (int) $user_id );
     1868        $user_blogs       = get_blogs_of_user( (int) $user_id );
    17511869        $most_recent_post = array();
    17521870
     
    17541872        // published by $user_id
    17551873        foreach ( (array) $user_blogs as $blog ) {
    1756                 $prefix = $wpdb->get_blog_prefix( $blog->userblog_id );
    1757                 $recent_post = $wpdb->get_row( $wpdb->prepare("SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A);
     1874                $prefix      = $wpdb->get_blog_prefix( $blog->userblog_id );
     1875                $recent_post = $wpdb->get_row( $wpdb->prepare( "SELECT ID, post_date_gmt FROM {$prefix}posts WHERE post_author = %d AND post_type = 'post' AND post_status = 'publish' ORDER BY post_date_gmt DESC LIMIT 1", $user_id ), ARRAY_A );
    17581876
    17591877                // Make sure we found a post
    1760                 if ( isset($recent_post['ID']) ) {
    1761                         $post_gmt_ts = strtotime($recent_post['post_date_gmt']);
     1878                if ( isset( $recent_post['ID'] ) ) {
     1879                        $post_gmt_ts = strtotime( $recent_post['post_date_gmt'] );
    17621880
    17631881                        // If this is the first post checked or if this post is
    17641882                        // newer than the current recent post, make it the new
    17651883                        // most recent post.
    1766                         if ( !isset($most_recent_post['post_gmt_ts']) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) {
     1884                        if ( ! isset( $most_recent_post['post_gmt_ts'] ) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) {
    17671885                                $most_recent_post = array(
    1768                                         'blog_id'               => $blog->userblog_id,
    1769                                         'post_id'               => $recent_post['ID'],
    1770                                         'post_date_gmt' => $recent_post['post_date_gmt'],
    1771                                         'post_gmt_ts'   => $post_gmt_ts
     1886                                        'blog_id'       => $blog->userblog_id,
     1887                                        'post_id'       => $recent_post['ID'],
     1888                                        'post_date_gmt' => $recent_post['post_date_gmt'],
     1889                                        'post_gmt_ts'   => $post_gmt_ts,
    17721890                                );
    17731891                        }
     
    17931911function get_dirsize( $directory ) {
    17941912        $dirsize = get_transient( 'dirsize_cache' );
    1795         if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
    1796                 return $dirsize[ $directory ][ 'size' ];
    1797 
    1798         if ( ! is_array( $dirsize ) )
     1913        if ( is_array( $dirsize ) && isset( $dirsize[ $directory ]['size'] ) ) {
     1914                return $dirsize[ $directory ]['size'];
     1915        }
     1916
     1917        if ( ! is_array( $dirsize ) ) {
    17991918                $dirsize = array();
     1919        }
    18001920
    18011921        // Exclude individual site directories from the total when checking the main site,
    18021922        // as they are subdirectories and should not be counted.
    18031923        if ( is_main_site() ) {
    1804                 $dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory, $directory . '/sites' );
     1924                $dirsize[ $directory ]['size'] = recurse_dirsize( $directory, $directory . '/sites' );
    18051925        } else {
    1806                 $dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory );
     1926                $dirsize[ $directory ]['size'] = recurse_dirsize( $directory );
    18071927        }
    18081928
    18091929        set_transient( 'dirsize_cache', $dirsize, HOUR_IN_SECONDS );
    1810         return $dirsize[ $directory ][ 'size' ];
     1930        return $dirsize[ $directory ]['size'];
    18111931}
    18121932
     
    18331953        }
    18341954
    1835         if ($handle = opendir($directory)) {
    1836                 while(($file = readdir($handle)) !== false) {
    1837                         $path = $directory.'/'.$file;
    1838                         if ($file != '.' && $file != '..') {
    1839                                 if (is_file($path)) {
    1840                                         $size += filesize($path);
    1841                                 } elseif (is_dir($path)) {
     1955        if ( $handle = opendir( $directory ) ) {
     1956                while ( ( $file = readdir( $handle ) ) !== false ) {
     1957                        $path = $directory . '/' . $file;
     1958                        if ( $file != '.' && $file != '..' ) {
     1959                                if ( is_file( $path ) ) {
     1960                                        $size += filesize( $path );
     1961                                } elseif ( is_dir( $path ) ) {
    18421962                                        $handlesize = recurse_dirsize( $path, $exclude );
    1843                                         if ($handlesize > 0)
     1963                                        if ( $handlesize > 0 ) {
    18441964                                                $size += $handlesize;
     1965                                        }
    18451966                                }
    18461967                        }
    18471968                }
    1848                 closedir($handle);
     1969                closedir( $handle );
    18491970        }
    18501971        return $size;
     
    18661987 */
    18671988function check_upload_mimes( $mimes ) {
    1868         $site_exts = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) );
     1989        $site_exts  = explode( ' ', get_site_option( 'upload_filetypes', 'jpg jpeg png gif' ) );
    18691990        $site_mimes = array();
    18701991        foreach ( $site_exts as $ext ) {
    18711992                foreach ( $mimes as $ext_pattern => $mime ) {
    1872                         if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false )
    1873                                 $site_mimes[$ext_pattern] = $mime;
     1993                        if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) {
     1994                                $site_mimes[ $ext_pattern ] = $mime;
     1995                        }
    18741996                }
    18751997        }
     
    19092031        global $wpdb;
    19102032        $user = get_userdata( (int) $user_id );
    1911         if ( $user )
    1912                 $wpdb->insert( $wpdb->registration_log, array('email' => $user->user_email, 'IP' => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ), 'blog_id' => $blog_id, 'date_registered' => current_time('mysql')) );
     2033        if ( $user ) {
     2034                $wpdb->insert(
     2035                        $wpdb->registration_log, array(
     2036                                'email'           => $user->user_email,
     2037                                'IP'              => preg_replace( '/[^0-9., ]/', '', wp_unslash( $_SERVER['REMOTE_ADDR'] ) ),
     2038                                'blog_id'         => $blog_id,
     2039                                'date_registered' => current_time( 'mysql' ),
     2040                        )
     2041                );
     2042        }
    19132043}
    19142044
     
    19312061        static $global_terms_recurse = null;
    19322062
    1933         if ( !global_terms_enabled() )
     2063        if ( ! global_terms_enabled() ) {
    19342064                return $term_id;
     2065        }
    19352066
    19362067        // prevent a race condition
    19372068        $recurse_start = false;
    19382069        if ( $global_terms_recurse === null ) {
    1939                 $recurse_start = true;
     2070                $recurse_start        = true;
    19402071                $global_terms_recurse = 1;
    19412072        } elseif ( 10 < $global_terms_recurse++ ) {
     
    19442075
    19452076        $term_id = intval( $term_id );
    1946         $c = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );
     2077        $c       = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM $wpdb->terms WHERE term_id = %d", $term_id ) );
    19472078
    19482079        $global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE category_nicename = %s", $c->slug ) );
     
    19502081                $used_global_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM $wpdb->sitecategories WHERE cat_ID = %d", $c->term_id ) );
    19512082                if ( null == $used_global_id ) {
    1952                         $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $term_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
     2083                        $wpdb->insert(
     2084                                $wpdb->sitecategories, array(
     2085                                        'cat_ID'            => $term_id,
     2086                                        'cat_name'          => $c->name,
     2087                                        'category_nicename' => $c->slug,
     2088                                )
     2089                        );
    19532090                        $global_id = $wpdb->insert_id;
    1954                         if ( empty( $global_id ) )
     2091                        if ( empty( $global_id ) ) {
    19552092                                return $term_id;
     2093                        }
    19562094                } else {
    19572095                        $max_global_id = $wpdb->get_var( "SELECT MAX(cat_ID) FROM $wpdb->sitecategories" );
    1958                         $max_local_id = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" );
     2096                        $max_local_id  = $wpdb->get_var( "SELECT MAX(term_id) FROM $wpdb->terms" );
    19592097                        $new_global_id = max( $max_global_id, $max_local_id ) + mt_rand( 100, 400 );
    1960                         $wpdb->insert( $wpdb->sitecategories, array( 'cat_ID' => $new_global_id, 'cat_name' => $c->name, 'category_nicename' => $c->slug ) );
     2098                        $wpdb->insert(
     2099                                $wpdb->sitecategories, array(
     2100                                        'cat_ID'            => $new_global_id,
     2101                                        'cat_name'          => $c->name,
     2102                                        'category_nicename' => $c->slug,
     2103                                )
     2104                        );
    19612105                        $global_id = $wpdb->insert_id;
    19622106                }
     
    19722116
    19732117        if ( $global_id != $term_id ) {
    1974                 if ( get_option( 'default_category' ) == $term_id )
     2118                if ( get_option( 'default_category' ) == $term_id ) {
    19752119                        update_option( 'default_category', $global_id );
    1976 
    1977                 $wpdb->update( $wpdb->terms, array('term_id' => $global_id), array('term_id' => $term_id) );
    1978                 $wpdb->update( $wpdb->term_taxonomy, array('term_id' => $global_id), array('term_id' => $term_id) );
    1979                 $wpdb->update( $wpdb->term_taxonomy, array('parent' => $global_id), array('parent' => $term_id) );
    1980 
    1981                 clean_term_cache($term_id);
    1982         }
    1983         if ( $recurse_start )
     2120                }
     2121
     2122                $wpdb->update( $wpdb->terms, array( 'term_id' => $global_id ), array( 'term_id' => $term_id ) );
     2123                $wpdb->update( $wpdb->term_taxonomy, array( 'term_id' => $global_id ), array( 'term_id' => $term_id ) );
     2124                $wpdb->update( $wpdb->term_taxonomy, array( 'parent' => $global_id ), array( 'parent' => $term_id ) );
     2125
     2126                clean_term_cache( $term_id );
     2127        }
     2128        if ( $recurse_start ) {
    19842129                $global_terms_recurse = null;
     2130        }
    19852131
    19862132        return $global_id;
     
    20112157 */
    20122158function upload_is_file_too_big( $upload ) {
    2013         if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) )
     2159        if ( ! is_array( $upload ) || defined( 'WP_IMPORTING' ) || get_site_option( 'upload_space_check_disabled' ) ) {
    20142160                return $upload;
    2015 
    2016         if ( strlen( $upload['bits'] )  > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
     2161        }
     2162
     2163        if ( strlen( $upload['bits'] ) > ( KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
    20172164                return sprintf( __( 'This file is too big. Files must be less than %d KB in size.' ) . '<br />', get_site_option( 'fileupload_maxk', 1500 ) );
    20182165        }
     
    20292176        $id = mt_rand();
    20302177        echo "<input type='hidden' name='signup_form_id' value='{$id}' />";
    2031         wp_nonce_field('signup_form_' . $id, '_signup_form', false);
     2178        wp_nonce_field( 'signup_form_' . $id, '_signup_form', false );
    20322179}
    20332180
     
    20412188 */
    20422189function signup_nonce_check( $result ) {
    2043         if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )
     2190        if ( ! strpos( $_SERVER['PHP_SELF'], 'wp-signup.php' ) ) {
    20442191                return $result;
    2045 
    2046         if ( wp_create_nonce('signup_form_' . $_POST[ 'signup_form_id' ]) != $_POST['_signup_form'] )
     2192        }
     2193
     2194        if ( wp_create_nonce( 'signup_form_' . $_POST['signup_form_id'] ) != $_POST['_signup_form'] ) {
    20472195                wp_die( __( 'Please try again.' ) );
     2196        }
    20482197
    20492198        return $result;
     
    20662215         */
    20672216        if ( is_main_site() && is_404() && defined( 'NOBLOGREDIRECT' ) && ( $destination = apply_filters( 'blog_redirect_404', NOBLOGREDIRECT ) ) ) {
    2068                 if ( $destination == '%siteurl%' )
     2217                if ( $destination == '%siteurl%' ) {
    20692218                        $destination = network_home_url();
     2219                }
    20702220                wp_redirect( $destination );
    20712221                exit();
     
    20832233 */
    20842234function maybe_add_existing_user_to_blog() {
    2085         if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
     2235        if ( false === strpos( $_SERVER['REQUEST_URI'], '/newbloguser/' ) ) {
    20862236                return;
    2087 
    2088         $parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );
    2089         $key = array_pop( $parts );
    2090 
    2091         if ( $key == '' )
     2237        }
     2238
     2239        $parts = explode( '/', $_SERVER['REQUEST_URI'] );
     2240        $key   = array_pop( $parts );
     2241
     2242        if ( $key == '' ) {
    20922243                $key = array_pop( $parts );
     2244        }
    20932245
    20942246        $details = get_option( 'new_user_' . $key );
    2095         if ( !empty( $details ) )
     2247        if ( ! empty( $details ) ) {
    20962248                delete_option( 'new_user_' . $key );
    2097 
    2098         if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )
    2099                 wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), home_url() ) );
    2100 
    2101         wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress &rsaquo; Success' ), array( 'response' => 200 ) );
     2249        }
     2250
     2251        if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) ) {
     2252                wp_die( sprintf( __( 'An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.' ), home_url() ) );
     2253        }
     2254
     2255        wp_die( sprintf( __( 'You have been added to this site. Please visit the <a href="%1$s">homepage</a> or <a href="%2$s">log in</a> using your username and password.' ), home_url(), admin_url() ), __( 'WordPress &rsaquo; Success' ), array( 'response' => 200 ) );
    21022256}
    21032257
     
    21132267        if ( is_array( $details ) ) {
    21142268                $blog_id = get_current_blog_id();
    2115                 $result = add_user_to_blog( $blog_id, $details[ 'user_id' ], $details[ 'role' ] );
     2269                $result  = add_user_to_blog( $blog_id, $details['user_id'], $details['role'] );
    21162270
    21172271                /**
     
    21442298 */
    21452299function add_new_user_to_blog( $user_id, $password, $meta ) {
    2146         if ( !empty( $meta[ 'add_to_blog' ] ) ) {
    2147                 $blog_id = $meta[ 'add_to_blog' ];
    2148                 $role = $meta[ 'new_role' ];
     2300        if ( ! empty( $meta['add_to_blog'] ) ) {
     2301                $blog_id = $meta['add_to_blog'];
     2302                $role    = $meta['new_role'];
    21492303                remove_user_from_blog( $user_id, get_network()->site_id ); // remove user from main blog.
    21502304
     
    21742328 *
    21752329 * @param string|WP_User $user Optional. Defaults to current user. WP_User object,
    2176  *                                 or user login name as a string.
     2330 *                             or user login name as a string.
    21772331 * @return bool
    21782332 */
    21792333function is_user_spammy( $user = null ) {
    2180     if ( ! ( $user instanceof WP_User ) ) {
     2334        if ( ! ( $user instanceof WP_User ) ) {
    21812335                if ( $user ) {
    21822336                        $user = get_user_by( 'login', $user );
     
    22112365 */
    22122366function users_can_register_signup_filter() {
    2213         $registration = get_site_option('registration');
     2367        $registration = get_site_option( 'registration' );
    22142368        return ( $registration == 'all' || $registration == 'user' );
    22152369}
     
    22242378 */
    22252379function welcome_user_msg_filter( $text ) {
    2226         if ( !$text ) {
     2380        if ( ! $text ) {
    22272381                remove_filter( 'site_option_welcome_user_email', 'welcome_user_msg_filter' );
    22282382
    22292383                /* translators: Do not translate USERNAME, PASSWORD, LOGINLINK, SITE_NAME: those are placeholders. */
    2230                 $text = __( 'Howdy USERNAME,
     2384                $text = __(
     2385                        'Howdy USERNAME,
    22312386
    22322387Your new account is set up.
     
    22392394Thanks!
    22402395
    2241 --The Team @ SITE_NAME' );
     2396--The Team @ SITE_NAME'
     2397                );
    22422398                update_site_option( 'welcome_user_email', $text );
    22432399        }
     
    22592415
    22602416        if ( '' != $force ) {
    2261                 $old_forced = $forced_content;
     2417                $old_forced     = $forced_content;
    22622418                $forced_content = $force;
    22632419                return $old_forced;
     
    22782434 */
    22792435function filter_SSL( $url ) {
    2280         if ( ! is_string( $url ) )
     2436        if ( ! is_string( $url ) ) {
    22812437                return get_bloginfo( 'url' ); // Return home blog url with proper scheme
    2282 
    2283         if ( force_ssl_content() && is_ssl() )
     2438        }
     2439
     2440        if ( force_ssl_content() && is_ssl() ) {
    22842441                $url = set_url_scheme( $url, 'https' );
     2442        }
    22852443
    22862444        return $url;
     
    22932451 */
    22942452function wp_schedule_update_network_counts() {
    2295         if ( !is_main_site() )
     2453        if ( ! is_main_site() ) {
    22962454                return;
    2297 
    2298         if ( ! wp_next_scheduled('update_network_counts') && ! wp_installing() )
    2299                 wp_schedule_event(time(), 'twicedaily', 'update_network_counts');
     2455        }
     2456
     2457        if ( ! wp_next_scheduled( 'update_network_counts' ) && ! wp_installing() ) {
     2458                wp_schedule_event( time(), 'twicedaily', 'update_network_counts' );
     2459        }
    23002460}
    23012461
     
    23372497         * @param string $context       Context. Either 'users' or 'sites'.
    23382498         */
    2339         if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) )
     2499        if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'sites' ) ) {
    23402500                return;
     2501        }
    23412502
    23422503        wp_update_network_site_counts( $network_id );
     
    23582519
    23592520        /** This filter is documented in wp-includes/ms-functions.php */
    2360         if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) )
     2521        if ( ! apply_filters( 'enable_live_network_counts', $is_small_network, 'users' ) ) {
    23612522                return;
     2523        }
    23622524
    23632525        wp_update_network_user_counts( $network_id );
     
    23782540        }
    23792541
    2380         $count = get_sites( array(
    2381                 'network_id' => $network_id,
    2382                 'spam'       => 0,
    2383                 'deleted'    => 0,
    2384                 'archived'   => 0,
    2385                 'count'      => true,
    2386         ) );
     2542        $count = get_sites(
     2543                array(
     2544                        'network_id' => $network_id,
     2545                        'spam'       => 0,
     2546                        'deleted'    => 0,
     2547                        'archived'   => 0,
     2548                        'count'      => true,
     2549                )
     2550        );
    23872551
    23882552        update_network_option( $network_id, 'blog_count', $count );
     
    24402604        $space_allowed = get_option( 'blog_upload_space' );
    24412605
    2442         if ( ! is_numeric( $space_allowed ) )
     2606        if ( ! is_numeric( $space_allowed ) ) {
    24432607                $space_allowed = get_site_option( 'blog_upload_space' );
    2444 
    2445         if ( ! is_numeric( $space_allowed ) )
     2608        }
     2609
     2610        if ( ! is_numeric( $space_allowed ) ) {
    24462611                $space_allowed = 100;
     2612        }
    24472613
    24482614        /**
     
    24692635        }
    24702636        $space_allowed = $allowed * MB_IN_BYTES;
    2471         if ( get_site_option( 'upload_space_check_disabled' ) )
     2637        if ( get_site_option( 'upload_space_check_disabled' ) ) {
    24722638                return $space_allowed;
     2639        }
    24732640
    24742641        $space_used = get_space_used() * MB_IN_BYTES;
    24752642
    2476         if ( ( $space_allowed - $space_used ) <= 0 )
     2643        if ( ( $space_allowed - $space_used ) <= 0 ) {
    24772644                return 0;
     2645        }
    24782646
    24792647        return $space_allowed - $space_used;
     
    24872655 */
    24882656function is_upload_space_available() {
    2489         if ( get_site_option( 'upload_space_check_disabled' ) )
     2657        if ( get_site_option( 'upload_space_check_disabled' ) ) {
    24902658                return true;
     2659        }
    24912660
    24922661        return (bool) get_upload_space_available();
     
    25032672function upload_size_limit_filter( $size ) {
    25042673        $fileupload_maxk = KB_IN_BYTES * get_site_option( 'fileupload_maxk', 1500 );
    2505         if ( get_site_option( 'upload_space_check_disabled' ) )
     2674        if ( get_site_option( 'upload_space_check_disabled' ) ) {
    25062675                return min( $size, $fileupload_maxk );
     2676        }
    25072677
    25082678        return min( $size, $fileupload_maxk, get_upload_space_available() );
     
    25582728function get_subdirectory_reserved_names() {
    25592729        $names = array(
    2560                 'page', 'comments', 'blog', 'files', 'feed', 'wp-admin',
    2561                 'wp-content', 'wp-includes', 'wp-json', 'embed'
     2730                'page',
     2731                'comments',
     2732                'blog',
     2733                'files',
     2734                'feed',
     2735                'wp-admin',
     2736                'wp-content',
     2737                'wp-includes',
     2738                'wp-json',
     2739                'embed',
    25622740        );
    25632741
     
    25892767        }
    25902768
    2591         $hash = md5( $value . time() . mt_rand() );
     2769        $hash            = md5( $value . time() . mt_rand() );
    25922770        $new_admin_email = array(
    25932771                'hash'     => $hash,
     
    25992777
    26002778        /* translators: Do not translate USERNAME, ADMIN_URL, EMAIL, SITENAME, SITEURL: those are placeholders. */
    2601         $email_text = __( 'Howdy ###USERNAME###,
     2779        $email_text = __(
     2780                'Howdy ###USERNAME###,
    26022781
    26032782You recently requested to have the network admin email address on
     
    26142793Regards,
    26152794All at ###SITENAME###
    2616 ###SITEURL###' );
     2795###SITEURL###'
     2796        );
    26172797
    26182798        /**
     
    26392819
    26402820        $current_user = wp_get_current_user();
    2641         $content = str_replace( '###USERNAME###', $current_user->user_login, $content );
    2642         $content = str_replace( '###ADMIN_URL###', esc_url( network_admin_url( 'settings.php?network_admin_hash=' . $hash ) ), $content );
    2643         $content = str_replace( '###EMAIL###', $value, $content );
    2644         $content = str_replace( '###SITENAME###', wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ), $content );
    2645         $content = str_replace( '###SITEURL###', network_home_url(), $content );
     2821        $content      = str_replace( '###USERNAME###', $current_user->user_login, $content );
     2822        $content      = str_replace( '###ADMIN_URL###', esc_url( network_admin_url( 'settings.php?network_admin_hash=' . $hash ) ), $content );
     2823        $content      = str_replace( '###EMAIL###', $value, $content );
     2824        $content      = str_replace( '###SITENAME###', wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ), $content );
     2825        $content      = str_replace( '###SITEURL###', network_home_url(), $content );
    26462826
    26472827        wp_mail( $value, sprintf( __( '[%s] New Network Admin Email Address' ), wp_specialchars_decode( get_site_option( 'site_name' ), ENT_QUOTES ) ), $content );
     
    26802860
    26812861        /* translators: Do not translate OLD_EMAIL, NEW_EMAIL, SITENAME, SITEURL: those are placeholders. */
    2682         $email_change_text = __( 'Hi,
     2862        $email_change_text = __(
     2863                'Hi,
    26832864
    26842865This notice confirms that the network admin email address was changed on ###SITENAME###.
     
    26902871Regards,
    26912872All at ###SITENAME###
    2692 ###SITEURL###' );
     2873###SITEURL###'
     2874        );
    26932875
    26942876        $email_change_email = array(
     
    27262908        $email_change_email = apply_filters( 'network_admin_email_change_email', $email_change_email, $old_email, $new_email, $network_id );
    27272909
    2728         $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email,    $email_change_email['message'] );
    2729         $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email,    $email_change_email['message'] );
    2730         $email_change_email['message'] = str_replace( '###SITENAME###',  $network_name, $email_change_email['message'] );
    2731         $email_change_email['message'] = str_replace( '###SITEURL###',   home_url(),    $email_change_email['message'] );
    2732 
    2733         wp_mail( $email_change_email['to'], sprintf(
    2734                 $email_change_email['subject'],
    2735                 $network_name
    2736         ), $email_change_email['message'], $email_change_email['headers'] );
    2737 }
     2910        $email_change_email['message'] = str_replace( '###OLD_EMAIL###', $old_email, $email_change_email['message'] );
     2911        $email_change_email['message'] = str_replace( '###NEW_EMAIL###', $new_email, $email_change_email['message'] );
     2912        $email_change_email['message'] = str_replace( '###SITENAME###', $network_name, $email_change_email['message'] );
     2913        $email_change_email['message'] = str_replace( '###SITEURL###', home_url(), $email_change_email['message'] );
     2914
     2915        wp_mail(
     2916                $email_change_email['to'], sprintf(
     2917                        $email_change_email['subject'],
     2918                        $network_name
     2919                ), $email_change_email['message'], $email_change_email['headers']
     2920        );
     2921}
Note: See TracChangeset for help on using the changeset viewer.