<!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 &lt;a href=&quot;SITE_URL&quot;&gt;SITE_NAME&lt;/a&gt;. This is your first post. Edit or delete it, then start blogging!' ) );
+
+                $first_post = str_replace( &quot;SITE_URL&quot;, clean_url(&quot;http://&quot; . $current_site-&gt;domain . $current_site-&gt;path), $first_post );
+                $first_post = str_replace( &quot;SITE_NAME&quot;, $current_site-&gt;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-&gt;insert( $wpdb-&gt;posts, array(
</span><span class="cx">                                                                 'post_author' =&gt; $user_id,
</span><span class="cx">                                                                 'post_date' =&gt; $now,
</span><span class="cx">                                                                 'post_date_gmt' =&gt; $now_gmt,
</span><del>-                                                                'post_content' =&gt; __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'),
</del><ins>+                                                                'post_content' =&gt; $first_post,
</ins><span class="cx">                                                                 'post_excerpt' =&gt; '',
</span><span class="cx">                                                                 'post_title' =&gt; __('Hello world!'),
</span><span class="cx">                                                                 /* translators: Default post slug */
</span><span class="lines">@@ -181,22 +193,36 @@
</span><span class="cx">         $wpdb-&gt;insert( $wpdb-&gt;term_relationships, array('term_taxonomy_id' =&gt; 1, 'object_id' =&gt; 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.&lt;br /&gt;To delete a comment, just log in and view the post&amp;#039;s comments. There you will have the option to edit or delete them.');
+        }        
</ins><span class="cx">         $wpdb-&gt;insert( $wpdb-&gt;comments, array(
</span><span class="cx">                                                                 'comment_post_ID' =&gt; 1,
</span><del>-                                                                'comment_author' =&gt; __('Mr WordPress'),
</del><ins>+                                                                'comment_author' =&gt; $first_comment_author,
</ins><span class="cx">                                                                 'comment_author_email' =&gt; '',
</span><span class="cx">                                                                 'comment_author_url' =&gt; 'http://wordpress.org/',
</span><span class="cx">                                                                 'comment_date' =&gt; $now,
</span><span class="cx">                                                                 'comment_date_gmt' =&gt; $now_gmt,
</span><del>-                                                                'comment_content' =&gt; __('Hi, this is a comment.&lt;br /&gt;To delete a comment, just log in and view the post&amp;#039;s comments. There you will have the option to edit or delete them.')
</del><ins>+                                                                'comment_content' =&gt; $first_comment
</ins><span class="cx">                                                                 ));
</span><ins>+
</ins><span class="cx">         // First Page
</span><ins>+        if ( is_multisite() &amp;&amp; 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-&gt;insert( $wpdb-&gt;posts, array(
</span><span class="cx">                                                                 'post_author' =&gt; $user_id,
</span><span class="cx">                                                                 'post_date' =&gt; $now,
</span><span class="cx">                                                                 'post_date_gmt' =&gt; $now_gmt,
</span><del>-                                                                'post_content' =&gt; __('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' =&gt; $first_page,
</ins><span class="cx">                                                                 'post_excerpt' =&gt; '',
</span><span class="cx">                                                                 'post_title' =&gt; __('About'),
</span><span class="cx">                                                                 /* translators: Default page slug */
</span><span class="lines">@@ -209,6 +235,23 @@
</span><span class="cx">                                                                 'pinged' =&gt; '',
</span><span class="cx">                                                                 'post_content_filtered' =&gt; ''
</span><span class="cx">                                                                 ));
</span><ins>+
+        if ( is_multisite() ) {
+                // Flush rules to pick up the new page.
+                $wp_rewrite-&gt;init();
+                $wp_rewrite-&gt;flush_rules();
+
+                $user = new WP_User($user_id);
+                $wpdb-&gt;update( $wpdb-&gt;options, array('option_value' =&gt; $user-&gt;user_email), array('option_name' =&gt; 'admin_email') );
+
+                // Remove all perms except for the login user.
+                $wpdb-&gt;query( $wpdb-&gt;prepare(&quot;DELETE FROM $wpdb-&gt;usermeta WHERE user_id != %d AND meta_key = %s&quot;, $user_id, $table_prefix.'user_level') );
+                $wpdb-&gt;query( $wpdb-&gt;prepare(&quot;DELETE FROM $wpdb-&gt;usermeta WHERE user_id != %d AND meta_key = %s&quot;, $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 ) &amp;&amp; $user_id != 1 )
+                        $wpdb-&gt;query( $wpdb-&gt;prepare(&quot;DELETE FROM $wpdb-&gt;usermeta WHERE user_id = %d AND meta_key = %s&quot;, $user_id, $wpdb-&gt;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-&gt;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-&gt;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-&gt;insert( $wpdb-&gt;links, array( 'link_url' =&gt; 'http://wordpress.com/', 'link_name' =&gt; 'WordPress.com', 'link_owner' =&gt; $user_id, 'link_rss' =&gt; 'http://en.blog.wordpress.com/feed/', 'link_notes' =&gt; '' ) );
-        $wpdb-&gt;insert( $wpdb-&gt;links, array( 'link_url' =&gt; 'http://wordpress.org/', 'link_name' =&gt; 'WordPress.org', 'link_owner' =&gt; $user_id, 'link_rss' =&gt; 'http://wordpress.org/development/feed/', 'link_notes' =&gt; '' ) );
-        $wpdb-&gt;insert( $wpdb-&gt;term_relationships, array('object_id' =&gt; 1, 'term_taxonomy_id' =&gt; 2));
-        $wpdb-&gt;insert( $wpdb-&gt;term_relationships, array('object_id' =&gt; 2, 'term_taxonomy_id' =&gt; 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 &lt;a href=&quot;SITE_URL&quot;&gt;SITE_NAME&lt;/a&gt;. This is your first post. Edit or delete it, then start blogging!' ) );
-
-        $first_post = str_replace( &quot;SITE_URL&quot;, clean_url(&quot;http://&quot; . $current_site-&gt;domain . $current_site-&gt;path), $first_post );
-        $first_post = str_replace( &quot;SITE_NAME&quot;, $current_site-&gt;site_name, $first_post );
-        $wpdb-&gt;insert( $wpdb-&gt;posts, array(
-                'post_author' =&gt; $user_id,
-                'post_date' =&gt; $now,
-                'post_date_gmt' =&gt; $now_gmt,
-                'post_content' =&gt; stripslashes( $first_post ),
-                'post_excerpt' =&gt; '',
-                'post_title' =&gt; __('Hello world!'),
-                'post_name' =&gt; __('hello-world'),
-                'post_modified' =&gt; $now,
-                'post_modified_gmt' =&gt; $now_gmt,
-                'comment_count' =&gt; 1,
-                'to_ping' =&gt; '',
-                'pinged' =&gt; '',
-                'post_content_filtered' =&gt; ''
-        ) );
-        $wpdb-&gt;insert( $wpdb-&gt;term_relationships, array('object_id' =&gt; 1, 'term_taxonomy_id' =&gt; 1));
-        update_option( &quot;post_count&quot;, 1 );
-
-        // First page
-        $wpdb-&gt;insert( $wpdb-&gt;posts, array(
-                'post_author' =&gt; $user_id,
-                'post_date' =&gt; $now,
-                'post_date_gmt' =&gt; $now_gmt,
-                'post_content' =&gt; get_site_option( 'first_page' ),
-                'post_excerpt' =&gt; '',
-                'post_title' =&gt; __('About'),
-                'post_name' =&gt; __('about'),
-                'post_modified' =&gt; $now,
-                'post_modified_gmt' =&gt; $now_gmt,
-                'post_status' =&gt; 'publish',
-                'post_type' =&gt; 'page',
-                'to_ping' =&gt; '',
-                'pinged' =&gt; '',
-                'post_content_filtered' =&gt; ''
-        ) );
-
-        // Flush rules to pick up the new page.
-        $wp_rewrite-&gt;init();
-        $wp_rewrite-&gt;flush_rules();
-
-        // Default comment
-        $wpdb-&gt;insert( $wpdb-&gt;comments, array(
-                'comment_post_ID' =&gt; '1',
-                'comment_author' =&gt; __( get_site_option( 'first_comment_author' ) ),
-                'comment_author_email' =&gt; '',
-                'comment_author_url' =&gt; get_site_option( 'first_comment_url' ),
-                'comment_author_IP' =&gt; '127.0.0.1',
-                'comment_date' =&gt; $now,
-                'comment_date_gmt' =&gt; $now_gmt,
-                'comment_content' =&gt; __( get_site_option( 'first_comment' ) )
-        ) );
-
-        $user = new WP_User($user_id);
-        $wpdb-&gt;update( $wpdb-&gt;options, array('option_value' =&gt; $user-&gt;user_email), array('option_name' =&gt; 'admin_email') );
-
-        // Remove all perms except for the login user.
-        $wpdb-&gt;query( $wpdb-&gt;prepare(&quot;DELETE FROM $wpdb-&gt;usermeta WHERE user_id != %d AND meta_key = %s&quot;, $user_id, $table_prefix.'user_level') );
-        $wpdb-&gt;query( $wpdb-&gt;prepare(&quot;DELETE FROM $wpdb-&gt;usermeta WHERE user_id != %d AND meta_key = %s&quot;, $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-&gt;user_login ) &amp;&amp; $user_id != 1 )
-                $wpdb-&gt;query( $wpdb-&gt;prepare(&quot;DELETE FROM $wpdb-&gt;usermeta WHERE user_id = %d AND meta_key = %s&quot;, $user_id, $wpdb-&gt;base_prefix.'1_capabilities') );
-
</del><span class="cx">         $wpdb-&gt;suppress_errors( false );
</span><span class="cx"> }
</span><span class="cx"> 
</span></span></pre>
</div>
</div>

</body>
</html>