Make WordPress Core

Ticket #11816: 11816.diff

File 11816.diff, 11.7 KB (added by nacin, 15 years ago)

Improvements to queries in populate_network(), also gettext. Matches up / fixes a string in ms-functions.php

  • wp-admin/includes/schema.php

     
    630630                die( 'You must provide a site name!' );
    631631
    632632        // check for network collision
    633         $existing_network = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM {$wpdb->site} WHERE id = %d", $network_id ) );
     633        $existing_network = $wpdb->get_var( $wpdb->prepare( "SELECT id FROM $wpdb->site WHERE id = %d", $network_id ) );
    634634        if ( $existing_network == $network_id )
    635635                die( 'That network already exists!' );
    636636
     
    645645        else
    646646                $allowed_themes = array( $stylesheet => true );
    647647
    648         if ( $network_id == 1 )
    649                 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->site." ( id, domain, path ) VALUES ( NULL, %s, %s )", $domain, $path ) );
    650         else
    651                 $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->site." ( id, domain, path ) VALUES ( %d, %s, %s )", $network_id, $domain, $path ) );
     648        if ( 1 == $network_id ) {
     649                $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path ) );
     650                $network_id = $wpdb->insert_id;
     651        } else {
     652                $wpdb->insert( $wpdb->site, array( 'domain' => $domain, 'path' => $path, 'network_id' => $network_id ) );
     653        }
    652654
    653         $network_id = $wpdb->insert_id;
     655        if ( !is_multisite() ) {
    654656
    655         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'site_name', %s)", $network_id, $site_name ) );
    656         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'admin_email', %s)", $network_id, $site_user->user_email ) );
    657         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'admin_user_id', %d)", $network_id, $site_user->ID ) );
    658         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'registration', 'none')", $network_id ) );
    659         if ( !is_multisite() ) {
    660                 $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (1, 'Uncategorized', 'uncategorized', NOW())" );
    661                 $wpdb->query( "INSERT INTO " . $wpdb->sitecategories . " ( cat_ID, cat_name, category_nicename, last_updated ) VALUES (2, 'Blogroll', 'blogroll', NOW())" );
    662         }
    663         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'upload_filetypes', 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf' )", $network_id ) );
    664         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'blog_upload_space', '10' )", $network_id ) );
    665         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'fileupload_maxk', '1500' )", $network_id ) );
    666         if ( !is_multisite() ) {
     657                /* translators: Default category slug */
     658                $cat_slug = sanitize_title( _x( 'Uncategorized', 'Default category slug' ) );
     659
     660                $wpdb->insert( $wpdb->sitecategories, array( 'site_id' => $network_id, 'cat_ID' => 1, 'cat_name' => __('Uncategorized'), 'category_nicename' => $cat_slug, 'last_updated' => current_time( 'mysql', true ) ) );
     661
     662                /* translators: Default link category slug */
     663                $cat_slug = sanitize_title( _x( 'Blogroll', 'Default link category slug' ) );
     664
     665                $wpdb->insert( $wpdb->sitecategories, array( 'site_id' => $network_id, 'cat_ID' => 2, 'cat_name' => __('Blogroll'), 'category_nicename' => $cat_slug, 'last_updated' => current_time( 'mysql', true ) ) );
     666
    667667                $site_admins = array( $site_user->user_login );
    668668                $users = get_users_of_blog();
    669669                if ( $users ) {
     
    675675        } else {
    676676                $site_admins = get_site_option( 'site_admins' );
    677677        }
    678         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'site_admins', '" . serialize( $site_admins ) . "' )", $network_id ) );
    679         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'allowedthemes', '" . serialize( $allowed_themes ) . "' )", $network_id ) );
    680         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'illegal_names', '" . serialize( array(  "www", "web", "root", "admin", "main", "invite", "administrator" ) ) . "' )", $network_id ) );
    681         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'wpmu_upgrade_site', '{$wp_db_version}')", $network_id ) );
    682         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'welcome_email', 'Dear User,
    683678
     679        $welcome_email = __( 'Dear User,
     680
    684681Your new SITE_NAME blog has been successfully set up at:
    685682BLOG_URL
    686683
     
    692689We hope you enjoy your new blog.
    693690Thanks!
    694691
    695 --The Team @ SITE_NAME')", $network_id ) );
    696         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'first_post', 'Welcome to <a href=\"SITE_URL\">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' )", $network_id ) );
    697         //@todo - network admins should have a method of editing the network siteurl (used for cookie hash)
    698         $wpdb->query( $wpdb->prepare( "INSERT INTO ".$wpdb->sitemeta." (meta_id, site_id, meta_key, meta_value) VALUES (NULL, %d, 'siteurl', %s)", $network_id, get_option( 'siteurl' ) ) );
     692--The Team @ SITE_NAME' );
    699693
     694        $sitemeta = array(
     695                'site_name' => $site_name,
     696                'admin_email' => $site_user->user_email,
     697                'admin_user_id' => $site_user->ID,
     698                'registration' => 'none',
     699                'upload_filetypes' => 'jpg jpeg png gif mp3 mov avi wmv midi mid pdf',
     700                'blog_upload_space' => 10,
     701                'fileupload_maxk' => 1500,
     702                'site_admins' => $site_admins,
     703                'allowedthemes' => $allowed_themes,
     704                'illegal_names' => array( 'www', 'web', 'root', 'admin', 'main', 'invite', 'administrator' ),
     705                'wpmu_upgrade_site' => $wp_db_version,
     706                'welcome_email' => $welcome_email,
     707                'first_post' => __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ),
     708                // @todo - network admins should have a method of editing the network siteurl (used for cookie hash)
     709                'siteurl' => get_option( 'siteurl' )
     710        );
     711
     712        $insert = '';
     713        foreach ( $sitemeta as $meta_key => $meta_value ) {
     714                $meta_key = $wpdb->escape( $meta_key );
     715                if ( is_array( $meta_value ) )
     716                        $meta_value = serialize( $meta_value );
     717                $meta_value = $wpdb->escape( $meta_value );
     718                if ( !empty( $insert ) )
     719                        $insert .= ', ';
     720                $insert .= "( $network_id, '$meta_key', '$meta_value')";
     721        }
     722        $wpdb->query( "INSERT INTO $wpdb->sitemeta ( site_id, meta_key, meta_value ) VALUES " . $insert );
     723
    700724        $current_site->domain = $domain;
    701725        $current_site->path = $base;
    702726        $current_site->site_name = ucfirst( $domain );
    703727
    704728        if ( !is_multisite() ) {
    705                 $wpdb->query( $wpdb->prepare( "INSERT INTO {$wpdb->blogs} (site_id, domain, path) VALUES (%s, %s, %s)", $network_id, $domain, $path ) );
     729                $wpdb->insert( $wpdb->blogs, array( 'site_id' => $network_id, 'domain' => $domain, 'path' => $path ) );
     730
    706731                update_usermeta( $site_user->ID, 'source_domain', $domain );
    707732                update_usermeta( $site_user->ID, 'primary_blog', 1 );
    708733        }
     
    726751                                $vhost_ok = true;
    727752                }
    728753                if ( !$vhost_ok ) {
    729                         $msg = "<h2>Warning! Wildcard DNS may not be configured correctly!</h2>";
    730                         $msg .= "<p>To use the subdomain feature of WordPress MU you must have a wildcard entry in your dns. The installer attempted to contact a random hostname ($hostname) on your domain but failed. It returned this error message:<br /> <strong>$errstr</strong></p><p>From the README.txt:</p>";
    731                         $msg .= "<p><blockquote> If you want to host blogs of the form http://blog.domain.tld/ where domain.tld is the domain name of your machine then you must add a wildcard record to your DNS records.<br />
    732 This usually means adding a '*' hostname record pointing at your webserver in your DNS configuration tool.  Matt has a more detailed <a href='http://ma.tt/2003/10/10/wildcard-dns-and-sub-domains/'>explanation</a> on his blog. If you still have problems, these <a href='http://mu.wordpress.org/forums/tags/wildcard'>forum messages</a> may help.</blockquote></p>";
    733                         $msg .= "<p>You can still use your site but any subdomain you create may not be accessible. This check is not foolproof so ignore if you know your dns is correct.</p>";
     754                        // @todo Update this to reflect the merge. Also: Multisite readme file, or remove the <blockquote> tags.
     755                        $msg = '<h2>' . esc_html__( 'Warning! Wildcard DNS may not be configured correctly!' ) . '</h2>';
     756                        $msg .= '<p>' . __( 'To use the subdomain feature of WordPress MU you must have a wildcard entry in your dns. The installer attempted to contact a random hostname ($hostname) on your domain but failed. It returned this error message:' ) . '<br />';
     757                        $msg .= '<br/><strong>' . $errstr . '</strong></p>';
     758                        $msg .= '<p>' . __( 'From the README.txt:' ) . '</p>';
     759                        $msg .= '<blockquote><p>' . __( "If you want to host blogs of the form http://blog.domain.tld/ where domain.tld is the domain name of your machine then you must add a wildcard record to your DNS records. This usually means adding a '*' hostname record pointing at your webserver in your DNS configuration tool.  Matt has a more detailed <a href='http://ma.tt/2003/10/10/wildcard-dns-and-sub-domains/'>explanation</a> on his blog. If you still have problems, these <a href='http://mu.wordpress.org/forums/tags/wildcard'>forum messages</a> may help." ) . '</p></blockquote>';
     760                        $msg .= '<p>' . __( 'You can still use your site but any subdomain you create may not be accessible. This check is not foolproof so ignore if you know your dns is correct.' ) . '</p>';
    734761                }
    735762        }
    736763        return $msg;
  • wp-includes/load.php

     
    298298        $wpdb->field_types = array( 'post_author' => '%d', 'post_parent' => '%d', 'menu_order' => '%d', 'term_id' => '%d', 'term_group' => '%d', 'term_taxonomy_id' => '%d',
    299299                'parent' => '%d', 'count' => '%d','object_id' => '%d', 'term_order' => '%d', 'ID' => '%d', 'commment_ID' => '%d', 'comment_post_ID' => '%d', 'comment_parent' => '%d',
    300300                'user_id' => '%d', 'link_id' => '%d', 'link_owner' => '%d', 'link_rating' => '%d', 'option_id' => '%d', 'blog_id' => '%d', 'meta_id' => '%d', 'post_id' => '%d',
    301                 'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d' );
     301                'user_status' => '%d', 'umeta_id' => '%d', 'comment_karma' => '%d', 'comment_count' => '%d',
     302                // multisite:
     303                'active' => '%d', 'cat_id' => '%d', 'deleted' => '%d', 'lang_id' => '%d', 'mature' => '%d', 'public' => '%d', 'site_id' => '%d', 'spam' => '%d',
     304        );
    302305
    303306        $prefix = $wpdb->set_prefix( $table_prefix );
    304307
  • wp-includes/ms-functions.php

     
    14861486
    14871487        $welcome_email = stripslashes( get_site_option( 'welcome_email' ) );
    14881488        if ( $welcome_email == false )
    1489                 $welcome_email = stripslashes( __( "Dear User,
     1489                $welcome_email = stripslashes( __( 'Dear User,
    14901490
    14911491Your new SITE_NAME blog has been successfully set up at:
    14921492BLOG_URL
     
    14961496Password: PASSWORD
    14971497Login Here: BLOG_URLwp-login.php
    14981498
    1499 We hope you enjoy your new weblog.
     1499We hope you enjoy your new blog.
    15001500Thanks!
    15011501
    1502 --The WordPress Team
    1503 SITE_NAME" ) );
     1502--The Team @ SITE_NAME' ) );
    15041503
    15051504        $url = get_blogaddress_by_id($blog_id);
    15061505        $user = new WP_User($user_id);