Make WordPress Core


Ignore:
Timestamp:
04/16/2018 08:59:19 AM (8 years ago)
Author:
azaozz
Message:

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

Props fclaussen, azaozz.

Fixes #43491.

File:
1 edited

Legend:

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

    r42875 r42981  
    307307                        )
    308308                );
     309
     310                // 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
     317                $privacy_policy_guid = get_option( 'home' ) . '/?page_id=3';
     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 );
    309347
    310348                // Set up default widgets for default theme.
Note: See TracChangeset for help on using the changeset viewer.