WordPress.org

Make WordPress Core

Ticket #40036: 40036.patch

File 40036.patch, 4.3 KB (added by shadyvb, 3 years ago)

Update wp_install_defaults to properly add default content to first page/content if they're saved as empty values

  • wp-admin/includes/upgrade.php

     
    194194        $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) );
    195195
    196196        // Default comment
    197         $first_comment_author = __( 'A WordPress Commenter' );
    198         $first_comment_email = 'wapuu@wordpress.example';
    199         $first_comment_url = 'https://wordpress.org/';
    200         $first_comment = __( 'Hi, this is a comment.
    201 To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
    202 Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' );
    203197        if ( is_multisite() ) {
    204                 $first_comment_author = get_site_option( 'first_comment_author', $first_comment_author );
    205                 $first_comment_email = get_site_option( 'first_comment_email', $first_comment_email );
     198                $first_comment_author = get_site_option( 'first_comment_author' );
     199                $first_comment_email = get_site_option( 'first_comment_email' );
    206200                $first_comment_url = get_site_option( 'first_comment_url', network_home_url() );
    207                 $first_comment = get_site_option( 'first_comment', $first_comment );
     201                $first_comment = get_site_option( 'first_comment' );
    208202        }
     203
     204        $first_comment_author = ! empty( $first_comment_author ) ? $first_comment_author : __( 'A WordPress Commenter' );
     205        $first_comment_email = ! empty( $first_comment_email ) ? $first_comment_email : 'wapuu@wordpress.example';
     206        $first_comment_url = ! empty( $first_comment_url ) ? $first_comment_url : 'https://wordpress.org/';
     207        $first_comment = ! empty( $first_comment ) ? $first_comment :  __( 'Hi, this is a comment.
     208To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard.
     209Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' );
    209210        $wpdb->insert( $wpdb->comments, array(
    210211                'comment_post_ID' => 1,
    211212                'comment_author' => $first_comment_author,
     
    217218        ));
    218219
    219220        // First Page
    220         $first_page = sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
     221        if ( is_multisite() )
     222                $first_page = get_site_option( 'first_page' );
    221223
    222 <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>
     224        $first_page = ! empty( $first_page ) ? $first_page : sprintf( __( "This is an example page. It's different from a blog post because it will stay in one place and will show up in your site navigation (in most themes). Most people start with an About page that introduces them to potential site visitors. It might say something like this:
     225               
     226                <blockquote>Hi there! I'm a bike messenger by day, aspiring actor by night, and this is my website. I live in Los Angeles, have a great dog named Jack, and I like pi&#241;a coladas. (And gettin' caught in the rain.)</blockquote>
     227               
     228                ...or something like this:
     229               
     230                <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
     231               
     232                As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
    223233
    224 ...or something like this:
    225 
    226 <blockquote>The XYZ Doohickey Company was founded in 1971, and has been providing quality doohickeys to the public ever since. Located in Gotham City, XYZ employs over 2,000 people and does all kinds of awesome things for the Gotham community.</blockquote>
    227 
    228 As a new WordPress user, you should go to <a href=\"%s\">your dashboard</a> to delete this page and create new pages for your content. Have fun!" ), admin_url() );
    229         if ( is_multisite() )
    230                 $first_page = get_site_option( 'first_page', $first_page );
    231234        $first_post_guid = get_option('home') . '/?page_id=2';
    232235        $wpdb->insert( $wpdb->posts, array(
    233236                'post_author' => $user_id,