WordPress.org

Make WordPress Core

Changeset 40296


Ignore:
Timestamp:
03/17/17 15:48:35 (9 months ago)
Author:
swissspidy
Message:

Multisite: Ensure first page/post/comment content is not empty when setting up a new site.

This prevents creating page without any content when the options are populated with an empty string.

Props shadyvb.
Fixes #40036.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r39921 r40296  
    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. 
     197    if ( is_multisite() ) { 
     198        $first_comment_author = get_site_option( 'first_comment_author' ); 
     199        $first_comment_email = get_site_option( 'first_comment_email' ); 
     200        $first_comment_url = get_site_option( 'first_comment_url', network_home_url() ); 
     201        $first_comment = get_site_option( 'first_comment' ); 
     202    } 
     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. 
    201208To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard. 
    202209Commenter avatars come from <a href="https://gravatar.com">Gravatar</a>.' ); 
    203     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 ); 
    206         $first_comment_url = get_site_option( 'first_comment_url', network_home_url() ); 
    207         $first_comment = get_site_option( 'first_comment', $first_comment ); 
    208     } 
    209210    $wpdb->insert( $wpdb->comments, array( 
    210211        'comment_post_ID' => 1, 
     
    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  
    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> 
    223  
    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() ); 
    229221    if ( is_multisite() ) 
    230         $first_page = get_site_option( 'first_page', $first_page ); 
     222        $first_page = get_site_option( 'first_page' ); 
     223 
     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() ); 
     233 
    231234    $first_post_guid = get_option('home') . '/?page_id=2'; 
    232235    $wpdb->insert( $wpdb->posts, array( 
Note: See TracChangeset for help on using the changeset viewer.