<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[12776] trunk: Deprecate wp_install_blog_defaults().</title>
</head>
<body>
<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.wordpress.org/changeset/12776">12776</a></dd>
<dt>Author</dt> <dd>ryan</dd>
<dt>Date</dt> <dd>2010-01-20 20:09:41 +0000 (Wed, 20 Jan 2010)</dd>
</dl>
<h3>Log Message</h3>
<pre>Deprecate wp_install_blog_defaults(). Use wp_install_defaults() instead. fixes <a href="http://trac.wordpress.org/ticket/11747">#11747</a> see <a href="http://trac.wordpress.org/ticket/11644">#11644</a></pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkwpadminincludesupgradephp">trunk/wp-admin/includes/upgrade.php</a></li>
<li><a href="#trunkwpincludesmsfunctionsphp">trunk/wp-includes/ms-functions.php</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkwpadminincludesupgradephp"></a>
<div class="modfile"><h4>Modified: trunk/wp-admin/includes/upgrade.php (12775 => 12776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-admin/includes/upgrade.php        2010-01-20 18:25:08 UTC (rev 12775)
+++ trunk/wp-admin/includes/upgrade.php        2010-01-20 20:09:41 UTC (rev 12776)
</span><span class="lines">@@ -96,7 +96,7 @@
</span><span class="cx"> * @param int $user_id User ID.
</span><span class="cx"> */
</span><span class="cx"> function wp_install_defaults($user_id) {
</span><del>-        global $wpdb;
</del><ins>+        global $wpdb, $wp_rewrite, $current_site, $table_prefix;
</ins><span class="cx">
</span><span class="cx">         // Default category
</span><span class="cx">         $cat_name = __('Uncategorized');
</span><span class="lines">@@ -161,11 +161,23 @@
</span><span class="cx">         $now_gmt = gmdate('Y-m-d H:i:s');
</span><span class="cx">         $first_post_guid = get_option('home') . '/?p=1';
</span><span class="cx">
</span><ins>+        if ( is_multisite() ) {
+                $first_post = get_site_option( 'first_post' );
+
+                if ( empty($first_post) )
+                        $first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
+
+                $first_post = str_replace( "SITE_URL", clean_url("http://" . $current_site->domain . $current_site->path), $first_post );
+                $first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
+        } else {
+                $first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
+        }
+
</ins><span class="cx">         $wpdb->insert( $wpdb->posts, array(
</span><span class="cx">                                                                 'post_author' => $user_id,
</span><span class="cx">                                                                 'post_date' => $now,
</span><span class="cx">                                                                 'post_date_gmt' => $now_gmt,
</span><del>-                                                                'post_content' => __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'),
</del><ins>+                                                                'post_content' => $first_post,
</ins><span class="cx">                                                                 'post_excerpt' => '',
</span><span class="cx">                                                                 'post_title' => __('Hello world!'),
</span><span class="cx">                                                                 /* translators: Default post slug */
</span><span class="lines">@@ -181,22 +193,36 @@
</span><span class="cx">         $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => 1, 'object_id' => 1) );
</span><span class="cx">
</span><span class="cx">         // Default comment
</span><ins>+        if ( is_multisite() ) {
+                $first_comment_author = get_site_option( 'first_comment_author' );
+                $first_comment_url = get_site_option( 'first_comment_url' );
+                $first_comment = get_site_option( 'first_comment' );
+        } else {
+                $first_comment_author = __('Mr WordPress');
+                $first_comment_url = 'http://wordpress.org/';
+                $first_comment = __('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.');
+        }        
</ins><span class="cx">         $wpdb->insert( $wpdb->comments, array(
</span><span class="cx">                                                                 'comment_post_ID' => 1,
</span><del>-                                                                'comment_author' => __('Mr WordPress'),
</del><ins>+                                                                'comment_author' => $first_comment_author,
</ins><span class="cx">                                                                 'comment_author_email' => '',
</span><span class="cx">                                                                 'comment_author_url' => 'http://wordpress.org/',
</span><span class="cx">                                                                 'comment_date' => $now,
</span><span class="cx">                                                                 'comment_date_gmt' => $now_gmt,
</span><del>-                                                                'comment_content' => __('Hi, this is a comment.<br />To delete a comment, just log in and view the post&#039;s comments. There you will have the option to edit or delete them.')
</del><ins>+                                                                'comment_content' => $first_comment
</ins><span class="cx">                                                                 ));
</span><ins>+
</ins><span class="cx">         // First Page
</span><ins>+        if ( is_multisite() && get_site_option( 'first_page' ) )
+                $first_page = get_site_option( 'first_page' );
+        else
+                $first_page = __('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.');
</ins><span class="cx">         $first_post_guid = get_option('home') . '/?page_id=2';
</span><span class="cx">         $wpdb->insert( $wpdb->posts, array(
</span><span class="cx">                                                                 'post_author' => $user_id,
</span><span class="cx">                                                                 'post_date' => $now,
</span><span class="cx">                                                                 'post_date_gmt' => $now_gmt,
</span><del>-                                                                'post_content' => __('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.'),
</del><ins>+                                                                'post_content' => $first_page,
</ins><span class="cx">                                                                 'post_excerpt' => '',
</span><span class="cx">                                                                 'post_title' => __('About'),
</span><span class="cx">                                                                 /* translators: Default page slug */
</span><span class="lines">@@ -209,6 +235,23 @@
</span><span class="cx">                                                                 'pinged' => '',
</span><span class="cx">                                                                 'post_content_filtered' => ''
</span><span class="cx">                                                                 ));
</span><ins>+
+        if ( is_multisite() ) {
+                // Flush rules to pick up the new page.
+                $wp_rewrite->init();
+                $wp_rewrite->flush_rules();
+
+                $user = new WP_User($user_id);
+                $wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') );
+
+                // Remove all perms except for the login user.
+                $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') );
+                $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
+
+                // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
+                if ( !is_super_admin( $user_id ) && $user_id != 1 )
+                        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $wpdb->base_prefix.'1_capabilities') );
+        }
</ins><span class="cx"> }
</span><span class="cx"> endif;
</span><span class="cx">
</span></span></pre></div>
<a id="trunkwpincludesmsfunctionsphp"></a>
<div class="modfile"><h4>Modified: trunk/wp-includes/ms-functions.php (12775 => 12776)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/wp-includes/ms-functions.php        2010-01-20 18:25:08 UTC (rev 12775)
+++ trunk/wp-includes/ms-functions.php        2010-01-20 20:09:41 UTC (rev 12776)
</span><span class="lines">@@ -1265,7 +1265,7 @@
</span><span class="cx">
</span><span class="cx">         switch_to_blog($blog_id);
</span><span class="cx">         install_blog($blog_id, $title);
</span><del>-        install_blog_defaults($blog_id, $user_id);
</del><ins>+        wp_install_defaults($user_id);
</ins><span class="cx">
</span><span class="cx">         add_user_to_blog($blog_id, $user_id, 'administrator');
</span><span class="cx">
</span><span class="lines">@@ -1415,95 +1415,17 @@
</span><span class="cx">         $wpdb->suppress_errors( false );
</span><span class="cx"> }
</span><span class="cx">
</span><ins>+// Deprecated, use wp_install_defaults()
</ins><span class="cx"> // should be switched already as $blog_id is ignored.
</span><span class="cx"> function install_blog_defaults($blog_id, $user_id) {
</span><del>-        global $wpdb, $wp_rewrite, $current_site, $table_prefix;
</del><ins>+        global $wpdb;
</ins><span class="cx">
</span><ins>+        require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
+
</ins><span class="cx">         $wpdb->suppress_errors();
</span><span class="cx">
</span><del>-        // Cast for security
-        $user_id = (int) $user_id;
-        $blog_id = (int) $blog_id;
</del><ins>+        wp_install_defaults($user_id);
</ins><span class="cx">
</span><del>-        // Default links
-        $wpdb->insert( $wpdb->links, array( 'link_url' => 'http://wordpress.com/', 'link_name' => 'WordPress.com', 'link_owner' => $user_id, 'link_rss' => 'http://en.blog.wordpress.com/feed/', 'link_notes' => '' ) );
-        $wpdb->insert( $wpdb->links, array( 'link_url' => 'http://wordpress.org/', 'link_name' => 'WordPress.org', 'link_owner' => $user_id, 'link_rss' => 'http://wordpress.org/development/feed/', 'link_notes' => '' ) );
-        $wpdb->insert( $wpdb->term_relationships, array('object_id' => 1, 'term_taxonomy_id' => 2));
-        $wpdb->insert( $wpdb->term_relationships, array('object_id' => 2, 'term_taxonomy_id' => 2));
-
-        // First post
-        $now = date('Y-m-d H:i:s');
-        $now_gmt = gmdate('Y-m-d H:i:s');
-        $first_post = get_site_option( 'first_post' );
-
-        if ( $first_post == false )
-                $first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
-
-        $first_post = str_replace( "SITE_URL", clean_url("http://" . $current_site->domain . $current_site->path), $first_post );
-        $first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
-        $wpdb->insert( $wpdb->posts, array(
-                'post_author' => $user_id,
-                'post_date' => $now,
-                'post_date_gmt' => $now_gmt,
-                'post_content' => stripslashes( $first_post ),
-                'post_excerpt' => '',
-                'post_title' => __('Hello world!'),
-                'post_name' => __('hello-world'),
-                'post_modified' => $now,
-                'post_modified_gmt' => $now_gmt,
-                'comment_count' => 1,
-                'to_ping' => '',
-                'pinged' => '',
-                'post_content_filtered' => ''
-        ) );
-        $wpdb->insert( $wpdb->term_relationships, array('object_id' => 1, 'term_taxonomy_id' => 1));
-        update_option( "post_count", 1 );
-
-        // First page
-        $wpdb->insert( $wpdb->posts, array(
-                'post_author' => $user_id,
-                'post_date' => $now,
-                'post_date_gmt' => $now_gmt,
-                'post_content' => get_site_option( 'first_page' ),
-                'post_excerpt' => '',
-                'post_title' => __('About'),
-                'post_name' => __('about'),
-                'post_modified' => $now,
-                'post_modified_gmt' => $now_gmt,
-                'post_status' => 'publish',
-                'post_type' => 'page',
-                'to_ping' => '',
-                'pinged' => '',
-                'post_content_filtered' => ''
-        ) );
-
-        // Flush rules to pick up the new page.
-        $wp_rewrite->init();
-        $wp_rewrite->flush_rules();
-
-        // Default comment
-        $wpdb->insert( $wpdb->comments, array(
-                'comment_post_ID' => '1',
-                'comment_author' => __( get_site_option( 'first_comment_author' ) ),
-                'comment_author_email' => '',
-                'comment_author_url' => get_site_option( 'first_comment_url' ),
-                'comment_author_IP' => '127.0.0.1',
-                'comment_date' => $now,
-                'comment_date_gmt' => $now_gmt,
-                'comment_content' => __( get_site_option( 'first_comment' ) )
-        ) );
-
-        $user = new WP_User($user_id);
-        $wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') );
-
-        // Remove all perms except for the login user.
-        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') );
-        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
-
-        // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
-        if ( !is_super_admin( $user->user_login ) && $user_id != 1 )
-                $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $wpdb->base_prefix.'1_capabilities') );
-
</del><span class="cx">         $wpdb->suppress_errors( false );
</span><span class="cx"> }
</span><span class="cx">
</span></span></pre>
</div>
</div>
</body>
</html>