Make WordPress Core

Changeset 12709


Ignore:
Timestamp:
01/12/2010 06:40:40 PM (14 years ago)
Author:
ryan
Message:

Formatting cleanup. Props Simek. fixes #11876

File:
1 edited

Legend:

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

    r12674 r12709  
    3232    global $current_site;
    3333
    34     if( is_subdomain_install() ) {
    35         if( $blogname == 'main' )
     34    if ( is_subdomain_install() ) {
     35        if ( $blogname == 'main' )
    3636            $blogname = 'www';
    3737        return clean_url( "http://" . $blogname . "." . $current_site->domain . $current_site->path );
     
    4242
    4343function get_blogaddress_by_domain( $domain, $path ){
    44     if( is_subdomain_install() ) {
     44    if ( is_subdomain_install() ) {
    4545        $url = "http://".$domain.$path;
    4646    } else {
    47         if( $domain != $_SERVER['HTTP_HOST'] ) {
     47        if ( $domain != $_SERVER['HTTP_HOST'] ) {
    4848            $blogname = substr( $domain, 0, strpos( $domain, '.' ) );
    49             if( $blogname != 'www.' ) {
     49            if ( $blogname != 'www.' ) {
    5050                $url = 'http://' . substr( $domain, strpos( $domain, '.' ) + 1 ) . $path . $blogname . '/';
    5151            } else { // we're installing the main blog
     
    6565
    6666    $count_ts = get_site_option( "get_user_count_ts" );
    67     if( time() - $count_ts > 3600 ) {
     67    if ( time() - $count_ts > 3600 ) {
    6868        $count = $wpdb->get_var( "SELECT COUNT(ID) FROM {$wpdb->users}" );
    6969        update_site_option( "user_count", $count );
     
    7979    global $wpdb;
    8080
    81     if( $sitedomain == '' ) {
     81    if ( $sitedomain == '' )
    8282        $site_id = $wpdb->siteid;
    83     } else {
     83    else
    8484        $site_id = $wpdb->get_var( $wpdb->prepare("SELECT id FROM $wpdb->site WHERE domain = %s AND path = %s", $sitedomain, $path) );
    85     }
    86 
    87     if( $site_id != false ) {
     85
     86    if ( $site_id != false )
    8887        return $wpdb->get_results( $wpdb->prepare("SELECT u.ID, u.user_login, u.user_pass FROM $wpdb->users AS u, $wpdb->sitemeta AS sm WHERE sm.meta_key = 'admin_user_id' AND u.ID = sm.meta_value AND sm.site_id = %d", $site_id), ARRAY_A );
    89     }
     88
    9089    return false;
    9190}
     
    9897function is_main_blog() {
    9998    global $current_blog, $current_site;
    100     if( $current_blog->domain == $current_site->domain && $current_blog->path == $current_site->path )
     99    if ( $current_blog->domain == $current_site->domain && $current_blog->path == $current_site->path )
    101100        return true;
    102101    return false;
     
    124123    global $wpdb;
    125124
    126     if( !is_numeric( $id ) ) {
     125    if ( !is_numeric( $id ) )
    127126        $id = get_id_from_blogname( $id );
    128     }
     127
    129128    $all = $getall == true ? '' : 'short';
    130129    $details = wp_cache_get( $id . $all, 'blog-details' );
     
    152151    $wpdb->suppress_errors();
    153152    switch_to_blog( $id );
    154     $details->blogname   = get_option( 'blogname' );
    155     $details->siteurl    = get_option( 'siteurl' );
    156     $details->post_count = get_option( 'post_count' );
     153    $details->blogname      = get_option( 'blogname' );
     154    $details->siteurl       = get_option( 'siteurl' );
     155    $details->post_count    = get_option( 'post_count' );
    157156    restore_current_blog();
    158157    $wpdb->suppress_errors( false );
     
    217216        if ( is_object( $row ) ) { // Has to be get_row instead of get_var because of funkiness with 0, false, null values
    218217            $value = $row->option_value;
    219             if ( $value == false ) {
     218            if ( $value == false )
    220219                wp_cache_set( $key, 'falsevalue', 'site-options' );
    221             } else {
     220            else
    222221                wp_cache_set( $key, $value, 'site-options' );
    223             }
    224222        } else { // option does not exist, so we must cache its non-existence
    225223            wp_cache_set( $key, 'noop', 'site-options' );
    226224            $value = $default;
    227225        }
    228     } elseif( $value == 'noop' ) {
     226    } elseif ( $value == 'noop' ) {
    229227        $value = $default;
    230     } elseif( $value == 'falsevalue' ) {
     228    } elseif ( $value == 'falsevalue' ) {
    231229        $value = false;
    232230    }
     
    269267    restore_current_blog();
    270268
    271     if( $refresh == true )
     269    if ( $refresh == true )
    272270        refresh_blog_details( $id );
    273271    wp_cache_set( $id."-".$key."-blog_option", $value, 'site-options');
     
    299297    $blog_id = $new_blog;
    300298
    301     if( is_object( $wp_roles ) ) {
     299    if ( is_object( $wp_roles ) ) {
    302300        $wpdb->suppress_errors();
    303         if ( method_exists( $wp_roles ,'_init' ) ) {
     301        if ( method_exists( $wp_roles ,'_init' ) )
    304302            $wp_roles->_init();
    305         } elseif( method_exists( $wp_roles, '__construct' ) ) {
     303        elseif ( method_exists( $wp_roles, '__construct' ) )
    306304            $wp_roles->__construct();
    307         }
    308305        $wpdb->suppress_errors( false );
    309306    }
     
    312309        $current_user->_init_caps();
    313310
    314     if ( is_object( $wp_object_cache ) ) {
     311    if ( is_object( $wp_object_cache ) )
    315312        $global_groups = $wp_object_cache->global_groups;
    316     } else {
     313    else
    317314        $global_groups = false;
    318     }
     315
    319316    wp_cache_init();
    320317    if ( function_exists('wp_cache_add_global_groups') ) {
    321         if ( is_array( $global_groups ) ) {
     318        if ( is_array( $global_groups ) )
    322319            wp_cache_add_global_groups( $global_groups );
    323         } else {
     320        else
    324321            wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'site-transient', 'global-posts' ) );
    325         }
    326322        wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
    327323    }
     
    354350    $table_prefix = $wpdb->prefix;
    355351
    356     if( is_object( $wp_roles ) ) {
     352    if ( is_object( $wp_roles ) ) {
    357353        $wpdb->suppress_errors();
    358         if ( method_exists( $wp_roles ,'_init' ) ) {
     354        if ( method_exists( $wp_roles ,'_init' ) )
    359355            $wp_roles->_init();
    360         } elseif( method_exists( $wp_roles, '__construct' ) ) {
     356        elseif ( method_exists( $wp_roles, '__construct' ) )
    361357            $wp_roles->__construct();
    362         }
    363358        $wpdb->suppress_errors( false );
    364359    }
     
    367362        $current_user->_init_caps();
    368363
    369     if ( is_object( $wp_object_cache ) ) {
     364    if ( is_object( $wp_object_cache ) )
    370365        $global_groups = $wp_object_cache->global_groups;
    371     } else {
     366    else
    372367        $global_groups = false;
    373     }
     368
    374369    wp_cache_init();
    375370    if ( function_exists('wp_cache_add_global_groups') ) {
    376         if ( is_array( $global_groups ) ) {
     371        if ( is_array( $global_groups ) )
    377372            wp_cache_add_global_groups( $global_groups );
    378         } else {
     373        else
    379374            wp_cache_add_global_groups( array( 'users', 'userlogins', 'usermeta', 'site-options', 'site-lookup', 'blog-lookup', 'blog-details', 'rss', 'site-transient' ) );
    380         }
    381375        wp_cache_add_non_persistent_groups(array( 'comment', 'counts', 'plugins' ));
    382376    }
     
    394388    $cache_suffix = $all ? '_all' : '_short';
    395389    $return = wp_cache_get( 'blogs_of_user_' . $id . $cache_suffix, 'users' );
    396     if ( $return ) {
     390    if ( $return )
    397391        return apply_filters( 'get_blogs_of_user', $return, $id, $all );
    398     }
    399392
    400393    $user = get_userdata( (int) $id );
     
    407400            $blog = get_blog_details( $match[1] );
    408401            if ( $blog && isset( $blog->domain ) && ( $all == true || $all == false && ( $blog->archived == 0 && $blog->spam == 0 && $blog->deleted == 0 ) ) ) {
    409                 $blogs[$match[1]]->userblog_id = $match[1];
    410                 $blogs[$match[1]]->blogname    = $blog->blogname;
    411                 $blogs[$match[1]]->domain      = $blog->domain;
    412                 $blogs[$match[1]]->path        = $blog->path;
    413                 $blogs[$match[1]]->site_id     = $blog->site_id;
    414                 $blogs[$match[1]]->siteurl     = $blog->siteurl;
     402                $blogs[$match[1]]->userblog_id  = $match[1];
     403                $blogs[$match[1]]->blogname     = $blog->blogname;
     404                $blogs[$match[1]]->domain       = $blog->domain;
     405                $blogs[$match[1]]->path         = $blog->path;
     406                $blogs[$match[1]]->site_id      = $blog->site_id;
     407                $blogs[$match[1]]->siteurl      = $blog->siteurl;
    415408            }
    416409        }
     
    489482    $blog_id = (int) $blog_id;
    490483
    491     if( $blog_id == 0 ) {
     484    if ( $blog_id == 0 ) {
    492485        global $wpdb;
    493486        $blog_id = $wpdb->blogid;
     
    495488
    496489    $blogs = get_blogs_of_user( $user_id );
    497     if( is_array( $blogs ) ) {
     490    if ( is_array( $blogs ) )
    498491        return array_key_exists( $blog_id, $blogs );
    499     } else {
     492    else
    500493        return false;
    501     }
    502494}
    503495
     
    518510
    519511    $wpdb->update( $wpdb->blogs, array($pref => $value, 'last_updated' => current_time('mysql', true)), array('blog_id' => $id) );
    520     if( $refresh == 1 )
     512    if ( $refresh == 1 )
    521513        refresh_blog_details($id);
    522514
    523     if( $pref == 'spam' ) {
    524         if( $value == 1 ) {
     515    if ( $pref == 'spam' ) {
     516        if ( $value == 1 )
    525517            do_action( "make_spam_blog", $id );
    526         } else {
     518        else
    527519            do_action( "make_ham_blog", $id );
    528         }
    529520    }
    530521
     
    536527
    537528    $details = get_blog_details( $id, false );
    538     if( $details ) {
     529    if ( $details )
    539530        return $details->$pref;
    540     }
     531
    541532    return $wpdb->get_var( $wpdb->prepare("SELECT $pref FROM {$wpdb->blogs} WHERE blog_id = %d", $id) );
    542533}
     
    550541    $most_active = get_site_option( "most_active" );
    551542    $update = false;
    552     if( is_array( $most_active ) ) {
    553         if( ( $most_active['time'] + 60 ) < time() ) { // cache for 60 seconds.
     543    if ( is_array( $most_active ) ) {
     544        if ( ( $most_active['time'] + 60 ) < time() ) { // cache for 60 seconds.
    554545            $update = true;
    555546        }
     
    558549    }
    559550
    560     if( $update == true ) {
     551    if ( $update == true ) {
    561552        unset( $most_active );
    562553        $blogs = get_blog_list( 0, 'all', false ); // $blog_id -> $details
    563         if( is_array( $blogs ) ) {
     554        if ( is_array( $blogs ) ) {
    564555            reset( $blogs );
    565556            foreach ( (array) $blogs as $key => $details ) {
     
    569560            arsort( $most_active );
    570561            reset( $most_active );
    571             foreach ( (array) $most_active as $key => $details ) {
     562            foreach ( (array) $most_active as $key => $details )
    572563                $t[ $key ] = $blog_list[ $key ];
    573             }
     564
    574565            unset( $most_active );
    575566            $most_active = $t;
     
    578569    }
    579570
    580     if( $display == true ) {
    581         if( is_array( $most_active ) ) {
     571    if ( $display == true ) {
     572        if ( is_array( $most_active ) ) {
    582573            reset( $most_active );
    583574            foreach ( (array) $most_active as $key => $details ) {
     
    595586    $blogs = get_site_option( "blog_list" );
    596587    $update = false;
    597     if( is_array( $blogs ) ) {
    598         if( ( $blogs['time'] + 60 ) < time() ) { // cache for 60 seconds.
     588    if ( is_array( $blogs ) ) {
     589        if ( ( $blogs['time'] + 60 ) < time() ) { // cache for 60 seconds.
    599590            $update = true;
    600591        }
     
    603594    }
    604595
    605     if( $update == true ) {
     596    if ( $update == true ) {
    606597        unset( $blogs );
    607598        $blogs = $wpdb->get_results( $wpdb->prepare("SELECT blog_id, domain, path FROM $wpdb->blogs WHERE site_id = %d AND public = '1' AND archived = '0' AND mature = '0' AND spam = '0' AND deleted = '0' ORDER BY registered DESC", $wpdb->siteid), ARRAY_A );
     
    616607    }
    617608
    618     if( false == is_array( $blogs ) )
     609    if ( false == is_array( $blogs ) )
    619610        return array();
    620611
    621     if( $num == 'all' ) {
     612    if ( $num == 'all' )
    622613        return array_slice( $blogs, $start, count( $blogs ) );
    623     } else {
     614    else
    624615        return array_slice( $blogs, $start, $num );
    625     }
    626616}
    627617
     
    630620
    631621    $count_ts = get_site_option( "user_count_ts" );
    632     if( time() - $count_ts > 3600 ) {
     622    if ( time() - $count_ts > 3600 ) {
    633623        $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(ID) as c FROM $wpdb->users WHERE spam = '0' AND deleted = '0'") );
    634624        update_site_option( "user_count", $count );
     
    644634    global $wpdb;
    645635
    646     if( $id == 0 )
     636    if ( $id == 0 )
    647637        $id = $wpdb->siteid;
    648638
    649639    $count_ts = get_site_option( "blog_count_ts" );
    650     if( time() - $count_ts > 3600 ) {
     640    if ( time() - $count_ts > 3600 ) {
    651641        $count = $wpdb->get_var( $wpdb->prepare("SELECT COUNT(blog_id) as c FROM $wpdb->blogs WHERE site_id = %d AND spam = '0' AND deleted = '0' and archived = '0'", $id) );
    652642        update_site_option( "blog_count", $count );
     
    664654    $key = $blog_id . "-" . $post_id;
    665655    $post = wp_cache_get( $key, "global-posts" );
    666     if( $post == false ) {
     656    if ( $post == false ) {
    667657        $post = $wpdb->get_row( $wpdb->prepare( "SELECT * FROM " . $wpdb->get_blog_prefix( $blog_id ) . "posts WHERE ID = %d", $post_id ) );
    668658        wp_cache_add( $key, $post, "global-posts" );
     
    737727    }
    738728
    739     if( $reassign != '' ) {
     729    if ( $reassign != '' ) {
    740730        $reassign = (int) $reassign;
    741731        $wpdb->query( $wpdb->prepare("UPDATE $wpdb->posts SET post_author = %d WHERE post_author = %d", $reassign, $user_id) );
     
    747737
    748738function create_empty_blog( $domain, $path, $weblog_title, $site_id = 1 ) {
    749     $domain       = addslashes( $domain );
    750     $weblog_title = addslashes( $weblog_title );
    751 
    752     if( empty($path) )
     739    $domain         = addslashes( $domain );
     740    $weblog_title   = addslashes( $weblog_title );
     741
     742    if ( empty($path) )
    753743        $path = '/';
    754744
     
    774764    $key = "{$_blog_id}-{$post_id}-blog_permalink";
    775765    $link = wp_cache_get( $key, 'site-options' );
    776     if( $link == false ) {
     766    if ( $link == false ) {
    777767        switch_to_blog( $_blog_id );
    778768        $link = get_permalink( $post_id );
     
    790780    $id = wp_cache_get( md5( $domain . $path ), 'blog-id-cache' );
    791781
    792     if( $id == -1 ) { // blog does not exist
     782    if ( $id == -1 ) { // blog does not exist
    793783        return 0;
    794     } elseif( $id ) {
     784    } elseif ( $id ) {
    795785        return (int)$id;
    796786    }
     
    816806        $ref = $_POST['ref'];
    817807
    818     if( $ref ) {
     808    if ( $ref ) {
    819809        $ref = wpmu_admin_redirect_add_updated_param( $ref );
    820810        wp_redirect( $ref );
    821811        exit();
    822812    }
    823     if( empty( $_SERVER['HTTP_REFERER'] ) == false ) {
     813    if ( empty( $_SERVER['HTTP_REFERER'] ) == false ) {
    824814        wp_redirect( $_SERVER['HTTP_REFERER'] );
    825815        exit();
     
    827817
    828818    $url = wpmu_admin_redirect_add_updated_param( $url );
    829     if( isset( $_GET['redirect'] ) ) {
    830         if( substr( $_GET['redirect'], 0, 2 ) == 's_' ) {
     819    if ( isset( $_GET['redirect'] ) ) {
     820        if ( substr( $_GET['redirect'], 0, 2 ) == 's_' )
    831821            $url .= "&action=blogs&s=". wp_specialchars( substr( $_GET['redirect'], 2 ) );
    832         }
    833     } elseif( isset( $_POST['redirect'] ) ) {
     822    } elseif ( isset( $_POST['redirect'] ) ) {
    834823        $url = wpmu_admin_redirect_add_updated_param( $_POST['redirect'] );
    835824    }
     
    839828
    840829function wpmu_admin_redirect_add_updated_param( $url = '' ) {
    841     if( strpos( $url, 'updated=true' ) === false ) {
    842         if( strpos( $url, '?' ) === false ) {
     830    if ( strpos( $url, 'updated=true' ) === false ) {
     831        if ( strpos( $url, '?' ) === false )
    843832            return $url . '?updated=true';
    844         } else {
     833        else
    845834            return $url . '&updated=true';
    846         }
    847835    }
    848836    return $url;
     
    864852
    865853function validate_email( $email, $check_domain = true) {
    866     if (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.
    867         '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
    868         '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $email))
    869     {
    870         if ($check_domain && function_exists('checkdnsrr')) {
    871             list (, $domain)  = explode('@', $email);
    872 
    873             if (checkdnsrr($domain.'.', 'MX') || checkdnsrr($domain.'.', 'A')) {
    874                 return true;
    875             }
    876             return false;
    877         }
    878         return true;
    879     }
    880     return false;
     854    if (ereg('^[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+'.'@'.
     855        '[-!#$%&\'*+\\/0-9=?A-Z^_`a-z{|}~]+\.'.
     856        '[-!#$%&\'*+\\./0-9=?A-Z^_`a-z{|}~]+$', $email))
     857    {
     858        if ($check_domain && function_exists('checkdnsrr')) {
     859            list (, $domain)  = explode('@', $email);
     860
     861            if (checkdnsrr($domain.'.', 'MX') || checkdnsrr($domain.'.', 'A'))
     862                return true;
     863            return false;
     864        }
     865        return true;
     866    }
     867    return false;
    881868}
    882869
    883870function is_email_address_unsafe( $user_email ) {
    884871    $banned_names = get_site_option( "banned_email_domains" );
    885     if ($banned_names && !is_array( $banned_names )) {
     872    if ($banned_names && !is_array( $banned_names ))
    886873        $banned_names = explode( "\n", $banned_names);
    887     }
     874
    888875    if ( is_array( $banned_names ) && empty( $banned_names ) == false ) {
    889876        $email_domain = strtolower( substr( $user_email, 1 + strpos( $user_email, '@' ) ) );
    890877        foreach( (array) $banned_names as $banned_domain ) {
    891             if( $banned_domain == '' )
     878            if ( $banned_domain == '' )
    892879                continue;
    893880            if (
     
    918905    preg_match( "/[a-z0-9]+/", $user_name, $maybe );
    919906
    920     if( $user_name != $maybe[0] ) {
    921         $errors->add('user_name', __("Only lowercase letters and numbers allowed"));
    922     }
     907    if ( $user_name != $maybe[0] )
     908        $errors->add('user_name', __("Only lowercase letters and numbers allowed"));
    923909
    924910    $illegal_names = get_site_option( "illegal_names" );
    925     if( is_array( $illegal_names ) == false ) {
     911    if ( is_array( $illegal_names ) == false ) {
    926912        $illegal_names = array(  "www", "web", "root", "admin", "main", "invite", "administrator" );
    927913        add_site_option( "illegal_names", $illegal_names );
    928914    }
    929     if( in_array( $user_name, $illegal_names ) == true ) {
    930         $errors->add('user_name',  __("That username is not allowed"));
    931     }
    932 
    933     if( is_email_address_unsafe( $user_email ) )
     915    if ( in_array( $user_name, $illegal_names ) == true )
     916        $errors->add('user_name',  __("That username is not allowed"));
     917
     918    if ( is_email_address_unsafe( $user_email ) )
    934919        $errors->add('user_email',  __("You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider."));
    935920
    936     if( strlen( $user_name ) < 4 ) {
    937         $errors->add('user_name',  __("Username must be at least 4 characters"));
    938     }
     921    if ( strlen( $user_name ) < 4 )
     922        $errors->add('user_name',  __("Username must be at least 4 characters"));
    939923
    940924    if ( strpos( " " . $user_name, "_" ) != false )
     
    948932
    949933    if ( !is_email( $user_email ) )
    950         $errors->add('user_email', __("Please enter a correct email address"));
     934        $errors->add('user_email', __("Please enter a correct email address"));
    951935
    952936    if ( !validate_email( $user_email ) )
     
    956940    if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
    957941        $emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
    958         if( in_array( $emaildomain, $limited_email_domains ) == false ) {
     942        if ( in_array( $emaildomain, $limited_email_domains ) == false )
    959943            $errors->add('user_email', __("Sorry, that email address is not allowed!"));
    960         }
    961944    }
    962945
     
    976959        $diff = $now - $registered_at;
    977960        // If registered more than two days ago, cancel registration and let this signup go through.
    978         if ( $diff > 172800 ) {
     961        if ( $diff > 172800 )
    979962            $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_login = %s", $user_name) );
    980         } else {
     963        else
    981964            $errors->add('user_name', __("That username is currently reserved but may be available in a couple of days."));
    982         }
    983         if( $signup->active == 0 && $signup->user_email == $user_email )
     965
     966        if ( $signup->active == 0 && $signup->user_email == $user_email )
    984967            $errors->add('user_email_used', __("username and email used"));
    985968    }
     
    989972        $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
    990973        // If registered more than two days ago, cancel registration and let this signup go through.
    991         if ( $diff > 172800 ) {
     974        if ( $diff > 172800 )
    992975            $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE user_email = %s", $user_email) );
    993         } else {
     976        else
    994977            $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."));
    995         }
    996978    }
    997979
     
    1010992    $errors = new WP_Error();
    1011993    $illegal_names = get_site_option( "illegal_names" );
    1012     if( $illegal_names == false ) {
    1013         $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" );
    1014         add_site_option( "illegal_names", $illegal_names );
     994    if ( $illegal_names == false ) {
     995        $illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" );
     996        add_site_option( "illegal_names", $illegal_names );
    1015997    }
    1016998
    1017999    if ( empty( $blogname ) )
    1018         $errors->add('blogname', __("Please enter a blog name"));
     1000        $errors->add('blogname', __("Please enter a blog name"));
    10191001
    10201002    $maybe = array();
    10211003    preg_match( "/[a-z0-9]+/", $blogname, $maybe );
    1022     if( $blogname != $maybe[0] ) {
    1023         $errors->add('blogname', __("Only lowercase letters and numbers allowed"));
    1024     }
    1025     if( in_array( $blogname, $illegal_names ) == true ) {
    1026         $errors->add('blogname',  __("That name is not allowed"));
    1027     }
    1028     if( strlen( $blogname ) < 4 && !is_super_admin() ) {
    1029         $errors->add('blogname',  __("Blog name must be at least 4 characters"));
    1030     }
     1004    if ( $blogname != $maybe[0] )
     1005        $errors->add('blogname', __("Only lowercase letters and numbers allowed"));
     1006
     1007    if ( in_array( $blogname, $illegal_names ) == true )
     1008        $errors->add('blogname',  __("That name is not allowed"));
     1009
     1010    if ( strlen( $blogname ) < 4 && !is_super_admin() )
     1011        $errors->add('blogname',  __("Blog name must be at least 4 characters"));
    10311012
    10321013    if ( strpos( " " . $blogname, "_" ) != false )
     
    10341015
    10351016    // do not allow users to create a blog that conflicts with a page on the main blog.
    1036     if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) ) {
     1017    if ( !is_subdomain_install() && $wpdb->get_var( $wpdb->prepare( "SELECT post_name FROM " . $wpdb->get_blog_prefix( $current_site->blog_id ) . "posts WHERE post_type = 'page' AND post_name = %s", $blogname ) ) )
    10371018        $errors->add( 'blogname', __( "Sorry, you may not use that blog name" ) );
    1038     }
    10391019
    10401020    // all numeric?
     
    10491029
    10501030    if ( empty( $blog_title ) )
    1051         $errors->add('blog_title', __("Please enter a blog title"));
     1031        $errors->add('blog_title', __("Please enter a blog title"));
    10521032
    10531033    // Check if the domain/path has been used already.
    1054     if( is_subdomain_install() ) {
     1034    if ( is_subdomain_install() ) {
    10551035        $mydomain = "$blogname.$domain";
    10561036        $path = $base;
     
    10721052        $diff = current_time( 'timestamp', true ) - mysql2date('U', $signup->registered);
    10731053        // If registered more than two days ago, cancel registration and let this signup go through.
    1074         if ( $diff > 172800 ) {
     1054        if ( $diff > 172800 )
    10751055            $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->signups WHERE domain = %s AND path = %s", $mydomain, $path) );
    1076         } else {
     1056        else
    10771057            $errors->add('blogname', __("That blog is currently reserved but may be available in a couple days."));
    1078         }
    10791058    }
    10801059
     
    11351114    global $current_site;
    11361115
    1137     if( !apply_filters('wpmu_signup_blog_notification', $domain, $path, $title, $user, $user_email, $key, $meta) )
     1116    if ( !apply_filters('wpmu_signup_blog_notification', $domain, $path, $title, $user, $user_email, $key, $meta) )
    11381117        return false;
    11391118
    11401119    // Send email with activation link.
    1141     if( !is_subdomain_install() || $current_site->id != 1 ) {
     1120    if ( !is_subdomain_install() || $current_site->id != 1 )
    11421121        $activate_url = "http://" . $current_site->domain . $current_site->path . "wp-activate.php?key=$key";
    1143     } else {
     1122    else
    11441123        $activate_url = "http://{$domain}{$path}wp-activate.php?key=$key";
    1145     }
     1124
    11461125    $activate_url = clean_url($activate_url);
    11471126    $admin_email = get_site_option( "admin_email" );
    1148     if( $admin_email == '' )
     1127    if ( $admin_email == '' )
    11491128        $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    11501129    $from_name = get_site_option( "site_name" ) == '' ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
     
    11601139    global $current_site;
    11611140
    1162     if( !apply_filters('wpmu_signup_user_notification', $user, $user_email, $key, $meta) )
     1141    if ( !apply_filters('wpmu_signup_user_notification', $user, $user_email, $key, $meta) )
    11631142        return false;
    11641143
    11651144    // Send email with activation link.
    11661145    $admin_email = get_site_option( "admin_email" );
    1167     if( $admin_email == '' )
     1146    if ( $admin_email == '' )
    11681147        $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
    11691148    $from_name = get_site_option( "site_name" ) == '' ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
     
    12071186    if ( empty($signup->domain) ) {
    12081187        $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
     1188
    12091189        if ( isset( $user_already_exists ) )
    12101190            return new WP_Error( 'user_already_exists', __( 'That username is already activated.' ), $signup);
     1191
    12111192        wpmu_welcome_user_notification($user_id, $password, $meta);
    12121193        $user_site = get_site_option( 'dashboard_blog', $current_site->blog_id );
    1213         if ( $user_site == false ) {
     1194
     1195        if ( $user_site == false )
    12141196            add_user_to_blog( '1', $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
    1215         } else {
     1197        else
    12161198            add_user_to_blog( $user_site, $user_id, get_site_option( 'default_user_role', 'subscriber' ) );
    1217         }
     1199
    12181200        add_new_user_to_blog( $user_id, $user_email, $meta );
    12191201        do_action('wpmu_activate_user', $user_id, $password, $meta);
     
    12321214            $wpdb->update( $wpdb->signups, array( 'active' => 1, 'activated' => $now ), array( 'activation_key' => $key ) );
    12331215        }
    1234 
    12351216        return $blog_id;
    12361217    }
    12371218
    12381219    $wpdb->update( $wpdb->signups, array('active' => 1, 'activated' => $now), array('activation_key' => $key) );
    1239 
    12401220    wpmu_welcome_notification($blog_id, $user_id, $password, $signup->title, $meta);
    1241 
    12421221    do_action('wpmu_activate_blog', $blog_id, $user_id, $password, $signup->title, $meta);
    12431222
     
    12681247function wpmu_create_blog($domain, $path, $title, $user_id, $meta = '', $site_id = 1) {
    12691248    $domain = preg_replace( "/\s+/", '', sanitize_user( $domain, true ) );
    1270     if( is_subdomain_install() )
     1249
     1250    if ( is_subdomain_install() )
    12711251        $domain = str_replace( '@', '', $domain );
     1252
    12721253    $title = strip_tags( $title );
    12731254    $user_id = (int) $user_id;
    12741255
    1275     if( empty($path) )
     1256    if ( empty($path) )
    12761257        $path = '/';
    12771258
     
    12871268
    12881269    switch_to_blog($blog_id);
    1289 
    12901270    install_blog($blog_id, $title);
    1291 
    12921271    install_blog_defaults($blog_id, $user_id);
    12931272
     
    12951274
    12961275    if ( is_array($meta) ) foreach ($meta as $key => $value) {
    1297         if( $key == 'public' || $key == 'archived' || $key == 'mature' || $key == 'spam' || $key == 'deleted' || $key == 'lang_id' ) {
     1276        if ( $key == 'public' || $key == 'archived' || $key == 'mature' || $key == 'spam' || $key == 'deleted' || $key == 'lang_id' )
    12981277            update_blog_status( $blog_id, $key, $value );
    1299         } else {
     1278        else
    13001279            update_option( $key, $value );
    1301         }
    13021280    }
    13031281
    13041282    add_option( 'WPLANG', get_site_option( 'WPLANG' ) );
    1305 
    13061283    update_option( 'blog_public', $meta['public'] );
    13071284
     
    13101287
    13111288    restore_current_blog();
    1312 
    13131289    do_action( 'wpmu_new_blog', $blog_id, $user_id );
    13141290
     
    13181294function newblog_notify_siteadmin( $blog_id, $deprecated = '' ) {
    13191295    global $current_site;
    1320     if( get_site_option( 'registrationnotification' ) != 'yes' )
     1296    if ( get_site_option( 'registrationnotification' ) != 'yes' )
    13211297        return false;
    13221298
    13231299    $email = get_site_option( 'admin_email' );
    1324     if( is_email($email) == false )
     1300    if ( is_email($email) == false )
    13251301        return false;
    13261302
     
    13451321function newuser_notify_siteadmin( $user_id ) {
    13461322    global $current_site;
    1347     if( get_site_option( 'registrationnotification' ) != 'yes' )
     1323
     1324    if ( get_site_option( 'registrationnotification' ) != 'yes' )
    13481325        return false;
    13491326
    13501327    $email = get_site_option( 'admin_email' );
    1351     if( is_email($email) == false )
     1328
     1329    if ( is_email($email) == false )
    13521330        return false;
     1331
    13531332    $user = new WP_User($user_id);
    13541333
     
    13911370    $blog_id = (int) $blog_id;
    13921371
    1393     require_once( ABSPATH . 'wp-admin/includes/upgrade.php');
     1372    require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    13941373
    13951374    if ( $wpdb->get_results("SELECT ID FROM $wpdb->posts") )
    13961375        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>');
    1397     $wpdb->suppress_errors( false);
     1376       
     1377    $wpdb->suppress_errors(false);
    13981378
    13991379    $url = get_blogaddress_by_id($blog_id);
     
    14231403
    14241404    $blogroll_id = $wpdb->get_var( $wpdb->prepare( "SELECT cat_ID FROM {$wpdb->sitecategories} WHERE category_nicename = %s", $cat_slug ) );
    1425     if( $blogroll_id == null ) {
     1405   
     1406    if ( $blogroll_id == null ) {
    14261407        $wpdb->insert( $wpdb->sitecategories, array('cat_ID' => 0, 'cat_name' => $cat_name, 'category_nicename' => $cat_slug, 'last_updated' => current_time('mysql', true)) );
    14271408        $blogroll_id = $wpdb->insert_id;
     
    14581439    $now_gmt = gmdate('Y-m-d H:i:s');
    14591440    $first_post = get_site_option( 'first_post' );
    1460     if( $first_post == false ) {
     1441
     1442    if ( $first_post == false )
    14611443        $first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
    1462     }
     1444
    14631445    $first_post = str_replace( "SITE_URL", clean_url("http://" . $current_site->domain . $current_site->path), $first_post );
    14641446    $first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
     
    15321514    global $current_site;
    15331515
    1534     if( !apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta) )
     1516    if ( !apply_filters('wpmu_welcome_notification', $blog_id, $user_id, $password, $title, $meta) )
    15351517        return false;
    15361518
    15371519    $welcome_email = stripslashes( get_site_option( 'welcome_email' ) );
    1538     if( $welcome_email == false )
     1520    if ( $welcome_email == false )
    15391521        $welcome_email = stripslashes( __( "Dear User,
    15401522
     
    15641546    $welcome_email = apply_filters( "update_welcome_email", $welcome_email, $blog_id, $user_id, $password, $title, $meta);
    15651547    $admin_email = get_site_option( "admin_email" );
    1566     if( $admin_email == '' )
     1548
     1549    if ( $admin_email == '' )
    15671550        $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
     1551
    15681552    $from_name = get_site_option( "site_name" ) == '' ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
    15691553    $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    15701554    $message = $welcome_email;
    1571     if( empty( $current_site->site_name ) )
     1555
     1556    if ( empty( $current_site->site_name ) )
    15721557        $current_site->site_name = "WordPress MU";
     1558
    15731559    $subject = apply_filters( 'update_welcome_subject', sprintf(__('New %1$s Blog: %2$s'), $current_site->site_name, stripslashes( $title ) ) );
    15741560    wp_mail($user->user_email, $subject, $message, $message_headers);
     
    15791565    global $current_site;
    15801566
    1581     if( !apply_filters('wpmu_welcome_user_notification', $user_id, $password, $meta) )
     1567    if ( !apply_filters('wpmu_welcome_user_notification', $user_id, $password, $meta) )
    15821568        return false;
    15831569
     
    15931579
    15941580    $admin_email = get_site_option( "admin_email" );
    1595     if( $admin_email == '' )
     1581
     1582    if ( $admin_email == '' )
    15961583        $admin_email = 'support@' . $_SERVER['SERVER_NAME'];
     1584
    15971585    $from_name = get_site_option( "site_name" ) == '' ? 'WordPress' : wp_specialchars( get_site_option( "site_name" ) );
    15981586    $message_headers = "MIME-Version: 1.0\n" . "From: \"{$from_name}\" <{$admin_email}>\n" . "Content-Type: text/plain; charset=\"" . get_option('blog_charset') . "\"\n";
    15991587    $message = $welcome_email;
    1600     if( empty( $current_site->site_name ) )
     1588
     1589    if ( empty( $current_site->site_name ) )
    16011590        $current_site->site_name = "WordPress MU";
     1591
    16021592    $subject = apply_filters( 'update_welcome_user_subject', sprintf(__('New %1$s User: %2$s'), $current_site->site_name, $user->user_login) );
    16031593    wp_mail($user->user_email, $subject, $message, $message_headers);
     
    16471637            // newer than the current recent post, make it the new
    16481638            // most recent post.
    1649             if (
    1650                 !isset($most_recent_post['post_gmt_ts'])
    1651                 || ($post_gmt_ts > $most_recent_post['post_gmt_ts'])
    1652             ) {
     1639            if ( !isset($most_recent_post['post_gmt_ts']) || ( $post_gmt_ts > $most_recent_post['post_gmt_ts'] ) ) {
    16531640                $most_recent_post = array(
    16541641                    'blog_id'       => $blog->userblog_id,
     
    16731660function get_dirsize( $directory ) {
    16741661    $dirsize = get_transient( 'dirsize_cache' );
    1675     if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) ) {
     1662    if ( is_array( $dirsize ) && isset( $dirsize[ $directory ][ 'size' ] ) )
    16761663        return $dirsize[ $directory ][ 'size' ];
    1677     }
    1678     if ( false == is_array( $dirsize ) ) {
     1664
     1665    if ( false == is_array( $dirsize ) )
    16791666        $dirsize = array();
    1680     }
     1667
    16811668    $dirsize[ $directory ][ 'size' ] = recurse_dirsize( $directory );
    16821669
     
    16941681function recurse_dirsize( $directory ) {
    16951682    $size = 0;
    1696     if(substr($directory,-1) == '/') $directory = substr($directory,0,-1);
    1697     if(!file_exists($directory) || !is_dir($directory) || !is_readable($directory)) return false;
    1698     if($handle = opendir($directory)) {
     1683
     1684    if ( substr( $directory, -1 ) == '/' )
     1685        $directory = substr($directory,0,-1);
     1686
     1687    if ( !file_exists($directory) || !is_dir( $directory ) || !is_readable( $directory ) )
     1688        return false;
     1689
     1690    if ($handle = opendir($directory)) {
    16991691        while(($file = readdir($handle)) !== false) {
    17001692            $path = $directory.'/'.$file;
    1701             if($file != '.' && $file != '..') {
    1702                 if(is_file($path)) {
     1693            if ($file != '.' && $file != '..') {
     1694                if (is_file($path)) {
    17031695                    $size += filesize($path);
    1704                 } elseif(is_dir($path)) {
     1696                } elseif (is_dir($path)) {
    17051697                    $handlesize = recurse_dirsize($path);
    1706                     if($handlesize >= 0) {
     1698                    if ($handlesize >= 0)
    17071699                        $size += $handlesize;
    1708                     } else {
     1700                    else
    17091701                        return false;
    1710                     }
    17111702                }
    17121703            }
     
    17181709
    17191710function upload_is_user_over_quota( $echo = true ) {
    1720     if ( get_site_option( 'upload_space_check_disabled' ) ) {
     1711    if ( get_site_option( 'upload_space_check_disabled' ) )
    17211712        return true;
    1722     }
     1713
    17231714    $spaceAllowed = get_space_allowed();
    1724     if(empty($spaceAllowed) || !is_numeric($spaceAllowed))
     1715    if ( empty( $spaceAllowed ) || !is_numeric( $spaceAllowed ) )
    17251716        $spaceAllowed = 10; // Default space allowed is 10 MB
    17261717
     
    17281719    $size = get_dirsize($dirName) / 1024 / 1024;
    17291720
    1730     if( ($spaceAllowed-$size) < 0 ) {
    1731         if( $echo )
     1721    if ( ($spaceAllowed-$size) < 0 ) {
     1722        if ( $echo )
    17321723            _e( "Sorry, you have used your space allocation. Please delete some files to upload more files." ); //No space left
    17331724        return true;
     
    17371728}
    17381729
    1739 function check_upload_mimes($mimes) {
     1730function check_upload_mimes( $mimes ) {
    17401731    $site_exts = explode( " ", get_site_option( "upload_filetypes" ) );
    17411732    foreach ( $site_exts as $ext ) {
    1742         foreach ( $mimes as $ext_pattern => $mime ) {
    1743             if( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) {
     1733        foreach ( $mimes as $ext_pattern => $mime )
     1734            if ( $ext != '' && strpos( $ext_pattern, $ext ) !== false ) {
    17441735                $site_mimes[$ext_pattern] = $mime;
    1745             }
    17461736        }
    17471737    }
     
    17611751
    17621752function fix_import_form_size( $size ) {
    1763     if( upload_is_user_over_quota( false ) == true ) {
     1753    if ( upload_is_user_over_quota( false ) == true )
    17641754        return 0;
    1765     }
    17661755
    17671756    $spaceAllowed = 1024 * 1024 * get_space_allowed();
    17681757    $dirName = BLOGUPLOADDIR;
    17691758    $dirsize = get_dirsize($dirName) ;
    1770     if( $size > $spaceAllowed - $dirsize ) {
     1759    if ( $size > $spaceAllowed - $dirsize )
    17711760        return $spaceAllowed - $dirsize; // remaining space
    1772     } else {
     1761    else
    17731762        return $size; // default
    1774     }
    17751763}
    17761764
     
    18161804    function admin_footer() {
    18171805        global $wpdb, $current_blog, $current_site;
    1818         if( $current_blog->domain . $current_blog->path == $current_site->domain . $current_site->path )
     1806        if ( $current_blog->domain . $current_blog->path == $current_site->domain . $current_site->path )
    18191807            return false;
    18201808
    1821         if( $this->reallydeleteblog == true ) {
     1809        if ( $this->reallydeleteblog == true )
    18221810            wpmu_delete_blog( $wpdb->blogid );
    1823         }
    18241811    }
    18251812
    18261813    function admin_menu() {
    18271814        global $current_blog, $current_site;
    1828         if( $current_blog->domain . $current_blog->path != $current_site->domain . $current_site->path )
     1815        if ( $current_blog->domain . $current_blog->path != $current_site->domain . $current_site->path )
    18291816            add_submenu_page('options-general.php', __('Delete Blog'), __('Delete Blog'), 'manage_options', 'delete-blog', array(&$this, 'plugin_content'));
    18301817    }
     
    18341821        $this->delete_blog_hash = get_settings('delete_blog_hash');
    18351822        echo '<div class="wrap"><h2>' . __('Delete Blog') . '</h2>';
    1836         if( $_POST['action'] == "deleteblog" && $_POST['confirmdelete'] == '1' ) {
     1823        if ( $_POST['action'] == "deleteblog" && $_POST['confirmdelete'] == '1' ) {
    18371824            $hash = substr( md5( $_SERVER['REQUEST_URI'] . time() ), 0, 6 );
    18381825            update_option( "delete_blog_hash", $hash );
     
    18591846            <p><?php _e('Thank you. Please check your email for a link to confirm your action. Your blog will not be deleted until this link is clicked.') ?></p>
    18601847            <?php
    1861         } elseif( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option('delete_blog_hash') != false ) {
    1862             if( get_option('delete_blog_hash') == $_GET['h'] ) {
     1848        } elseif ( isset( $_GET['h'] ) && $_GET['h'] != '' && get_option('delete_blog_hash') != false ) {
     1849            if ( get_option('delete_blog_hash') == $_GET['h'] ) {
    18631850                $this->reallydeleteblog = true;
    18641851                echo "<p>" . sprintf(__('Thank you for using %s, your blog has been deleted. Happy trails to you until we meet again.'), $current_site->site_name) . "</p>";
     
    19001887        return $global_id;
    19011888
    1902     if( get_option( 'default_category' ) == $term_id )
     1889    if ( get_option( 'default_category' ) == $term_id )
    19031890        update_option( 'default_category', $global_id );
    19041891
     
    19181905
    19191906function upload_is_file_too_big( $upload ) {
    1920     if( is_array( $upload ) == false || defined( 'WP_IMPORTING' ) )
     1907    if ( is_array( $upload ) == false || defined( 'WP_IMPORTING' ) )
    19211908        return $upload;
    1922     if( strlen( $upload[ 'bits' ] )  > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) ) {
     1909
     1910    if ( strlen( $upload[ 'bits' ] )  > ( 1024 * get_site_option( 'fileupload_maxk', 1500 ) ) )
    19231911        return sprintf(__( "This file is too big. Files must be less than %dKb in size.<br />" ), get_site_option( 'fileupload_maxk', 1500 ));
    1924     }
    19251912
    19261913    return $upload;
     
    19281915
    19291916function wordpressmu_authenticate_siteadmin( $user, $password = '' ) {
    1930     if( is_super_admin( $user->user_login ) == false && ( $primary_blog = get_usermeta( $user->user_id, "primary_blog" ) ) ) {
     1917    if ( is_super_admin( $user->user_login ) == false && ( $primary_blog = get_usermeta( $user->user_id, "primary_blog" ) ) ) {
    19311918        $details = get_blog_details( $primary_blog );
    1932         if( is_object( $details ) && $details->spam == 1 ) {
     1919        if ( is_object( $details ) && $details->spam == 1 )
    19331920            return new WP_Error('blog_suspended', __('Blog Suspended.'));
    1934         }
    19351921    }
    19361922    return $user;
     
    19381924
    19391925function wordpressmu_wp_mail_from( $email ) {
    1940     if( strpos( $email, 'wordpress@' ) !== false )
     1926    if ( strpos( $email, 'wordpress@' ) !== false )
    19411927        $email = get_option( 'admin_email' );
    19421928    return $email;
     
    19471933http://trac.mu.wordpress.org/attachment/ticket/551/xmlrpc-mu.php
    19481934*/
    1949 function wpmu_blogger_getUsersBlogs($args) {
     1935function wpmu_blogger_getUsersBlogs( $args ) {
    19501936    global $current_blog;
    19511937    $domain = $current_blog->domain;
     
    19561942    $blogs = $rpc->getResponse();
    19571943
    1958     if ( isset($blogs['faultCode']) ) {
     1944    if ( isset($blogs['faultCode']) )
    19591945        return new IXR_Error($blogs['faultCode'], $blogs['faultString']);
    1960     }
    19611946
    19621947    if ( $_SERVER['HTTP_HOST'] == $domain && $_SERVER['REQUEST_URI'] == $path ) {
     
    19711956}
    19721957
    1973 function attach_wpmu_xmlrpc($methods) {
     1958function attach_wpmu_xmlrpc( $methods ) {
    19741959    $methods['blogger.getUsersBlogs'] = 'wpmu_blogger_getUsersBlogs';
    19751960    return $methods;
     
    19771962
    19781963function mu_locale( $locale ) {
    1979     if( defined('WP_INSTALLING') == false ) {
     1964    if ( defined('WP_INSTALLING') == false ) {
    19801965        $mu_locale = get_option('WPLANG');
    1981         if( $mu_locale === false )
     1966        if ( $mu_locale === false )
    19821967            $mu_locale = get_site_option('WPLANG');
    19831968
    1984         if( $mu_locale !== false )
     1969        if ( $mu_locale !== false )
    19851970            return $mu_locale;
    19861971    }
     
    19951980
    19961981function signup_nonce_check( $result ) {
    1997     if( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )
     1982    if ( !strpos( $_SERVER[ 'PHP_SELF' ], 'wp-signup.php' ) )
    19981983        return $result;
    19991984
     
    20061991function maybe_redirect_404() {
    20071992    global $current_site;
    2008     if( is_main_blog() && is_404() && defined( 'NOBLOGREDIRECT' ) && constant( 'NOBLOGREDIRECT' ) != '' ) {
     1993    if ( is_main_blog() && is_404() && defined( 'NOBLOGREDIRECT' ) && constant( 'NOBLOGREDIRECT' ) != '' ) {
    20091994        $destination = constant( 'NOBLOGREDIRECT' );
    20101995        if ( $destination == '%siteurl%' )
     
    20212006
    20222007function maybe_add_existing_user_to_blog() {
    2023     if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) ) {
     2008    if ( false === strpos( $_SERVER[ 'REQUEST_URI' ], '/newbloguser/' ) )
    20242009        return false;
    2025     }
    20262010
    20272011    $parts = explode( '/', $_SERVER[ 'REQUEST_URI' ] );
    20282012    $key = array_pop( $parts );
     2013
    20292014    if ( $key == '' )
    20302015        $key = array_pop( $parts );
     2016
    20312017    $details = get_option( "new_user_" . $key );
    20322018    add_existing_user_to_blog( $details );
     
    20442030function add_new_user_to_blog( $user_id, $email, $meta ) {
    20452031    global $current_site;
    2046     if( $meta[ 'add_to_blog' ] ) {
     2032    if ( $meta[ 'add_to_blog' ] ) {
    20472033        $blog_id = $meta[ 'add_to_blog' ];
    20482034        $role = $meta[ 'new_role' ];
     
    20592045
    20602046function is_user_spammy( $username = 0 ) {
    2061     if( $username == 0 ) {
     2047    if ( $username == 0 ) {
    20622048        global $current_user;
    20632049        $user_id = $current_user->ID;
     
    20662052    }
    20672053    $u = new WP_User( $user_id );
    2068     if( $u->spam == 1 )
     2054
     2055    if ( $u->spam == 1 )
    20692056        return true;
     2057
    20702058    return false;
    20712059}
    20722060
    20732061function login_spam_check( $user, $password ) {
    2074     if( is_user_spammy( $user->ID ) )
     2062    if ( is_user_spammy( $user->ID ) )
    20752063        return new WP_Error('invalid_username', __('<strong>ERROR</strong>: your account has been marked as a spammer.'));
    20762064    return $user;
     
    21052093    global $current_site;
    21062094
    2107     if ( get_site_option( 'dashboard_blog' ) == false ) {
     2095    if ( get_site_option( 'dashboard_blog' ) == false )
    21082096        return get_blog_details( $current_site->blog_id );
    2109     } else {
     2097    else
    21102098        return get_blog_details( get_site_option( 'dashboard_blog' ) );
    2111     }
    21122099}
    21132100
     
    21152102    global $current_user, $wpdb;
    21162103
    2117     if( $user_id == 0 )
     2104    if ( $user_id == 0 )
    21182105        $user_id = $current_user->ID;
    2119     if( $blog_id == 0 )
     2106    if ( $blog_id == 0 )
    21202107        $blog_id = $wpdb->blogid;
    21212108
    21222109    $local_key = $wpdb->base_prefix . $blog_id . "_" . $key;
    2123     if( isset( $current_user->$local_key ) )
     2110
     2111    if ( isset( $current_user->$local_key ) )
    21242112        return true;
     2113
    21252114    return false;
    21262115}
    21272116
    21282117function fix_active_plugins( $value ) {
    2129     if( false == is_array( $value ) )
     2118    if ( false == is_array( $value ) )
    21302119        $value = array();
    21312120    return $value;
     
    21382127    // Garbage Collection
    21392128    $rows = $wpdb->get_results( "SELECT meta_key FROM {$wpdb->sitemeta} WHERE meta_key LIKE 'rss\_%\_ts' AND meta_value < unix_timestamp( date_sub( NOW(), interval 7200 second ) )" );
    2140     if( is_array( $rows ) ) {
     2129    if ( is_array( $rows ) ) {
    21412130        foreach( $rows as $row ) {
    21422131            $wpdb->query( $wpdb->prepare( "DELETE FROM {$wpdb->sitemeta} WHERE meta_key = %s", $row->meta_key ) );
     
    21672156function mu_upload_dir( $uploads ) {
    21682157    $dir = $uploads[ 'basedir' ];
    2169     if( defined( 'BLOGUPLOADDIR' ) )
     2158    if ( defined( 'BLOGUPLOADDIR' ) )
    21702159        $dir = constant( 'BLOGUPLOADDIR' );
    21712160    $dir = untrailingslashit( $dir ) . $uploads[ 'subdir' ];
     
    21782167function users_can_register_signup_filter() {
    21792168    $registration = get_site_option('registration');
    2180     if ( $registration == 'all' || $registration == 'user' ) {
     2169    if ( $registration == 'all' || $registration == 'user' )
    21812170        return true;
    2182     } else {
     2171    else
    21832172        return false;
    2184     }
    21852173}
    21862174add_filter('option_users_can_register', 'users_can_register_signup_filter');
     
    22062194
    22072195function first_page_filter( $text ) {
    2208     if ( !$text ) {
     2196    if ( !$text )
    22092197        return __( "This is an example of a WordPress page, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many pages like this one or sub-pages as you like and manage all of your content inside of WordPress." );
    2210     }
     2198
    22112199    return $text;
    22122200}
     
    22142202
    22152203function first_comment_filter( $text ) {
    2216     if ( !$text ) {
     2204    if ( !$text )
    22172205        return __( "This is an example of a WordPress comment, you could edit this to put information about yourself or your site so readers know where you are coming from. You can create as many comments like this one or sub-comments as you like and manage all of your content inside of WordPress." );
    2218     }
     2206
    22192207    return $text;
    22202208}
     
    22222210
    22232211function first_comment_author_filter( $text ) {
    2224     if ( !$text ) {
     2212    if ( !$text )
    22252213        return __( "Mr WordPress" );
    2226     }
     2214
    22272215    return $text;
    22282216}
     
    22312219function first_comment_url_filter( $text ) {
    22322220    global $current_site;
    2233     if ( !$text ) {
     2221    if ( !$text )
    22342222        return 'http://' . $current_site->domain . $current_site->path;
    2235     }
     2223
    22362224    return $text;
    22372225}
     
    22592247 */
    22602248function force_ssl_content( $force = '' ) {
    2261         static $forced_content;
    2262 
    2263         if ( '' != $force ) {
    2264                 $old_forced = $forced_content;
    2265                 $forced_content = $force;
    2266                 return $old_forced;
    2267         }
    2268         return $forced_content;
     2249    static $forced_content;
     2250
     2251    if ( '' != $force ) {
     2252        $old_forced = $forced_content;
     2253        $forced_content = $force;
     2254        return $old_forced;
     2255    }
     2256
     2257    return $forced_content;
    22692258}
    22702259
     
    22762265 **/
    22772266function filter_SSL( $url) {
    2278     if ( !is_string( $url ) ) {
     2267    if ( !is_string( $url ) )
    22792268        return get_bloginfo( 'url' ); //return home blog url with proper scheme
    2280     }
    22812269
    22822270    $arrURL = parse_url( $url );
    22832271
    22842272    if ( force_ssl_content() && is_ssl() ) {
    2285         if ( 'http' === $arrURL['scheme'] && 'https' !== $arrURL['scheme'] ) {
     2273        if ( 'http' === $arrURL['scheme'] && 'https' !== $arrURL['scheme'] )
    22862274            $url = str_replace( $arrURL['scheme'], 'https', $url );
    2287         }
    22882275    }
    22892276
     
    22922279
    22932280function maybe_cancel_post_by_email() {
    2294     if ( !defined( 'POST_BY_EMAIL' ) || !POST_BY_EMAIL ) {
     2281    if ( !defined( 'POST_BY_EMAIL' ) || !POST_BY_EMAIL )
    22952282        die( __( 'This action has been disabled by the administrator' ) );
    2296     }
    22972283}
    22982284add_action( 'wp-mail.php', 'maybe_cancel_post_by_email' );
Note: See TracChangeset for help on using the changeset viewer.