Make WordPress Core


Ignore:
Timestamp:
01/20/2010 08:09:41 PM (17 years ago)
Author:
ryan
Message:

Deprecate wp_install_blog_defaults(). Use wp_install_defaults() instead. fixes #11747 see #11644

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/upgrade.php

    r12756 r12776  
    9797 */
    9898function wp_install_defaults($user_id) {
    99         global $wpdb;
     99        global $wpdb, $wp_rewrite, $current_site, $table_prefix;
    100100
    101101        // Default category
    … …  
    162162        $first_post_guid = get_option('home') . '/?p=1';
    163163
     164        if ( is_multisite() ) {
     165                $first_post = get_site_option( 'first_post' );
     166
     167                if ( empty($first_post) )
     168                        $first_post = stripslashes( __( 'Welcome to <a href="SITE_URL">SITE_NAME</a>. This is your first post. Edit or delete it, then start blogging!' ) );
     169
     170                $first_post = str_replace( "SITE_URL", clean_url("http://" . $current_site->domain . $current_site->path), $first_post );
     171                $first_post = str_replace( "SITE_NAME", $current_site->site_name, $first_post );
     172        } else {
     173                $first_post = __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!');
     174        }
     175
    164176        $wpdb->insert( $wpdb->posts, array(
    165177                                                                'post_author' => $user_id,
    166178                                                                'post_date' => $now,
    167179                                                                'post_date_gmt' => $now_gmt,
    168                                                                 'post_content' => __('Welcome to WordPress. This is your first post. Edit or delete it, then start blogging!'),
     180                                                                'post_content' => $first_post,
    169181                                                                'post_excerpt' => '',
    170182                                                                'post_title' => __('Hello world!'),
    … …  
    182194
    183195        // Default comment
     196        if ( is_multisite() ) {
     197                $first_comment_author = get_site_option( 'first_comment_author' );
     198                $first_comment_url = get_site_option( 'first_comment_url' );
     199                $first_comment = get_site_option( 'first_comment' );
     200        } else {
     201                $first_comment_author = __('Mr WordPress');
     202                $first_comment_url = 'http://wordpress.org/';
     203                $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.');
     204        }       
    184205        $wpdb->insert( $wpdb->comments, array(
    185206                                                                'comment_post_ID' => 1,
    186                                                                 'comment_author' => __('Mr WordPress'),
     207                                                                'comment_author' => $first_comment_author,
    187208                                                                'comment_author_email' => '',
    188209                                                                'comment_author_url' => 'http://wordpress.org/',
    189210                                                                'comment_date' => $now,
    190211                                                                'comment_date_gmt' => $now_gmt,
    191                                                                 '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.')
     212                                                                'comment_content' => $first_comment
    192213                                                                ));
     214
    193215        // First Page
     216        if ( is_multisite() && get_site_option( 'first_page' ) )
     217                $first_page = get_site_option( 'first_page' );
     218        else
     219                $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.');
    194220        $first_post_guid = get_option('home') . '/?page_id=2';
    195221        $wpdb->insert( $wpdb->posts, array(
    … …  
    197223                                                                'post_date' => $now,
    198224                                                                'post_date_gmt' => $now_gmt,
    199                                                                 '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.'),
     225                                                                'post_content' => $first_page,
    200226                                                                'post_excerpt' => '',
    201227                                                                'post_title' => __('About'),
    … …  
    210236                                                                'post_content_filtered' => ''
    211237                                                                ));
     238
     239        if ( is_multisite() ) {
     240                // Flush rules to pick up the new page.
     241                $wp_rewrite->init();
     242                $wp_rewrite->flush_rules();
     243
     244                $user = new WP_User($user_id);
     245                $wpdb->update( $wpdb->options, array('option_value' => $user->user_email), array('option_name' => 'admin_email') );
     246
     247                // Remove all perms except for the login user.
     248                $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'user_level') );
     249                $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id != %d AND meta_key = %s", $user_id, $table_prefix.'capabilities') );
     250
     251                // Delete any caps that snuck into the previously active blog. (Hardcoded to blog 1 for now.) TODO: Get previous_blog_id.
     252                if ( !is_super_admin( $user_id ) && $user_id != 1 )
     253                        $wpdb->query( $wpdb->prepare("DELETE FROM $wpdb->usermeta WHERE user_id = %d AND meta_key = %s", $user_id, $wpdb->base_prefix.'1_capabilities') );
     254        }
    212255}
    213256endif;
Note: See TracChangeset for help on using the changeset viewer.