Make WordPress Core

Ticket #49264: 49264.diff

File 49264.diff, 11.9 KB (added by xkon, 4 years ago)
  • src/js/_enqueues/admin/privacy-tools.js

    diff --git a/src/js/_enqueues/admin/privacy-tools.js b/src/js/_enqueues/admin/privacy-tools.js
    index 802ec88f4b..9d878e7c92 100644
    a b jQuery( document ).ready( function( $ ) { 
    7777
    7878                        appendResultsAfterRow( $requestRow, 'notice-success', summaryMessage, [] );
    7979                        $this.hide();
    80                        
     80
    8181                        if ( 'undefined' !== typeof zipUrl ) {
    8282                                window.location = zipUrl;
    8383                        } else if ( ! sendAsEmail ) {
    jQuery( document ).ready( function( $ ) { 
    259259                        }
    260260                }
    261261        });
     262
     263        $( 'body.options-privacy-php label[for=create-page]' ).on( 'click', function( e ) {
     264                e.preventDefault();
     265                $( 'input#create-page' ).focus();
     266        } );
    262267});
    263268
  • new file src/wp-admin/css/privacy-settings.css

    diff --git a/src/wp-admin/css/privacy-settings.css b/src/wp-admin/css/privacy-settings.css
    new file mode 100644
    index 0000000000..340b10ef89
    - +  
     1/* General */
     2.options-privacy-php #wpcontent,
     3.options-privacy-php.auto-fold #wpcontent {
     4        padding-left: 0;
     5}
     6
     7.privacy-settings-header h1 {
     8        display: inline-block;
     9        font-weight: 600;
     10        margin: 0 0.8rem 1rem;
     11        font-size: 23px;
     12        padding: 9px 0 4px 0;
     13        line-height: 1.3;
     14}
     15
     16.privacy-settings-body h2 {
     17        padding: 1rem 0;
     18        line-height: 1.4;
     19}
     20
     21.privacy-settingsbody h3 {
     22        padding: 0;
     23        font-weight: 400;
     24}
     25
     26/* Header */
     27.privacy-settings-header {
     28        text-align: center;
     29        margin: 0 0 1rem;
     30        background: #fff;
     31        border-bottom: 1px solid #e2e4e7;
     32}
     33
     34.privacy-settings-title-section {
     35        display: flex;
     36        align-items: center;
     37        justify-content: center;
     38        clear: both;
     39}
     40
     41.privacy-settings-tabs-wrapper {
     42        /* IE 11 */
     43        display: -ms-inline-grid;
     44        -ms-grid-columns: 1fr 1fr;
     45        vertical-align: top;
     46        /* modern browsers */
     47        display: inline-grid;
     48        grid-template-columns: 1fr 1fr 1fr;
     49}
     50
     51.privacy-settings-tab {
     52        display: block; /* IE 11 */
     53        text-decoration: none;
     54        color: inherit;
     55        padding: 0.5rem 1rem 1rem;
     56        margin: 0 1rem;
     57        transition: box-shadow 0.5s ease-in-out;
     58}
     59
     60.privacy-settings-tab:nth-child(1) {
     61        -ms-grid-column: 1; /* IE 11 */
     62}
     63
     64.privacy-settings-tab:nth-child(2) {
     65        -ms-grid-column: 2; /* IE 11 */
     66}
     67
     68.privacy-settings-tab:nth-child(2) {
     69        -ms-grid-column: 3; /* IE 11 */
     70}
     71
     72.privacy-settings-tab:focus {
     73        color: #191e23;
     74        outline: 1px solid #6c7781;
     75        box-shadow: none;
     76}
     77
     78.privacy-settings-tab.active {
     79        box-shadow: inset 0 -3px #007cba;
     80        font-weight: 600;
     81}
     82
     83/* Body */
     84.privacy-settings-body {
     85        max-width: 800px;
     86        margin: 0 auto;
     87}
     88
     89.tools-privacy-policy-page th {
     90        min-width: 230px;
     91}
     92
     93/* Media queries */
     94@media screen and (max-width: 782px) {
     95
     96        .privacy-settings-body {
     97                margin: 0 12px;
     98                width: auto;
     99        }
     100
     101        .privacy-settings-tabs-wrapper {
     102                grid-template-columns: 1fr;
     103        }
     104
     105        input#create-page {
     106                margin-top: 10px;
     107        }
     108}
  • src/wp-admin/options-privacy.php

    diff --git a/src/wp-admin/options-privacy.php b/src/wp-admin/options-privacy.php
    index 95492b326f..a3dbca59af 100644
    a b if ( ! empty( $privacy_policy_page_id ) ) { 
    112112        }
    113113}
    114114
    115 $title       = __( 'Privacy Settings' );
    116115$parent_file = 'options-general.php';
    117116
     117wp_enqueue_style( 'privacy-settings' );
     118wp_enqueue_script( 'privacy-tools' );
     119
    118120require_once( ABSPATH . 'wp-admin/admin-header.php' );
    119121
    120122?>
    121 <div class="wrap">
    122         <h1><?php echo $title; ?></h1>
    123         <h2><?php _e( 'Privacy Policy Page' ); ?></h2>
     123<div class="privacy-settings-header">
     124        <div class="privacy-settings-title-section">
     125                <h1>
     126                        <?php _e( 'Privacy' ); ?>
     127                </h1>
     128        </div>
     129
     130        <nav class="privacy-settings-tabs-wrapper hide-if-no-js" aria-label="<?php esc_attr_e( 'Secondary menu' ); ?>">
     131                <a href="<?php echo esc_url( admin_url( 'options-privacy.php' ) ); ?>" class="privacy-settings-tab active" aria-current="true">
     132                        <?php
     133                        /* translators: Tab heading for Site Health Status page. */
     134                        _ex( 'Settings', 'Privacy Settings' );
     135                        ?>
     136                </a>
     137
     138                <a href="<?php echo esc_url( admin_url( 'privacy-policy-guide.php' ) ); ?>" class="privacy-settings-tab">
     139                        <?php
     140                        /* translators: Tab heading for Site Health Status page. */
     141                        _ex( 'Policy Guide', 'Privacy Settings' );
     142                        ?>
     143                </a>
     144
     145                <a href="<?php echo esc_url( admin_url( 'disclosures-and-premissions.php' ) ); ?>" class="privacy-settings-tab">
     146                        <?php
     147                        /* translators: Tab heading for Site Health Info page. */
     148                        _ex( 'Disclosures &amp; Permissions', 'Privacy Settings' );
     149                        ?>
     150                </a>
     151        </nav>
     152</div>
     153
     154<hr class="wp-header-end">
     155
     156<div class="notice notice-error hide-if-js">
     157        <p><?php _e( 'The Privacy Settings require JavaScript.' ); ?></p>
     158</div>
     159
     160<div class="privacy-settings-body hide-if-no-js">
     161        <h2><?php _e( 'Privacy Settings' ); ?></h2>
    124162        <p>
    125163                <?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.' ); ?>
    126164                <?php _e( 'If you already have a Privacy Policy page, please select it below. If not, please create one.' ); ?>
    require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
    133171                <?php _e( 'After your Privacy Policy page is set, we suggest that you edit it.' ); ?>
    134172                <?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.' ); ?>
    135173        </p>
    136         <?php
    137 
    138         if ( $privacy_policy_page_exists ) {
    139                 $edit_href = add_query_arg(
    140                         array(
    141                                 'post'   => $privacy_policy_page_id,
    142                                 'action' => 'edit',
    143                         ),
    144                         admin_url( 'post.php' )
    145                 );
    146 
    147                 $view_href = get_permalink( $privacy_policy_page_id );
    148                 ?>
    149                 <p class="tools-privacy-edit"><strong>
    150                         <?php
    151                         if ( 'publish' === get_post_status( $privacy_policy_page_id ) ) {
    152                                 printf(
    153                                         /* translators: 1: URL to edit Privacy Policy page, 2: URL to view Privacy Policy page. */
    154                                         __( '<a href="%1$s">Edit</a> or <a href="%2$s">view</a> your Privacy Policy page content.' ),
    155                                         esc_url( $edit_href ),
    156                                         esc_url( $view_href )
    157                                 );
    158                         } else {
    159                                 printf(
    160                                         /* translators: 1: URL to edit Privacy Policy page, 2: URL to preview Privacy Policy page. */
    161                                         __( '<a href="%1$s">Edit</a> or <a href="%2$s">preview</a> your Privacy Policy page content.' ),
    162                                         esc_url( $edit_href ),
    163                                         esc_url( $view_href )
    164                                 );
    165                         }
    166                         ?>
    167                 </strong></p>
    168                 <?php
    169         }
    170         ?>
    171174        <p>
    172175                <?php
     176                if ( $privacy_policy_page_exists ) {
     177                        $edit_href = add_query_arg(
     178                                array(
     179                                        'post'   => $privacy_policy_page_id,
     180                                        'action' => 'edit',
     181                                ),
     182                                admin_url( 'post.php' )
     183                        );
     184
     185                        $view_href = get_permalink( $privacy_policy_page_id );
     186                        ?>
     187                                <strong>
     188                                <?php
     189                                if ( 'publish' === get_post_status( $privacy_policy_page_id ) ) {
     190                                        printf(
     191                                                /* translators: 1: URL to edit Privacy Policy page, 2: URL to view Privacy Policy page. */
     192                                                __( '<a href="%1$s">Edit</a> or <a href="%2$s">view</a> your Privacy Policy page content.' ),
     193                                                esc_url( $edit_href ),
     194                                                esc_url( $view_href )
     195                                        );
     196                                } else {
     197                                        printf(
     198                                                /* translators: 1: URL to edit Privacy Policy page, 2: URL to preview Privacy Policy page. */
     199                                                __( '<a href="%1$s">Edit</a> or <a href="%2$s">preview</a> your Privacy Policy page content.' ),
     200                                                esc_url( $edit_href ),
     201                                                esc_url( $view_href )
     202                                        );
     203                                }
     204                                ?>
     205                                </strong>
     206                        <?php
     207                }
    173208                printf(
    174209                        /* translators: 1: Privacy Policy guide URL, 2: Additional link attributes, 3: Accessibility text. */
    175                         __( '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.' ),
     210                        __( 'Need help putting together your new Privacy Policy page? <a href="%1$s" %2$s>Check out our Privacy Policy guide%3$s</a> for recommendations on what content to include, along with policies suggested by your plugins and theme.' ),
    176211                        esc_url( admin_url( 'privacy-policy-guide.php' ) ),
    177212                        '',
    178213                        ''
    require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
    181216        </p>
    182217
    183218        <hr>
     219
     220        <?php
     221        $has_pages = (bool) get_posts(
     222                array(
     223                        'post_type'      => 'page',
     224                        'posts_per_page' => 1,
     225                        'post_status'    => array(
     226                                'publish',
     227                                'draft',
     228                        ),
     229                )
     230        );
     231        ?>
     232
    184233        <table class="form-table tools-privacy-policy-page" role="presentation">
     234                <tr>
     235                        <th scope="row">
     236                                <label for="create-page">
     237                                <?php
     238                                if ( $has_pages ) {
     239                                        _e( 'Create a new Privacy Policy Page' );
     240                                } else {
     241                                        _e( 'There are no pages.' );
     242                                }
     243                                ?>
     244                                </label>
     245                        </td>
     246                        <td>
     247                                <form class="wp-create-privacy-page" method="post" action="">
     248                                        <input type="hidden" name="action" value="create-privacy-page" />
     249                                        <?php
     250                                        wp_nonce_field( 'create-privacy-page' );
     251
     252                                        submit_button( __( 'Create' ), 'secondary', 'submit', false, array( 'id' => 'create-page' ) );
     253                                        ?>
     254                                </form>
     255                        </td>
     256                </tr>
     257                <?php if ( $has_pages ) : ?>
    185258                <tr>
    186259                        <th scope="row">
    187260                                <label for="page_for_privacy_policy">
    require_once( ABSPATH . 'wp-admin/admin-header.php' ); 
    195268                                </label>
    196269                        </th>
    197270                        <td>
    198                                 <?php
    199                                 $has_pages = (bool) get_posts(
    200                                         array(
    201                                                 'post_type'      => 'page',
    202                                                 'posts_per_page' => 1,
    203                                                 'post_status'    => array(
    204                                                         'publish',
    205                                                         'draft',
    206                                                 ),
    207                                         )
    208                                 );
    209 
    210                                 if ( $has_pages ) :
    211                                         ?>
    212                                         <form method="post" action="">
    213                                                 <input type="hidden" name="action" value="set-privacy-page" />
    214                                                 <?php
    215                                                 wp_dropdown_pages(
    216                                                         array(
    217                                                                 'name'              => 'page_for_privacy_policy',
    218                                                                 'show_option_none'  => __( '&mdash; Select &mdash;' ),
    219                                                                 'option_none_value' => '0',
    220                                                                 'selected'          => $privacy_policy_page_id,
    221                                                                 'post_status'       => array( 'draft', 'publish' ),
    222                                                         )
    223                                                 );
    224 
    225                                                 wp_nonce_field( 'set-privacy-page' );
    226 
    227                                                 submit_button( __( 'Use This Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) );
    228                                                 ?>
    229                                         </form>
    230                                 <?php endif; ?>
    231 
    232                                 <form class="wp-create-privacy-page" method="post" action="">
    233                                         <input type="hidden" name="action" value="create-privacy-page" />
    234                                         <span>
    235                                                 <?php
    236                                                 if ( $has_pages ) {
    237                                                         _e( 'Or:' );
    238                                                 } else {
    239                                                         _e( 'There are no pages.' );
    240                                                 }
    241                                                 ?>
    242                                         </span>
     271                                <form method="post" action="">
     272                                        <input type="hidden" name="action" value="set-privacy-page" />
    243273                                        <?php
    244                                         wp_nonce_field( 'create-privacy-page' );
     274                                        wp_dropdown_pages(
     275                                                array(
     276                                                        'name'              => 'page_for_privacy_policy',
     277                                                        'show_option_none'  => __( '&mdash; Select &mdash;' ),
     278                                                        'option_none_value' => '0',
     279                                                        'selected'          => $privacy_policy_page_id,
     280                                                        'post_status'       => array( 'draft', 'publish' ),
     281                                                )
     282                                        );
    245283
    246                                         submit_button( __( 'Create New Page' ), 'primary', 'submit', false, array( 'id' => 'create-page' ) );
     284                                        wp_nonce_field( 'set-privacy-page' );
     285
     286                                        submit_button( __( 'Use This Page' ), 'primary', 'submit', false, array( 'id' => 'set-page' ) );
    247287                                        ?>
    248288                                </form>
    249289                        </td>
    250290                </tr>
     291                <?php endif; ?>
    251292        </table>
     293
    252294</div>
    253295<?php
    254296
  • src/wp-includes/script-loader.php

    diff --git a/src/wp-includes/script-loader.php b/src/wp-includes/script-loader.php
    index 018cb777af..e30dfc7f84 100644
    a b function wp_default_styles( &$styles ) { 
    17301730        $styles->add( 'l10n', "/wp-admin/css/l10n$suffix.css" );
    17311731        $styles->add( 'code-editor', "/wp-admin/css/code-editor$suffix.css", array( 'wp-codemirror' ) );
    17321732        $styles->add( 'site-health', "/wp-admin/css/site-health$suffix.css" );
     1733        $styles->add( 'privacy-settings', "/wp-admin/css/privacy-settings$suffix.css" );
    17331734
    17341735        $styles->add( 'wp-admin', false, array( 'dashicons', 'common', 'forms', 'admin-menu', 'dashboard', 'list-tables', 'edit', 'revisions', 'media', 'themes', 'about', 'nav-menus', 'widgets', 'site-icon', 'l10n' ) );
    17351736