Make WordPress Core

Ticket #43481: 43481.6.diff

File 43481.6.diff, 17.1 KB (added by xkon, 7 years ago)

allendav / birgire / various fixes

  • 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
     1096body.privacy-php .tab,
     1097body.privacy-php .privacy-information .tab {
     1098        display: none;
     1099}
     1100
     1101body.privacy-php .tab:first-child,
     1102body.privacy-php .privacy-information .tab:first-child {
     1103        display: block;
     1104}
     1105
     1106body.privacy-php .create-privacy-policy-box .submit {
     1107        margin-top: 0;
     1108}
     1109
     1110body.privacy-php .tab.privacy-tools #post-body-content .inside {
     1111        overflow-x: auto;
     1112}
     1113
     1114body.privacy-php .privacy-information-toc-wrapper {
     1115        padding: 10px 0 10px 0;
     1116}
     1117
     1118body.privacy-php .privacy-information-toc.active {
     1119        text-decoration: none;
     1120        color: #000;
     1121}
     1122
    10721123/* =Media Queries
    10731124-------------------------------------------------------------- */
    10741125
  • 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 .privacy-information-toc' ).on( 'click', function( e ){
     35                e.preventDefault();
     36
     37                var target = '.' + $( this ).data( 'tab' );
     38                $( target ).show();
     39                $( target ).siblings().hide();
     40                $( this ).addClass( 'active' );
     41                $( this ).siblings().removeClass( 'active' );
     42        });
    2243});
  • 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-information"><?php esc_html_e( 'Privacy Policy Information' ); ?></a>
     116        </div>
     117        <!-- TABS -->
     118        <div class="tabs">
     119                <!-- TAB Tools -->
     120                <div class="tab privacy-tools">
     121                        <div id="poststuff">
     122                                <div id="post-body" class="metabox-holder columns-2">
     123                                        <!-- main content -->
     124                                        <div id="post-body-content">
     125                                                <div class="meta-box-sortables ui-sortable">
     126                                                        <?php
     127                                                        // Requests come from wp_options as an array of users.
     128                                                        // If user is registered, use an array similar to WP_User, otherwise just the user email.
     129                                                        $requests = array(
     130                                                                array(
     131                                                                        'ID'        => 1,
     132                                                                        'full_name' => 'John Doe',
     133                                                                        'email'     => 'john@doe.com',
     134                                                                        'date'      => '2018/03/07',
     135                                                                        'type'      => 'delete',
     136                                                                ),
     137                                                                array(
     138                                                                        'ID'        => 2,
     139                                                                        'full_name' => 'John Doe',
     140                                                                        'email'     => 'john@doe.com',
     141                                                                        'date'      => '2018/03/07',
     142                                                                        'type'      => 'delete',
     143                                                                ),
     144                                                                array(
     145                                                                        'ID'        => 3,
     146                                                                        'full_name' => 'John Doe',
     147                                                                        'email'     => 'john@doe.com',
     148                                                                        'date'      => '2018/03/07',
     149                                                                        'type'      => 'delete',
     150                                                                ),
     151                                                        );
    110152
    111         <h2><?php _e( 'Privacy policy page' ); ?></h2>
     153                                                        $delete_requests = array_filter( $requests, function( $item ) {
     154                                                                return $item['type'] == 'delete';
     155                                                        });
    112156
    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 );
     157                                                        $export_requests = array_filter( $requests, function( $item ) {
     158                                                                return $item['type'] == 'export';
     159                                                        });
     160                                                        ?>
     161                                                        <div class="postbox">
     162                                                                <h2><?php esc_html_e( 'Erasure / Anonymization Requests' ); ?></h2>
     163                                                                <div class="inside">
     164                                                                <?php if ( ! empty( $delete_requests ) ) { ?>
     165                                                                        <table class="widefat striped">
     166                                                                                <thead>
     167                                                                                <tr>
     168                                                                                        <th><?php esc_html_e( 'ID' ); ?></th>
     169                                                                                        <th><?php esc_html_e( 'Full Name' ); ?></th>
     170                                                                                        <th><?php esc_html_e( 'Email' ); ?></th>
     171                                                                                        <th><?php esc_html_e( 'Date of Request' ); ?></th>
     172                                                                                        <th><?php esc_html_e( 'Review' ); ?></th>
     173                                                                                        <th><?php esc_html_e( 'Action' ); ?></th>
     174                                                                                </tr>
     175                                                                                </thead>
     176                                                                                <tbody>
     177                                                                                <?php foreach ( $delete_requests as $request ) : ?>
     178                                                                                        <tr>
     179                                                                                                <td><?php echo esc_html( $request['ID'] ); ?></td>
     180                                                                                                <td><?php echo esc_html( $request['full_name'] ); ?></td>
     181                                                                                                <td><?php echo esc_html( $request['email'] ); ?></td>
     182                                                                                                <td><?php echo esc_html( $request['date'] ); ?></td>
     183                                                                                                <td>
     184                                                                                                        <button class="button"><?php esc_html_e( 'Review Request' ); ?></button>
     185                                                                                                </td>
     186                                                                                                <td>
     187                                                                                                        <button class="button button-primary"><?php esc_html_e( 'Erase / Anonymize' ); ?></button>
     188                                                                                                </td>
     189                                                                                        </tr>
     190                                                                                <?php endforeach; ?>
     191                                                                                </tbody>
     192                                                                        </table>
     193                                                                        <?php } else { ?>
     194                                                                                <strong><?php esc_html_e( 'There are currently no Erasure / Anonymization Requests.' ); ?></strong>
     195                                                                        <?php } ?>
     196                                                                </div>
     197                                                        </div>
     198                                                        <div class="postbox">
     199                                                                <h2><?php esc_html_e( 'Export Requests' ); ?></h2>
     200                                                                <div class="inside">
     201                                                                        <?php if ( ! empty( $export_requests ) ) { ?>
     202                                                                        <table class="widefat striped">
     203                                                                                <thead>
     204                                                                                <tr>
     205                                                                                        <th><?php esc_html_e( 'ID' ); ?></th>
     206                                                                                        <th><?php esc_html_e( 'Full Name' ); ?></th>
     207                                                                                        <th><?php esc_html_e( 'Email' ); ?></th>
     208                                                                                        <th><?php esc_html_e( 'Date of Request' ); ?></th>
     209                                                                                        <th><?php esc_html_e( 'Review' ); ?></th>
     210                                                                                        <th><?php esc_html_e( 'Action' ); ?></th>
     211                                                                                </tr>
     212                                                                                </thead>
     213                                                                                <tbody>
     214                                                                                <?php foreach ( $export_requests as $request ) : ?>
     215                                                                                        <tr>
     216                                                                                                <td><?php echo esc_html( $request['ID'] ); ?></td>
     217                                                                                                <td><?php echo esc_html( $request['full_name'] ); ?></td>
     218                                                                                                <td><?php echo esc_html( $request['email'] ); ?></td>
     219                                                                                                <td><?php echo esc_html( $request['date'] ); ?></td>
     220                                                                                                <td>
     221                                                                                                        <button class="button"><?php esc_html_e( 'Review Request' ); ?></button>
     222                                                                                                </td>
     223                                                                                                <td>
     224                                                                                                        <button class="button button-primary"><?php esc_html_e( 'Export' ); ?></button>
     225                                                                                                </td>
     226                                                                                        </tr>
     227                                                                                <?php endforeach; ?>
     228                                                                                </tbody>
     229                                                                        </table>
     230                                                                        <?php } else { ?>
     231                                                                                <strong><?php esc_html_e( 'There are currently no Export Requests.' ); ?></strong>
     232                                                                        <?php } ?>
     233                                                                </div>
     234                                                        </div>
     235                                                </div>
     236                                        </div>
     237                                        <!-- sidebar -->
     238                                        <div id="postbox-container-1" class="postbox-container">
     239                                                <!-- privacy policy page box -->
     240                                                <div class="meta-box-sortables">
     241                                                        <div class="postbox create-privacy-policy-box">
     242                                                                <h2><?php esc_html_e( 'Privacy Policy Page' ); ?></h2>
     243                                                                <div class="inside">
     244                                                                        <?php
     245                                                                        if ( $privacy_policy_page_exists ) {
     246                                                                                $edit_href = add_query_arg(
     247                                                                                        array(
     248                                                                                                'post'   => $privacy_policy_page_id,
     249                                                                                                'action' => 'edit',
     250                                                                                        ),
     251                                                                                        admin_url( 'post.php' )
     252                                                                                );
     253                                                                                $view_href = get_permalink( $privacy_policy_page_id );
     254                                                                        ?>
     255                                                                        <p>
     256                                                                                <strong>
     257                                                                                        <?php
     258                                                                                        printf(
     259                                                                                                // translators: %1$s Edit url. %2$s View url.
     260                                                                                                __( '<a href="%1$s">Edit</a> or <a href="%2$s">view</a> your privacy policy.' ),
     261                                                                                                esc_url( $edit_href ),
     262                                                                                                esc_url( $view_href )
     263                                                                                        );
     264                                                                                        ?>
     265                                                                                </strong>
     266                                                                        </p>
     267                                                                        <?php
     268                                                                        }
     269                                                                        ?>
     270                                                                        <form method="post" action="">
     271                                                                                <input type="hidden" name="action" value="set-privacy-page" />
     272                                                                                <p class="post-attributes-label-wrapper">
     273                                                                                        <label class="post-attributes-label" for="page_for_privacy_policy">
     274                                                                                                <?php
     275                                                                                                if ( $privacy_policy_page_exists ) {
     276                                                                                                        esc_html_e( 'Select another page for your privacy policy' );
     277                                                                                                } else {
     278                                                                                                        esc_html_e( 'Select an existing privacy policy page' );
     279                                                                                                }
     280                                                                                                ?>
     281                                                                                        </label>
     282                                                                                </p>
     283                                                                                <?php
     284                                                                                wp_dropdown_pages(
     285                                                                                        array(
     286                                                                                                'name'              => 'page_for_privacy_policy',
     287                                                                                                'show_option_none'  => __( '&mdash; Select &mdash;' ),
     288                                                                                                'option_none_value' => '0',
     289                                                                                                'selected'          => $privacy_policy_page_id,
     290                                                                                                'post_status'       => array( 'draft', 'publish' ),
     291                                                                                        )
     292                                                                                );
    123293
    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         ?>
     294                                                                                wp_nonce_field( 'set-privacy-page' );
     295                                                                                submit_button( __( 'Set Page' ), 'primary', 'submit', true, array( 'id' => 'set-page' ) );
     296                                                                                ?>
     297                                                                        </form>
     298                                                                        <?php
     299                                                                        if ( ! $privacy_policy_page_exists ) {
     300                                                                        ?>
     301                                                                        <form method="post" action="">
     302                                                                                <p class="post-attributes-label-wrapper">
     303                                                                                        <strong><?php esc_html_e( 'Create new page for your privacy policy' ); ?></strong>
     304                                                                                </p>
     305                                                                                <input type="hidden" name="action" value="create-privacy-page" />
     306                                                                                <?php
    137307
    138         <table class="form-table">
    139                 <tr>
    140                         <th scope="row">
    141                                 <label for="page_for_privacy_policy">
    142                                         <?php
     308                                                                                wp_nonce_field( 'create-privacy-page' );
     309                                                                                submit_button( __( 'Create Page' ), 'primary', 'submit', true, array( 'id' => 'create-page' ) );
    143310
    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                                         }
    149 
    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
    157 
    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                                         );
    167 
    168                                         wp_nonce_field( 'set-privacy-page' );
    169                                         submit_button( __( 'Set Page' ), 'primary', 'submit', true, array( 'id' => 'set-page' ) );
    170 
    171                                         ?>
    172                                 </form>
    173                         </td>
    174                 </tr>
    175                 <?php
    176 
    177                 if ( ! $privacy_policy_page_exists ) {
    178                         ?>
    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
    185 
    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>
     311                                                                                ?>
     312                                                                        </form>
     313                                                                        <?php
     314                                                                        }
     315                                                                        ?>
     316                                                                </div>
     317                                                        </div>
     318                                                </div>
     319                                                <!-- manual erase / anonymize box -->
     320                                                <div class="meta-box-sortables">
     321                                                        <div class="postbox">
     322                                                                <h2>
     323                                                                        <?php esc_html_e( 'Erase / Anonymize Data' ); ?>
     324                                                                </h2>
     325                                                                <div class="inside">
     326                                                                                <form method="post" action="">
     327                                                                                        <p class="post-attributes-label-wrapper">
     328                                                                                                <label class="post-attributes-label" for="manual_erase_email">
     329                                                                                                        E-mail
     330                                                                                                </label>
     331                                                                                        </p>
     332                                                                                        <input type="text" name="action" name="manual_erase_email" id="manual_erase_email" value="" />
     333                                                                                        <?php
     334                                                                                        submit_button( __( 'Erase / Anonymize' ), 'primary', 'submit', true, array( 'id' => 'delete' ) );
     335                                                                                        ?>
     336                                                                                </form>
     337                                                                </div>
     338                                                        </div>
     339                                                </div>
     340                                                <!-- manual export box -->
     341                                                <div class="meta-box-sortables">
     342                                                        <div class="postbox">
     343                                                                <h2>
     344                                                                        <?php esc_html_e( 'Export Data' ); ?>
     345                                                                </h2>
     346                                                                <div class="inside">
     347                                                                                <form method="post" action="">
     348                                                                                        <p class="post-attributes-label-wrapper">
     349                                                                                                <label class="post-attributes-label" for="manual_export_email">
     350                                                                                                        E-mail
     351                                                                                                </label>
     352                                                                                        </p>
     353                                                                                        <input type="text" name="action" name="manual_export_email" id="manual_export_email" value="" />
     354                                                                                        <?php
     355                                                                                        submit_button( __( 'Export' ), 'primary', 'submit', true, array( 'id' => 'export' ) );
     356                                                                                        ?>
     357                                                                                </form>
     358                                                                </div>
     359                                                        </div>
     360                                                </div>
     361                                                <!-- information box -->
     362                                                <div class="meta-box-sortables">
     363                                                        <div class="postbox tools-information">
     364                                                                <h2>
     365                                                                        <?php esc_html_e( 'General Information' ); ?>
     366                                                                </h2>
     367                                                                <div class="inside">
     368                                                                        <p>
     369                                                                                Content Here
     370                                                                        </p>
     371                                                                </div>
     372                                                        </div>
     373                                                </div>
     374                                        </div>
     375                                </div>
     376                        </div>
     377                </div>
     378                <!-- TAB Privacy Policy Information -->
     379                <div class="tab privacy-information">
     380                        <div class="privacy-information-toc-wrapper">
     381                                <a href="#" class="privacy-information-toc active" data-tab="privacy-information-core"><?php esc_html_e( 'WordPress' ); ?></a> |
     382                                <a href="#" class="privacy-information-toc" data-tab="privacy-information-plugin1"><?php esc_html_e( 'Plugin 1' ); ?></a>
     383                        </div>
     384                        <div class="tabs">
     385                                <div class="tab privacy-information-core">
     386                                        <div class="tab-content">
     387                                                <h2><?php esc_html_e( 'WordPress' ); ?></h2>
     388                                                <p>Content Here</p>
     389                                        </div>
     390                                </div>
     391                                <div class="tab privacy-information-plugin1">
     392                                        <div class="tab-content">
     393                                                <h2><?php esc_html_e( 'Plugin 1' ); ?></h2>
     394                                                <p>Content Here</p>
     395                                        </div>
     396                                </div>
     397                        </div>
     398                </div>
     399        </div>
    198400</div>
    199 
    200401<?php
    201402
    202403include( ABSPATH . 'wp-admin/admin-footer.php' );