Make WordPress Core

Changeset 43272


Ignore:
Timestamp:
05/15/2018 03:29:27 PM (7 years ago)
Author:
SergeyBiryukov
Message:

Privacy: automatically create a Privacy Policy page when installing WordPress.

Props fclaussen, azaozz.
Merges [42981], [42982], [43243] to the 4.9 branch.
Fixes #43491.

Location:
branches/4.9
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-admin/includes/upgrade.php

    r42212 r43272  
    252252    ));
    253253    $wpdb->insert( $wpdb->postmeta, array( 'post_id' => 2, 'meta_key' => '_wp_page_template', 'meta_value' => 'default' ) );
     254
     255    // Privacy Policy page
     256    if ( is_multisite() ) {
     257        // Disable by default unless the suggested content is provided.
     258        $privacy_policy_content = get_site_option( 'default_privacy_policy_content' );
     259    } else {
     260        if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
     261            include_once( ABSPATH . 'wp-admin/includes/misc.php' );
     262        }
     263
     264        $privacy_policy_content = WP_Privacy_Policy_Content::get_default_content();
     265    }
     266
     267    if ( ! empty( $privacy_policy_content ) ) {
     268        $privacy_policy_guid = get_option( 'home' ) . '/?page_id=3';
     269
     270        $wpdb->insert(
     271            $wpdb->posts, array(
     272                'post_author'           => $user_id,
     273                'post_date'             => $now,
     274                'post_date_gmt'         => $now_gmt,
     275                'post_content'          => $privacy_policy_content,
     276                'post_excerpt'          => '',
     277                'comment_status'        => 'closed',
     278                'post_title'            => __( 'Privacy Policy' ),
     279                /* translators: Privacy Policy page slug */
     280                'post_name'             => __( 'privacy-policy' ),
     281                'post_modified'         => $now,
     282                'post_modified_gmt'     => $now_gmt,
     283                'guid'                  => $privacy_policy_guid,
     284                'post_type'             => 'page',
     285                'post_status'           => 'draft',
     286                'to_ping'               => '',
     287                'pinged'                => '',
     288                'post_content_filtered' => '',
     289            )
     290        );
     291        $wpdb->insert(
     292            $wpdb->postmeta, array(
     293                'post_id'    => 3,
     294                'meta_key'   => '_wp_page_template',
     295                'meta_value' => 'default',
     296            )
     297        );
     298        update_option( 'wp_page_for_privacy_policy', 3 );
     299    }
    254300
    255301    // Set up default widgets for default theme.
Note: See TracChangeset for help on using the changeset viewer.