From 6508ab45cd64f470c764d155ec9ede1a51173bae Mon Sep 17 00:00:00 2001 From: Andrew Ozz Date: Fri, 11 May 2018 15:43:36 +0000 Subject: [PATCH] Privacy: make creating a privacy policy page on install multisite compatible. See #43491. git-svn-id: https://develop.svn.wordpress.org/trunk@43243 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-admin/includes/upgrade.php | 74 +++++++++++++++++-------------- 1 file changed, 41 insertions(+), 33 deletions(-) diff --git a/src/wp-admin/includes/upgrade.php b/src/wp-admin/includes/upgrade.php index 6e21b0d4de..85439b430a 100644 --- a/src/wp-admin/includes/upgrade.php +++ b/src/wp-admin/includes/upgrade.php @@ -308,42 +308,50 @@ As a new WordPress user, you should go to your dashboard to d ); // Privacy Policy page - if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) { - include_once( ABSPATH . 'wp-admin/includes/misc.php' ); + if ( is_multisite() ) { + // Disable by default unless the suggested content is provided. + $privacy_policy_content = get_site_option( 'default_privacy_policy_content' ); + } else { + if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) { + include_once( ABSPATH . 'wp-admin/includes/misc.php' ); + } + + $privacy_policy_content = WP_Privacy_Policy_Content::get_default_content(); } - $privacy_policy_content = WP_Privacy_Policy_Content::get_default_content(); - $privacy_policy_guid = get_option( 'home' ) . '/?page_id=3'; + if ( ! empty( $privacy_policy_content ) ) { + $privacy_policy_guid = get_option( 'home' ) . '/?page_id=3'; - $wpdb->insert( - $wpdb->posts, array( - 'post_author' => $user_id, - 'post_date' => $now, - 'post_date_gmt' => $now_gmt, - 'post_content' => $privacy_policy_content, - 'post_excerpt' => '', - 'comment_status' => 'closed', - 'post_title' => __( 'Privacy Policy' ), - /* translators: Privacy Policy page slug */ - 'post_name' => __( 'privacy-policy' ), - 'post_modified' => $now, - 'post_modified_gmt' => $now_gmt, - 'guid' => $privacy_policy_guid, - 'post_type' => 'page', - 'post_status' => 'draft', - 'to_ping' => '', - 'pinged' => '', - 'post_content_filtered' => '', - ) - ); - $wpdb->insert( - $wpdb->postmeta, array( - 'post_id' => 3, - 'meta_key' => '_wp_page_template', - 'meta_value' => 'default', - ) - ); - update_option( 'wp_page_for_privacy_policy', 3 ); + $wpdb->insert( + $wpdb->posts, array( + 'post_author' => $user_id, + 'post_date' => $now, + 'post_date_gmt' => $now_gmt, + 'post_content' => $privacy_policy_content, + 'post_excerpt' => '', + 'comment_status' => 'closed', + 'post_title' => __( 'Privacy Policy' ), + /* translators: Privacy Policy page slug */ + 'post_name' => __( 'privacy-policy' ), + 'post_modified' => $now, + 'post_modified_gmt' => $now_gmt, + 'guid' => $privacy_policy_guid, + 'post_type' => 'page', + 'post_status' => 'draft', + 'to_ping' => '', + 'pinged' => '', + 'post_content_filtered' => '', + ) + ); + $wpdb->insert( + $wpdb->postmeta, array( + 'post_id' => 3, + 'meta_key' => '_wp_page_template', + 'meta_value' => 'default', + ) + ); + update_option( 'wp_page_for_privacy_policy', 3 ); + } // Set up default widgets for default theme. update_option(