Make WordPress Core

Ticket #43481: 43481.5.diff

File 43481.5.diff, 14.3 KB (added by xkon, 7 years ago)
  • src/wp-admin/css/forms.css

     
    10681068        clear: both;
    10691069}
    10701070
     1071/*------------------------------------------------------------------------------
     1072   Privacy Tools
     1073------------------------------------------------------------------------------*/
    10711074
     1075body.privacy-php .tools-information {
     1076        background: #f6fbfd;
     1077}
     1078
     1079body.privacy-php #poststuff h2 {
     1080        font-size: 1.3em;
     1081}
     1082
     1083body.privacy-php .privacy-information .nav-tab-wrapper {
     1084        margin-bottom: 10px;
     1085}
     1086
     1087body.privacy-php .privacy-information .tab-content {
     1088        position: relative;
     1089        min-width: 255px;
     1090        border: 1px solid #e5e5e5;
     1091        box-shadow: 0 1px 1px rgba(0,0,0,0.04);
     1092        background: #fff;
     1093        padding: 12px;
     1094}
     1095
    10721096/* =Media Queries
    10731097-------------------------------------------------------------- */
    10741098
  • src/wp-admin/js/xfn.js

     
    1919                });
    2020                $( '#link_rel' ).val( ( isMe ) ? 'me' : inputs.substr( 0,inputs.length - 1 ) );
    2121        });
     22
     23        // Privacy Tools
     24        $( 'body.privacy-php .nav-tab' ).on( 'click', function( e ){
     25                e.preventDefault();
     26
     27                var target = '.' + $( this ).data( 'tab' );
     28                $( target ).show();
     29                $( target ).siblings().hide();
     30                $( this ).addClass( 'nav-tab-active' );
     31                $( this ).siblings().removeClass( 'nav-tab-active' )
     32        });
     33
     34        $( 'body.privacy-php .tab:eq(0)' ).siblings().css( 'display', 'none' );
     35        $( 'body.privacy-php .privacy-information .tab:eq(0)' ).siblings().css( 'display', 'none' );
    2236});
  • src/wp-admin/privacy.php

     
    1414}
    1515
    1616// "Borrow" xfn.js for now so we don't have to create new files.
    17 // wp_enqueue_script( 'xfn' );
     17wp_enqueue_script( 'xfn' );
    1818
    1919$action = isset( $_POST['action'] ) ? $_POST['action'] : '';
    2020
     
    6262
    6363// If a privacy policy page ID is available, make sure the page actually exists. If not, display an error.
    6464$privacy_policy_page_exists = false;
    65 $privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
     65$privacy_policy_page_id     = (int) get_option( 'wp_page_for_privacy_policy' );
    6666
    6767if ( ! empty( $privacy_policy_page_id ) ) {
    68                 $privacy_policy_page = get_post( $privacy_policy_page_id );
    69                 if ( ! $privacy_policy_page instanceof WP_Post ) {
     68        $privacy_policy_page = get_post( $privacy_policy_page_id );
     69        if ( ! $privacy_policy_page instanceof WP_Post ) {
     70                add_settings_error(
     71                        'page_for_privacy_policy',
     72                        'page_for_privacy_policy',
     73                        __( 'The currently selected privacy policy page does not exist. Please create or select new page.' ),
     74                        'error'
     75                );
     76        } else {
     77                if ( 'trash' === $privacy_policy_page->post_status ) {
    7078                        add_settings_error(
    7179                                'page_for_privacy_policy',
    7280                                'page_for_privacy_policy',
    73                                 __( 'The currently selected privacy policy page does not exist. Please create or select new page.' ),
     81                                sprintf(
     82                                        // translators: %s The url to restore the page.
     83                                        __( 'The currently selected privacy policy page is in the trash. Please create or select new privacy policy page or <a href="%s">restore the current page</a>.' ),
     84                                        'edit.php?post_status=trash&post_type=page'
     85                                ),
    7486                                'error'
    7587                        );
    7688                } else {
    77                         if ( 'trash' === $privacy_policy_page->post_status ) {
    78                                 add_settings_error(
    79                                         'page_for_privacy_policy',
    80                                         'page_for_privacy_policy',
    81                                         sprintf(
    82                                                 __( 'The currently selected privacy policy page is in the trash. Please create or select new privacy policy page or <a href="%s">restore the current page</a>.' ),
    83                                                 'edit.php?post_status=trash&post_type=page'
    84                                         ),
    85                                         'error'
    86                                 );
    87                         } else {
    88                                 $privacy_policy_page_exists = true;
    89                         }
     89                        $privacy_policy_page_exists = true;
    9090                }
     91        }
    9192}
    9293
    9394get_current_screen()->add_help_tab( array(
     
    104105require_once( ABSPATH . 'wp-admin/admin-header.php' );
    105106
    106107?>
     108<!-- PAGE WRAP -->
    107109<div class="wrap">
    108         <h1><?php _e( 'Privacy Tools' ); ?></h1>
     110        <h1><?php esc_html_e( 'Privacy Tools' ); ?></h1>
    109111        <?php settings_errors(); ?>
     112        <!-- TAB PANEL MENU -->
     113        <div class="nav-tab-wrapper wp-clearfix">
     114                <a href="#" class="nav-tab nav-tab-active" data-tab="privacy-tools"><?php esc_html_e( 'Tools' ); ?></a>
     115                <a href="#" class="nav-tab" data-tab="privacy-requests"><?php esc_html_e( 'Requests' ); ?></a>
     116                <a href="#" class="nav-tab" data-tab="privacy-information"><?php esc_html_e( 'Privacy Policy Information' ); ?></a>
     117        </div>
     118        <!-- TABS -->
     119        <div class="tabs">
     120                <!-- TAB Tools -->
     121                <div class="tab privacy-tools">
     122                        <div id="poststuff">
     123                                <div id="post-body" class="metabox-holder columns-2">
     124                                        <!-- main content -->
     125                                        <div id="post-body-content">
     126                                                <div class="meta-box-sortables ui-sortable">
     127                                                        <div class="postbox">
     128                                                                <h2><?php esc_html_e( 'Privacy Policy Page' ); ?></h2>
     129                                                                <div class="inside">
     130                                                                        <?php
     131                                                                        if ( $privacy_policy_page_exists ) {
     132                                                                                $edit_href = add_query_arg(
     133                                                                                        array(
     134                                                                                                'post'   => $privacy_policy_page_id,
     135                                                                                                'action' => 'edit',
     136                                                                                        ),
     137                                                                                        admin_url( 'post.php' )
     138                                                                                );
     139                                                                                $view_href = get_permalink( $privacy_policy_page_id );
     140                                                                        ?>
     141                                                                        <p>
     142                                                                                <strong>
     143                                                                                        <?php
     144                                                                                        printf(
     145                                                                                                // translators: %1$s Edit url. %2$s View url.
     146                                                                                                __( '<a href="%1$s">Edit</a> or <a href="%2$s">view</a> your privacy policy.' ),
     147                                                                                                $edit_href,
     148                                                                                                $view_href
     149                                                                                        );
     150                                                                                        ?>
     151                                                                                </strong>
     152                                                                        </p>
     153                                                                        <?php
     154                                                                        }
     155                                                                        ?>
     156                                                                        <table class="form-table">
     157                                                                                <tr>
     158                                                                                        <th scope="row">
     159                                                                                                <label for="page_for_privacy_policy">
     160                                                                                                        <?php
    110161
    111         <h2><?php _e( 'Privacy policy page' ); ?></h2>
     162                                                                                                        if ( $privacy_policy_page_exists ) {
     163                                                                                                                esc_html_e( 'Select another page for your privacy policy' );
     164                                                                                                        } else {
     165                                                                                                                esc_html_e( 'Select an existing privacy policy page' );
     166                                                                                                        }
    112167
    113         <?php
    114         if ( $privacy_policy_page_exists ) {
    115                 $edit_href = add_query_arg(
    116                         array(
    117                                 'post'  => $privacy_policy_page_id,
    118                                 'action' => 'edit',
    119                         ),
    120                         admin_url( 'post.php' )
    121                 );
    122                 $view_href = get_permalink( $privacy_policy_page_id );
     168                                                                                                        ?>
     169                                                                                                </label>
     170                                                                                        </th>
     171                                                                                        <td id="privacy-policy-page">
     172                                                                                                <form method="post" action="">
     173                                                                                                        <input type="hidden" name="action" value="set-privacy-page" />
     174                                                                                                        <?php
    123175
    124                 ?>
    125                 <p><strong>
    126                         <?php
    127                         printf(
    128                                 __( '<a href="%1$s">Edit</a> or <a href="%2$s">view</a> your privacy policy.' ),
    129                                 $edit_href,
    130                                 $view_href
    131                         );
    132                         ?>
    133                 </strong></p>
    134                 <?php
    135         }
    136         ?>
     176                                                                                                        wp_dropdown_pages(
     177                                                                                                                array(
     178                                                                                                                        'name'              => 'page_for_privacy_policy',
     179                                                                                                                        'show_option_none'  => __( '&mdash; Select &mdash;' ),
     180                                                                                                                        'option_none_value' => '0',
     181                                                                                                                        'selected'          => $privacy_policy_page_id,
     182                                                                                                                        'post_status'       => array( 'draft', 'publish' ),
     183                                                                                                                )
     184                                                                                                        );
    137185
    138         <table class="form-table">
    139                 <tr>
    140                         <th scope="row">
    141                                 <label for="page_for_privacy_policy">
    142                                         <?php
     186                                                                                                        wp_nonce_field( 'set-privacy-page' );
     187                                                                                                        submit_button( __( 'Set Page' ), 'primary', 'submit', true, array( 'id' => 'set-page' ) );
    143188
    144                                         if ( $privacy_policy_page_exists ) {
    145                                                 _e( 'Select another page for your privacy policy' );
    146                                         } else {
    147                                                 _e( 'Select an existing privacy policy page' );
    148                                         }
     189                                                                                                        ?>
     190                                                                                                </form>
     191                                                                                        </td>
     192                                                                                </tr>
     193                                                                                <?php
     194                                                                                if ( ! $privacy_policy_page_exists ) {
     195                                                                                        ?>
     196                                                                                        <tr>
     197                                                                                                <th scope="row"><?php esc_html_e( 'Create new page for your privacy policy' ); ?></th>
     198                                                                                                <td>
     199                                                                                                        <form method="post" action="">
     200                                                                                                                <input type="hidden" name="action" value="create-privacy-page" />
     201                                                                                                                <?php
    149202
    150                                         ?>
    151                                 </label>
    152                         </th>
    153                         <td id="front-static-pages">
    154                                 <form method="post" action="">
    155                                         <input type="hidden" name="action" value="set-privacy-page" />
    156                                         <?php
     203                                                                                                                wp_nonce_field( 'create-privacy-page' );
     204                                                                                                                submit_button( __( 'Create Page' ), 'primary', 'submit', true, array( 'id' => 'create-page' ) );
    157205
    158                                         wp_dropdown_pages(
    159                                                 array(
    160                                                         'name'              => 'page_for_privacy_policy',
    161                                                         'show_option_none'  => __( '&mdash; Select &mdash;' ),
    162                                                         'option_none_value' => '0',
    163                                                         'selected'          => $privacy_policy_page_id,
    164                                                         'post_status'       => array( 'draft', 'publish' ),
    165                                                 )
    166                                         );
     206                                                                                                                ?>
     207                                                                                                        </form>
     208                                                                                                </td>
     209                                                                                        </tr>
     210                                                                                        <?php
     211                                                                                }
     212                                                                                ?>
     213                                                                        </table>
     214                                                                </div>
     215                                                        </div>
     216                                                </div>
     217                                                <div class="meta-box-sortables ui-sortable">
     218                                                        <div class="postbox">
     219                                                                <h2><?php esc_html_e( 'Title' ); ?></h2>
     220                                                                <div class="inside">
     221                                                                        Content Here
     222                                                                </div>
     223                                                        </div>
     224                                                </div>
     225                                        </div>
     226                                        <!-- sidebar -->
     227                                        <div id="postbox-container-1" class="postbox-container">
     228                                                <div class="meta-box-sortables">
     229                                                        <div class="postbox tools-information">
     230                                                                <h2>
     231                                                                        <?php esc_html_e( 'General Information' ); ?>
     232                                                                </h2>
     233                                                                <div class="inside">
     234                                                                        <p>
     235                                                                                Content Here
     236                                                                        </p>
     237                                                                </div>
     238                                                        </div>
     239                                                </div>
     240                                        </div>
     241                                </div>
     242                        </div>
     243                </div>
     244                <!-- TAB Requests -->
     245                <div class="tab privacy-requests">
    167246
    168                                         wp_nonce_field( 'set-privacy-page' );
    169                                         submit_button( __( 'Set Page' ), 'primary', 'submit', true, array( 'id' => 'set-page' ) );
     247                        <?php
     248                        // Requests come from wp_options as an array of users.
     249                        // If user is registered, use an array similar to WP_User, otherwise just the user email.
     250                        $requests = array(
     251                                array(
     252                                        'ID'        => 1,
     253                                        'full_name' => 'John Doe',
     254                                        'email'     => 'john@doe.com',
     255                                        'date'      => '2018/03/07',
     256                                        'type'      => 'Delete',
     257                                ),
     258                                array(
     259                                        'ID'        => 2,
     260                                        'full_name' => 'Jane Doe',
     261                                        'email'     => 'jane@doe.com',
     262                                        'date'      => '2018/03/03',
     263                                        'type'      => 'Anonymize',
     264                                ),
     265                        );
    170266
    171                                         ?>
    172                                 </form>
    173                         </td>
    174                 </tr>
    175                 <?php
     267                        $delete_requests = array_filter( $requests, function( $item ) {
     268                                return $item['type'] == 'Delete';
     269                        });
    176270
    177                 if ( ! $privacy_policy_page_exists ) {
     271                        $anonymize_requests = array_filter( $requests, function( $item ) {
     272                                return $item['type'] == 'Anonymize';
     273                        });
    178274                        ?>
    179                         <tr>
    180                                 <th scope="row"><?php _e( 'Create new page for your privacy policy' ); ?></th>
    181                                 <td>
    182                                         <form method="post" action="">
    183                                                 <input type="hidden" name="action" value="create-privacy-page" />
    184                                                 <?php
    185275
    186                                                 wp_nonce_field( 'create-privacy-page' );
    187                                                 submit_button( __( 'Create Page' ), 'primary', 'submit', true, array( 'id' => 'create-page' ) );
    188 
    189                                                 ?>
    190                                         </form>
    191                                 </td>
    192                         </tr>
    193                         <?php
    194                 }
    195 
    196                 ?>
    197         </table>
     276                        <?php if ( ! empty( $delete_requests ) ) : ?>
     277                                <h2><?php esc_html_e( 'Erasure Requests' ); ?></h2>
     278                                <table class="widefat">
     279                                        <thead>
     280                                        <tr>
     281                                                <th><?php esc_attr_e( 'ID' ); ?></th>
     282                                                <th><?php esc_attr_e( 'Full Name' ); ?></th>
     283                                                <th><?php esc_attr_e( 'Email' ); ?></th>
     284                                                <th><?php esc_attr_e( 'Date of Request' ); ?></th>
     285                                                <th><?php esc_attr_e( 'Review' ); ?></th>
     286                                                <th><?php esc_attr_e( 'Action' ); ?></th>
     287                                        </tr>
     288                                        </thead>
     289                                        <tbody>
     290                                        <?php foreach ( $delete_requests as $request ) : ?>
     291                                                <tr>
     292                                                        <td><?php echo esc_html( $request['ID'] ); ?></td>
     293                                                        <td><?php echo esc_html( $request['full_name'] ); ?></td>
     294                                                        <td><?php echo esc_html( $request['email'] ); ?></td>
     295                                                        <td><?php echo esc_html( $request['date'] ); ?></td>
     296                                                        <td>
     297                                                                <button class="button"><?php esc_html_e( 'Review Request' ); ?></button>
     298                                                        </td>
     299                                                        <td>
     300                                                                <button class="button button-primary"><?php esc_html_e( 'Erase' ); ?></button>
     301                                                        </td>
     302                                                </tr>
     303                                        <?php endforeach; ?>
     304                                        </tbody>
     305                                </table>
     306                        <?php endif ?>
     307                        <?php if ( ! empty( $anonymize_requests ) ) : ?>
     308                                <h2><?php esc_html_e( 'Anonymization Requests' ); ?></h2>
     309                                <table class="widefat">
     310                                        <thead>
     311                                        <tr>
     312                                                <th><?php esc_attr_e( 'ID' ); ?></th>
     313                                                <th><?php esc_attr_e( 'Full Name' ); ?></th>
     314                                                <th><?php esc_attr_e( 'Email' ); ?></th>
     315                                                <th><?php esc_attr_e( 'Date of Request' ); ?></th>
     316                                                <th><?php esc_attr_e( 'Review' ); ?></th>
     317                                                <th><?php esc_attr_e( 'Action' ); ?></th>
     318                                        </tr>
     319                                        </thead>
     320                                        <tbody>
     321                                        <?php foreach ( $anonymize_requests as $request ) : ?>
     322                                                <tr>
     323                                                        <td><?php echo esc_html( $request['ID'] ); ?></td>
     324                                                        <td><?php echo esc_html( $request['full_name'] ); ?></td>
     325                                                        <td><?php echo esc_html( $request['email'] ); ?></td>
     326                                                        <td><?php echo esc_html( $request['date'] ); ?></td>
     327                                                        <td>
     328                                                                <button class="button"><?php esc_html_e( 'Review Request' ); ?></button>
     329                                                        </td>
     330                                                        <td>
     331                                                                <button class="button button-primary"><?php esc_html_e( 'Anonymize' ); ?></button>
     332                                                        </td>
     333                                                </tr>
     334                                        <?php endforeach; ?>
     335                                        </tbody>
     336                                </table>
     337                        <?php endif ?>
     338                </div>
     339                <!-- TAB Privacy Policy Information -->
     340                <div class="tab privacy-information">
     341                        <div class="nav-tab-wrapper wp-clearfix">
     342                                <a href="#" class="nav-tab nav-tab-active" data-tab="privacy-information-core"><?php esc_html_e( 'WordPress Core' ); ?></a>
     343                                <a href="#" class="nav-tab" data-tab="privacy-information-plugin1"><?php esc_html_e( 'Plugin 1' ); ?></a>
     344                        </div>
     345                        <div class="tabs">
     346                                <div class="tab privacy-information-core">
     347                                        <div class="tab-content">
     348                                                <h2><?php esc_html_e( 'WordPress Core' ); ?></h2>
     349                                                <p>Content Here</p>
     350                                        </div>
     351                                </div>
     352                                <div class="tab privacy-information-plugin1">
     353                                        <div class="tab-content">
     354                                                <h2><?php esc_html_e( 'Plugin 1' ); ?></h2>
     355                                                <p>Content Here</p>
     356                                        </div>
     357                                </div>
     358                        </div>
     359                </div>
     360        </div>
    198361</div>
    199 
    200362<?php
    201363
    202364include( ABSPATH . 'wp-admin/admin-footer.php' );