Make WordPress Core

Changeset 45451


Ignore:
Timestamp:
05/26/2019 10:56:18 PM (5 years ago)
Author:
azaozz
Message:

Privacy tools: restore privacy.php to its "proper" use to output the Privacy tab on the About screen, see [42814]. Then add the Privacy tab updates from freedoms.php.

See #43895.

Location:
trunk/src/wp-admin
Files:
3 edited
1 copied

Legend:

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

    r45338 r45451  
    4646            <a href="credits.php" class="nav-tab"><?php _e( 'Credits' ); ?></a>
    4747            <a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a>
    48             <a href="freedoms.php?privacy-notice" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
     48            <a href="privacy.php" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
    4949        </nav>
    5050
  • trunk/src/wp-admin/credits.php

    r45338 r45451  
    4747    <a href="credits.php" class="nav-tab nav-tab-active" aria-current="page"><?php _e( 'Credits' ); ?></a>
    4848    <a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a>
    49     <a href="freedoms.php?privacy-notice" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
     49    <a href="privacy.php" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
    5050</nav>
    5151
  • trunk/src/wp-admin/freedoms.php

    r45338 r45451  
    1616include( ABSPATH . 'wp-admin/admin-header.php' );
    1717
    18 $is_privacy_notice = isset( $_GET['privacy-notice'] );
    19 
    20 if ( $is_privacy_notice ) {
    21     $freedoms_class        = '';
    22     $privacy_class         = ' nav-tab-active';
    23     $freedoms_aria_current = '';
    24     $privacy_aria_current  = ' aria-current="page"';
    25 } else {
    26     $freedoms_class        = ' nav-tab-active';
    27     $privacy_class         = '';
    28     $freedoms_aria_current = ' aria-current="page"';
    29     $privacy_aria_current  = '';
     18// This file was used to also display the Privacy tab on the About screen from 4.9.6 until 5.3.0.
     19if ( isset( $_GET['privacy-notice'] ) ) {
     20    wp_redirect( admi_url( 'privacy.php' ), 301 );
     21    exit;
    3022}
    3123
     
    6052    <a href="about.php" class="nav-tab"><?php _e( 'What&#8217;s New' ); ?></a>
    6153    <a href="credits.php" class="nav-tab"><?php _e( 'Credits' ); ?></a>
    62     <a href="freedoms.php" class="nav-tab<?php echo $freedoms_class; ?>"<?php echo $freedoms_aria_current; ?>><?php _e( 'Freedoms' ); ?></a>
    63     <a href="freedoms.php?privacy-notice" class="nav-tab<?php echo $privacy_class; ?>"<?php echo $privacy_aria_current; ?>><?php _e( 'Privacy' ); ?></a>
     54    <a href="freedoms.php" class="nav-tab nav-tab-active" aria-current="page"><?php _e( 'Freedoms' ); ?></a>
     55    <a href="privacy.php" class="nav-tab"><?php _e( 'Privacy' ); ?></a>
    6456</nav>
    6557
    66 <?php if ( $is_privacy_notice ) : ?>
    67 
    68 <div class="about-wrap-content">
    69     <p class="about-description"><?php _e( 'From time to time, your WordPress site may send data to WordPress.org &#8212; including, but not limited to &#8212; the version of WordPress you are using, and a list of installed plugins and themes.' ); ?></p>
    70 
    71     <p>
    72         <?php
    73         /* translators: %s: https://wordpress.org/about/stats/ */
    74         printf( __( 'This data is used to provide general enhancements to WordPress, which includes helping to protect your site by finding and automatically installing new updates. It is also used to calculate statistics, such as those shown on the <a href="%s">WordPress.org stats page</a>.' ), 'https://wordpress.org/about/stats/' );
    75         ?>
    76     </p>
    77 
    78     <p>
    79         <?php
    80         /* translators: %s: https://wordpress.org/about/privacy/ */
    81         printf( __( 'We take privacy and transparency very seriously. To learn more about what data we collect, and how we use it, please visit <a href="%s">WordPress.org/about/privacy</a>.' ), 'https://wordpress.org/about/privacy/' );
    82         ?>
    83     </p>
    84 </div>
    85 
    86 <?php else : ?>
    8758<div class="about-wrap-content">
    8859    <div class="feature-section has-1-columns">
     
    140111</div>
    141112
    142 <?php endif; ?>
    143113</div>
    144114<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
  • trunk/src/wp-admin/privacy.php

    r45447 r45451  
    11<?php
    22/**
    3  * Privacy Settings Screen.
     3 * Privacy administration panel.
    44 *
    55 * @package WordPress
     
    1010require_once( dirname( __FILE__ ) . '/admin.php' );
    1111
    12 if ( ! current_user_can( 'manage_privacy_options' ) ) {
    13     wp_die( __( 'Sorry, you are not allowed to manage privacy on this site.' ) );
    14 }
     12$title = __( 'Privacy' );
    1513
    16 $action = isset( $_POST['action'] ) ? $_POST['action'] : '';
     14list( $display_version ) = explode( '-', get_bloginfo( 'version' ) );
    1715
    18 if ( ! empty( $action ) ) {
    19     check_admin_referer( $action );
     16include( ABSPATH . 'wp-admin/admin-header.php' );
     17?>
     18<div class="wrap about-wrap full-width-layout">
    2019
    21     if ( 'set-privacy-page' === $action ) {
    22         $privacy_policy_page_id = isset( $_POST['page_for_privacy_policy'] ) ? (int) $_POST['page_for_privacy_policy'] : 0;
    23         update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id );
     20<h1>
     21    <?php
     22    /* translators: %s: The current WordPress version number */
     23    printf( __( 'Welcome to WordPress&nbsp;%s' ), $display_version );
     24    ?>
     25</h1>
    2426
    25         $privacy_page_updated_message = __( 'Privacy Policy page updated successfully.' );
     27<p class="about-text">
     28    <?php
     29    printf(
     30        /* translators: %s: The current WordPress version number */
     31        __( 'Congratulations on updating to WordPress %s! This update makes it easier than ever to fix your site if something goes wrong.' ),
     32        $display_version
     33    );
     34    ?>
     35</p>
    2636
    27         if ( $privacy_policy_page_id ) {
    28             /*
    29              * Don't always link to the menu customizer:
    30              *
    31              * - Unpublished pages can't be selected by default.
    32              * - `WP_Customize_Nav_Menus::__construct()` checks the user's capabilities.
    33              * - Themes might not "officially" support menus.
    34              */
    35             if (
    36                 'publish' === get_post_status( $privacy_policy_page_id )
    37                 && current_user_can( 'edit_theme_options' )
    38                 && current_theme_supports( 'menus' )
    39             ) {
    40                 $privacy_page_updated_message = sprintf(
    41                     /* translators: %s: URL to Customizer -> Menus */
    42                     __( 'Privacy Policy page setting updated successfully. Remember to <a href="%s">update your menus</a>!' ),
    43                     esc_url( add_query_arg( 'autofocus[panel]', 'nav_menus', admin_url( 'customize.php' ) ) )
    44                 );
    45             }
    46         }
     37<div class="wp-badge">
     38    <?php
     39    /* translators: %s: The current WordPress version number */
     40    printf( __( 'Version %s' ), $display_version );
     41    ?>
     42</div>
    4743
    48         add_settings_error(
    49             'page_for_privacy_policy',
    50             'page_for_privacy_policy',
    51             $privacy_page_updated_message,
    52             'updated'
    53         );
    54     } elseif ( 'create-privacy-page' === $action ) {
     44<nav class="nav-tab-wrapper wp-clearfix" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
     45    <a href="about.php" class="nav-tab"><?php _e( 'What&#8217;s New' ); ?></a>
     46    <a href="credits.php" class="nav-tab"><?php _e( 'Credits' ); ?></a>
     47    <a href="freedoms.php" class="nav-tab"><?php _e( 'Freedoms' ); ?></a>
     48    <a href="privacy.php" class="nav-tab nav-tab-active" aria-current="page"><?php _e( 'Privacy' ); ?></a>
     49</nav>
    5550
    56         if ( ! class_exists( 'WP_Privacy_Policy_Content' ) ) {
    57             require_once( ABSPATH . 'wp-admin/includes/misc.php' );
    58         }
     51<div class="about-wrap-content">
     52    <p class="about-description"><?php _e( 'From time to time, your WordPress site may send data to WordPress.org &#8212; including, but not limited to &#8212; the version of WordPress you are using, and a list of installed plugins and themes.' ); ?></p>
    5953
    60         $privacy_policy_page_content = WP_Privacy_Policy_Content::get_default_content();
    61         $privacy_policy_page_id      = wp_insert_post(
    62             array(
    63                 'post_title'   => __( 'Privacy Policy' ),
    64                 'post_status'  => 'draft',
    65                 'post_type'    => 'page',
    66                 'post_content' => $privacy_policy_page_content,
    67             ),
    68             true
    69         );
    70 
    71         if ( is_wp_error( $privacy_policy_page_id ) ) {
    72             add_settings_error(
    73                 'page_for_privacy_policy',
    74                 'page_for_privacy_policy',
    75                 __( 'Unable to create a Privacy Policy page.' ),
    76                 'error'
    77             );
    78         } else {
    79             update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id );
    80 
    81             wp_redirect( admin_url( 'post.php?post=' . $privacy_policy_page_id . '&action=edit' ) );
    82             exit;
    83         }
    84     }
    85 }
    86 
    87 // If a Privacy Policy page ID is available, make sure the page actually exists. If not, display an error.
    88 $privacy_policy_page_exists = false;
    89 $privacy_policy_page_id     = (int) get_option( 'wp_page_for_privacy_policy' );
    90 
    91 if ( ! empty( $privacy_policy_page_id ) ) {
    92 
    93     $privacy_policy_page = get_post( $privacy_policy_page_id );
    94 
    95     if ( ! $privacy_policy_page instanceof WP_Post ) {
    96         add_settings_error(
    97             'page_for_privacy_policy',
    98             'page_for_privacy_policy',
    99             __( 'The currently selected Privacy Policy page does not exist. Please create or select a new page.' ),
    100             'error'
    101         );
    102     } else {
    103         if ( 'trash' === $privacy_policy_page->post_status ) {
    104             add_settings_error(
    105                 'page_for_privacy_policy',
    106                 'page_for_privacy_policy',
    107                 sprintf(
    108                     /* translators: URL to Pages Trash */
    109                     __( 'The currently selected Privacy Policy page is in the trash. Please create or select a new Privacy Policy page or <a href="%s">restore the current page</a>.' ),
    110                     'edit.php?post_status=trash&post_type=page'
    111                 ),
    112                 'error'
    113             );
    114         } else {
    115             $privacy_policy_page_exists = true;
    116         }
    117     }
    118 }
    119 
    120 $title       = __( 'Privacy Settings' );
    121 $parent_file = 'options-general.php';
    122 
    123 require_once( ABSPATH . 'wp-admin/admin-header.php' );
    124 
    125 ?>
    126 <div class="wrap">
    127     <h1><?php echo $title; ?></h1>
    128     <h2><?php _e( 'Privacy Policy Page' ); ?></h2>
    129     <p>
    130         <?php _e( 'As a website owner, you may need to follow national or international privacy laws. For example, you may need to create and display a Privacy Policy.' ); ?>
    131         <?php _e( 'If you already have a Privacy Policy page, please select it below. If not, please create one.' ); ?>
    132     </p>
    133     <p>
    134         <?php _e( 'The new page will include help and suggestions for your Privacy Policy.' ); ?>
    135         <?php _e( 'However, it is your responsibility to use those resources correctly, to provide the information that your Privacy Policy requires, and to keep that information current and accurate.' ); ?>
    136     </p>
    137     <p>
    138         <?php _e( 'After your Privacy Policy page is set, we suggest that you edit it.' ); ?>
    139         <?php _e( 'We would also suggest reviewing your Privacy Policy from time to time, especially after installing or updating any themes or plugins. There may be changes or new suggested information for you to consider adding to your policy.' ); ?>
    140     </p>
    141     <?php
    142 
    143     if ( $privacy_policy_page_exists ) {
    144         $edit_href = add_query_arg(
    145             array(
    146                 'post'   => $privacy_policy_page_id,
    147                 'action' => 'edit',
    148             ),
    149             admin_url( 'post.php' )
    150         );
    151 
    152         $view_href = get_permalink( $privacy_policy_page_id );
    153 
    154         ?>
    155         <p class="tools-privacy-edit"><strong>
    156             <?php
    157 
    158             if ( 'publish' === get_post_status( $privacy_policy_page_id ) ) {
    159                 printf(
    160                     /* translators: 1: URL to edit Privacy Policy page, 2: URL to view Privacy Policy page */
    161                     __( '<a href="%1$s">Edit</a> or <a href="%2$s">view</a> your Privacy Policy page content.' ),
    162                     esc_url( $edit_href ),
    163                     esc_url( $view_href )
    164                 );
    165             } else {
    166                 printf(
    167                     /* translators: 1: URL to edit Privacy Policy page, 2: URL to preview Privacy Policy page */
    168                     __( '<a href="%1$s">Edit</a> or <a href="%2$s">preview</a> your Privacy Policy page content.' ),
    169                     esc_url( $edit_href ),
    170                     esc_url( $view_href )
    171                 );
    172             }
    173 
    174             ?>
    175         </strong></p>
    176         <?php
    177     }
    178     ?>
    17954    <p>
    18055        <?php
    181 
    182         printf(
    183             /* translators: 1: Privacy Policy guide URL, 2: additional link attributes, 3: accessibility text */
    184             __( 'Need help putting together your new Privacy Policy page? <a href="%1$s" %2$s>Check out our guide%3$s</a> for recommendations on what content to include, along with policies suggested by your plugins and theme.' ),
    185             esc_url( admin_url( 'tools.php?wp-privacy-policy-guide=1' ) ),
    186             '',
    187             ''
    188         );
    189 
     56        /* translators: %s: https://wordpress.org/about/stats/ */
     57        printf( __( 'This data is used to provide general enhancements to WordPress, which includes helping to protect your site by finding and automatically installing new updates. It is also used to calculate statistics, such as those shown on the <a href="%s">WordPress.org stats page</a>.' ), 'https://wordpress.org/about/stats/' );
    19058        ?>
    19159    </p>
    19260
    193     <hr>
    194     <table class="form-table tools-privacy-policy-page" role="presentation">
    195         <tr>
    196             <th scope="row"><label for="page_for_privacy_policy">
    197                 <?php
    198                 if ( $privacy_policy_page_exists ) {
    199                     _e( 'Change your Privacy Policy page' );
    200                 } else {
    201                     _e( 'Select a Privacy Policy page' );
    202                 }
    203                 ?>
    204             </label></th>
    205             <td>
    206                 <?php
    207                 $has_pages = (bool) get_posts(
    208                     array(
    209                         'post_type'      => 'page',
    210                         'posts_per_page' => 1,
    211                         'post_status'    => array(
    212                             'publish',
    213                             'draft',
    214                         ),
    215                     )
    216                 );
     61    <p>
     62        <?php
     63        /* translators: %s: https://wordpress.org/about/privacy/ */
     64        printf( __( 'We take privacy and transparency very seriously. To learn more about what data we collect, and how we use it, please visit <a href="%s">WordPress.org/about/privacy</a>.' ), 'https://wordpress.org/about/privacy/' );
     65        ?>
     66    </p>
     67</div>
    21768
    218                 if ( $has_pages ) :
    219                     ?>
    220                     <form method="post" action="">
    221                         <input type="hidden" name="action" value="set-privacy-page" />
    222                         <?php
    223                         wp_dropdown_pages(
    224                             array(
    225                                 'name'              => 'page_for_privacy_policy',
    226                                 'show_option_none'  => __( '&mdash; Select &mdash;' ),
    227                                 'option_none_value' => '0',
    228                                 'selected'          => $privacy_policy_page_id,
    229                                 'post_status'       => array( 'draft', 'publish' ),
    230                             )
    231                         );
    232 
    233                         wp_nonce_field( 'set-privacy-page' );
    234 
    235                         submit_button( __( 'Use This Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) );
    236                         ?>
    237                     </form>
    238                 <?php endif; ?>
    239 
    240                 <form class="wp-create-privacy-page" method="post" action="">
    241                     <input type="hidden" name="action" value="create-privacy-page" />
    242                     <span>
    243                         <?php
    244                         if ( $has_pages ) {
    245                             _e( 'Or:' );
    246                         } else {
    247                             _e( 'There are no pages.' );
    248                         }
    249                         ?>
    250                     </span>
    251                     <?php
    252                     wp_nonce_field( 'create-privacy-page' );
    253 
    254                     submit_button( __( 'Create New Page' ), 'primary', 'submit', false, array( 'id' => 'create-page' ) );
    255                     ?>
    256                 </form>
    257             </td>
    258         </tr>
    259     </table>
    26069</div>
    261 <?php
    262 
    263 include( ABSPATH . 'wp-admin/admin-footer.php' );
     70<?php include( ABSPATH . 'wp-admin/admin-footer.php' ); ?>
Note: See TracChangeset for help on using the changeset viewer.