Make WordPress Core


Ignore:
Timestamp:
05/11/2018 03:43:36 PM (9 years ago)
Author:
azaozz
Message:

Privacy: make creating a privacy policy page on install multisite compatible.

See #43491.

File:
1 edited

Legend:

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

    r42982 r43243  
    309309
    310310                // Privacy Policy page
    311                 if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
    312                         include_once( ABSPATH . 'wp-admin/includes/misc.php' );
    313                 }
    314 
    315                 $privacy_policy_content = WP_Privacy_Policy_Content::get_default_content();
    316                 $privacy_policy_guid = get_option( 'home' ) . '/?page_id=3';
    317 
    318                 $wpdb->insert(
    319                         $wpdb->posts, array(
    320                                 'post_author'           => $user_id,
    321                                 'post_date'             => $now,
    322                                 'post_date_gmt'         => $now_gmt,
    323                                 'post_content'          => $privacy_policy_content,
    324                                 'post_excerpt'          => '',
    325                                 'comment_status'        => 'closed',
    326                                 'post_title'            => __( 'Privacy Policy' ),
    327                                 /* translators: Privacy Policy page slug */
    328                                 'post_name'             => __( 'privacy-policy' ),
    329                                 'post_modified'         => $now,
    330                                 'post_modified_gmt'     => $now_gmt,
    331                                 'guid'                  => $privacy_policy_guid,
    332                                 'post_type'             => 'page',
    333                                 'post_status'           => 'draft',
    334                                 'to_ping'               => '',
    335                                 'pinged'                => '',
    336                                 'post_content_filtered' => '',
    337                         )
    338                 );
    339                 $wpdb->insert(
    340                         $wpdb->postmeta, array(
    341                                 'post_id'    => 3,
    342                                 'meta_key'   => '_wp_page_template',
    343                                 'meta_value' => 'default',
    344                         )
    345                 );
    346                 update_option( 'wp_page_for_privacy_policy', 3 );
     311                if ( is_multisite() ) {
     312                        // Disable by default unless the suggested content is provided.
     313                        $privacy_policy_content = get_site_option( 'default_privacy_policy_content' );
     314                } else {
     315                        if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
     316                                include_once( ABSPATH . 'wp-admin/includes/misc.php' );
     317                        }
     318
     319                        $privacy_policy_content = WP_Privacy_Policy_Content::get_default_content();
     320                }
     321
     322                if ( ! empty( $privacy_policy_content ) ) {
     323                        $privacy_policy_guid = get_option( 'home' ) . '/?page_id=3';
     324
     325                        $wpdb->insert(
     326                                $wpdb->posts, array(
     327                                        'post_author'           => $user_id,
     328                                        'post_date'             => $now,
     329                                        'post_date_gmt'         => $now_gmt,
     330                                        'post_content'          => $privacy_policy_content,
     331                                        'post_excerpt'          => '',
     332                                        'comment_status'        => 'closed',
     333                                        'post_title'            => __( 'Privacy Policy' ),
     334                                        /* translators: Privacy Policy page slug */
     335                                        'post_name'             => __( 'privacy-policy' ),
     336                                        'post_modified'         => $now,
     337                                        'post_modified_gmt'     => $now_gmt,
     338                                        'guid'                  => $privacy_policy_guid,
     339                                        'post_type'             => 'page',
     340                                        'post_status'           => 'draft',
     341                                        'to_ping'               => '',
     342                                        'pinged'                => '',
     343                                        'post_content_filtered' => '',
     344                                )
     345                        );
     346                        $wpdb->insert(
     347                                $wpdb->postmeta, array(
     348                                        'post_id'    => 3,
     349                                        'meta_key'   => '_wp_page_template',
     350                                        'meta_value' => 'default',
     351                                )
     352                        );
     353                        update_option( 'wp_page_for_privacy_policy', 3 );
     354                }
    347355
    348356                // Set up default widgets for default theme.
Note: See TracChangeset for help on using the changeset viewer.