From 62061bab5658386d0bbfbfeb3f89be883fd75ec4 Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Fri, 17 Mar 2017 15:49:42 +0000 Subject: [PATCH] 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. Built from https://develop.svn.wordpress.org/trunk@40296 git-svn-id: http://core.svn.wordpress.org/trunk@40203 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/upgrade.php | 43 +++++++++++++++++++---------------- wp-includes/version.php | 2 +- 2 files changed, 24 insertions(+), 21 deletions(-) diff --git a/wp-admin/includes/upgrade.php b/wp-admin/includes/upgrade.php index 8ce5c2aac8..94ad771761 100644 --- a/wp-admin/includes/upgrade.php +++ b/wp-admin/includes/upgrade.php @@ -194,18 +194,19 @@ function wp_install_defaults( $user_id ) { $wpdb->insert( $wpdb->term_relationships, array('term_taxonomy_id' => $cat_tt_id, 'object_id' => 1) ); // Default comment - $first_comment_author = __( 'A WordPress Commenter' ); - $first_comment_email = 'wapuu@wordpress.example'; - $first_comment_url = 'https://wordpress.org/'; - $first_comment = __( 'Hi, this is a comment. + if ( is_multisite() ) { + $first_comment_author = get_site_option( 'first_comment_author' ); + $first_comment_email = get_site_option( 'first_comment_email' ); + $first_comment_url = get_site_option( 'first_comment_url', network_home_url() ); + $first_comment = get_site_option( 'first_comment' ); + } + + $first_comment_author = ! empty( $first_comment_author ) ? $first_comment_author : __( 'A WordPress Commenter' ); + $first_comment_email = ! empty( $first_comment_email ) ? $first_comment_email : 'wapuu@wordpress.example'; + $first_comment_url = ! empty( $first_comment_url ) ? $first_comment_url : 'https://wordpress.org/'; + $first_comment = ! empty( $first_comment ) ? $first_comment : __( 'Hi, this is a comment. To get started with moderating, editing, and deleting comments, please visit the Comments screen in the dashboard. Commenter avatars come from Gravatar.' ); - if ( is_multisite() ) { - $first_comment_author = get_site_option( 'first_comment_author', $first_comment_author ); - $first_comment_email = get_site_option( 'first_comment_email', $first_comment_email ); - $first_comment_url = get_site_option( 'first_comment_url', network_home_url() ); - $first_comment = get_site_option( 'first_comment', $first_comment ); - } $wpdb->insert( $wpdb->comments, array( 'comment_post_ID' => 1, 'comment_author' => $first_comment_author, @@ -217,17 +218,19 @@ Commenter avatars come from Gravatar.' ); )); // 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: - -
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ña coladas. (And gettin' caught in the rain.)
- -...or something like this: - -
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.
- -As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!" ), admin_url() ); if ( is_multisite() ) - $first_page = get_site_option( 'first_page', $first_page ); + $first_page = get_site_option( 'first_page' ); + + $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: + +
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ña coladas. (And gettin' caught in the rain.)
+ + ...or something like this: + +
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.
+ + As a new WordPress user, you should go to your dashboard to delete this page and create new pages for your content. Have fun!" ), admin_url() ); + $first_post_guid = get_option('home') . '/?page_id=2'; $wpdb->insert( $wpdb->posts, array( 'post_author' => $user_id, diff --git a/wp-includes/version.php b/wp-includes/version.php index d4b2c37716..e01f1cd819 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -4,7 +4,7 @@ * * @global string $wp_version */ -$wp_version = '4.8-alpha-40295'; +$wp_version = '4.8-alpha-40296'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.