Make WordPress Core

Changeset 43213


Ignore:
Timestamp:
05/10/2018 10:02:41 AM (9 years ago)
Author:
azaozz
Message:

Privacy: cleanup of the "Export Personal Data" and "Erase Personal Data" screens.

Props desrosj, xkon.
Merges [43212] to the 4.9 branch.
See #43929.

Location:
branches/4.9
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/4.9

  • branches/4.9/src/wp-admin/css/forms.css

    r43194 r43213  
    11331133}
    11341134
     1135.privacy_requests .request-results .notice {
     1136        margin: -2px 0 0;
     1137}
     1138
     1139.privacy_requests .request-results .notice p {
     1140        margin: 0.5em 0;
     1141}
     1142
     1143.request-results td {
     1144        padding: 0 0 1px;
     1145}
     1146
    11351147.status-label {
    11361148        font-weight: bold;
  • branches/4.9/src/wp-admin/includes/user.php

    r43192 r43213  
    623623                        );
    624624                }
    625 
    626625        } elseif ( isset( $_POST['action'] ) ) {
    627626                $action = isset( $_POST['action'] ) ? sanitize_key( wp_unslash( $_POST['action'] ) ) : ''; // WPCS: input var ok, CSRF ok.
    … …  
    720719                'post_status'    => 'request-pending',
    721720                'fields'         => 'ids',
    722                 'date_query' => array(
     721                'date_query'     => array(
    723722                        array(
    724723                                'column' => 'post_modified_gmt',
    … …  
    10721071         */
    10731072        protected function get_views() {
    1074                 $current_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ): '';
     1073                $current_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : '';
    10751074                $statuses       = _wp_privacy_statuses();
    10761075                $views          = array();
    … …  
    11111110                $action      = $this->current_action();
    11121111                $request_ids = isset( $_REQUEST['request_id'] ) ? wp_parse_id_list( wp_unslash( $_REQUEST['request_id'] ) ) : array(); // WPCS: input var ok, CSRF ok.
    1113                 $count = 0;
     1112                $count       = 0;
    11141113
    11151114                if ( $request_ids ) {
    … …  
    11281127                                        'bulk_action',
    11291128                                        'bulk_action',
     1129                                        /* translators: %d: number of requests */
    11301130                                        sprintf( _n( 'Deleted %d request', 'Deleted %d requests', $count ), $count ),
    11311131                                        'updated'
    … …  
    11441144                                        'bulk_action',
    11451145                                        'bulk_action',
     1146                                        /* translators: %d: number of requests */
    11461147                                        sprintf( _n( 'Re-sent %d request', 'Re-sent %d requests', $count ), $count ),
    11471148                                        'updated'
    … …  
    11731174                        'post_name__in'  => array( $this->request_type ),
    11741175                        'posts_per_page' => $posts_per_page,
    1175                         'offset'         => isset( $_REQUEST['paged'] ) ? max( 0, absint( $_REQUEST['paged'] ) - 1 ) * $posts_per_page: 0,
     1176                        'offset'         => isset( $_REQUEST['paged'] ) ? max( 0, absint( $_REQUEST['paged'] ) - 1 ) * $posts_per_page : 0,
    11761177                        'post_status'    => 'any',
    11771178                        's'              => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : '',
    … …  
    12651266
    12661267                if ( $time_diff >= 0 && $time_diff < DAY_IN_SECONDS ) {
     1268                        /* translators: human readable timestamp */
    12671269                        return sprintf( __( '%s ago' ), human_time_diff( $timestamp ) );
    12681270                }
    … …  
    13721374                $nonce           = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
    13731375
    1374                 $download_data_markup = '<div class="export_personal_data" ' .
     1376                $download_data_markup = '<div class="export-personal-data" ' .
    13751377                        'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' .
    13761378                        'data-request-id="' . esc_attr( $request_id ) . '" ' .
    … …  
    13781380                        '">';
    13791381
    1380                 $download_data_markup .= '<span class="export_personal_data_idle"><a href="#" >' . __( 'Download Personal Data' ) . '</a></span>' .
    1381                         '<span style="display:none" class="export_personal_data_processing" >' . __( 'Downloading Data...' ) . '</span>' .
    1382                         '<span style="display:none" class="export_personal_data_success"><a href="#" >' . __( 'Download Personal Data Again' ) . '</a></span>' .
    1383                         '<span style="display:none" class="export_personal_data_failed">' . __( 'Download has failed.' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>';
     1382                $download_data_markup .= '<span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download Personal Data' ) . '</button></span>' .
     1383                        '<span style="display:none" class="export-personal-data-processing" >' . __( 'Downloading Data...' ) . '</span>' .
     1384                        '<span style="display:none" class="export-personal-data-success"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download Personal Data Again' ) . '</button></span>' .
     1385                        '<span style="display:none" class="export-personal-data-failed">' . __( 'Download has failed.' ) . ' <button type="button" class="button-link">' . __( 'Retry' ) . '</button></span>';
    13841386
    13851387                $download_data_markup .= '</div>';
    13861388
    13871389                $row_actions = array(
    1388                         'download_data' => $download_data_markup,
     1390                        'download-data' => $download_data_markup,
    13891391                );
    13901392
    … …  
    14121414                                $nonce           = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
    14131415
    1414                                 echo '<div class="export_personal_data" ' .
     1416                                echo '<div class="export-personal-data" ' .
    14151417                                        'data-send-as-email="1" ' .
    14161418                                        'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' .
    … …  
    14201422
    14211423                                ?>
    1422                                 <span class="export_personal_data_idle"><a class="button" href="#" ><?php _e( 'Send Export Link' ); ?></a></span>
    1423                                 <span style="display:none" class="export_personal_data_processing button updating-message" ><?php _e( 'Sending Email...' ); ?></span>
    1424                                 <span style="display:none" class="export_personal_data_success success-message" ><?php _e( 'Email sent.' ); ?></span>
    1425                                 <span style="display:none" class="export_personal_data_failed"><?php _e( 'Email could not be sent.' ); ?> <a class="button" href="#" ><?php _e( 'Retry' ); ?></a></span>
     1424                                <span class="export-personal-data-idle"><button type="button" class="button export-personal-data-handle"><?php _e( 'Email Data' ); ?></button></span>
     1425                                <span style="display:none" class="export-personal-data-processing button updating-message" ><?php _e( 'Sending Email...' ); ?></span>
     1426                                <span style="display:none" class="export-personal-data-success success-message" ><?php _e( 'Email sent.' ); ?></span>
     1427                                <span style="display:none" class="export-personal-data-failed"><?php _e( 'Email could not be sent.' ); ?> <button type="button" class="button export-personal-data-handle"><?php _e( 'Retry' ); ?></button></span>
    14261428                                <?php
    14271429
    … …  
    14331435                        case 'request-completed':
    14341436                                echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array(
    1435                                         'action' => 'delete',
    1436                                         'request_id' => array( $item->ID )
    1437                                 ), admin_url( 'tools.php?page=export_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>';
     1437                                        'action'     => 'delete',
     1438                                        'request_id' => array( $item->ID ),
     1439                                ), admin_url( 'tools.php?page=export_personal_data' ) ), 'bulk-privacy_requests' ) ) . '" class="button">' . esc_html__( 'Remove request' ) . '</a>';
    14381440                                break;
    14391441                }
    … …  
    14841486                        $nonce         = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
    14851487
    1486                         $remove_data_markup = '<div class="remove_personal_data force_remove_personal_data" ' .
     1488                        $remove_data_markup = '<div class="remove-personal-data force-remove-personal-data" ' .
    14871489                                'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' .
    14881490                                'data-request-id="' . esc_attr( $request_id ) . '" ' .
    … …  
    14901492                                '">';
    14911493
    1492                         $remove_data_markup .= '<span class="remove_personal_data_idle"><a href="#" >' . __( 'Force Erase Personal Data' ) . '</a></span>' .
    1493                                 '<span style="display:none" class="remove_personal_data_processing" >' . __( 'Erasing Data...' ) . '</span>' .
    1494                                 '<span style="display:none" class="remove_personal_data_failed">' . __( 'Force Erase has failed.' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>';
     1494                        $remove_data_markup .= '<span class="remove-personal-data-idle"><button type="button" class="button-link remove-personal-data-handle">' . __( 'Force Erase Personal Data' ) . '</button></span>' .
     1495                                '<span style="display:none" class="remove-personal-data-processing" >' . __( 'Erasing Data...' ) . '</span>' .
     1496                                '<span style="display:none" class="remove-personal-data-failed">' . __( 'Force Erase has failed.' ) . ' <button type="button" class="button-link remove-personal-data-handle">' . __( 'Retry' ) . '</button></span>';
    14951497
    14961498                        $remove_data_markup .= '</div>';
    14971499
    14981500                        $row_actions = array(
    1499                                 'remove_data' => $remove_data_markup,
     1501                                'remove-data' => $remove_data_markup,
    15001502                        );
    15011503                }
    … …  
    15241526                                $nonce         = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
    15251527
    1526                                 echo '<div class="remove_personal_data" ' .
     1528                                echo '<div class="remove-personal-data" ' .
    15271529                                        'data-force-erase="1" ' .
    15281530                                        'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' .
    … …  
    15321534
    15331535                                ?>
    1534                                 <span class="remove_personal_data_idle"><a class="button" href="#" ><?php _e( 'Erase Personal Data' ); ?></a></span>
    1535                                 <span style="display:none" class="remove_personal_data_processing button updating-message" ><?php _e( 'Erasing Data...' ); ?></span>
    1536                                 <span style="display:none" class="remove_personal_data_failed"><?php _e( 'Erasing Data has failed.' ); ?> <a class="button" href="#" ><?php _e( 'Retry' ); ?></a></span>
     1536                                <span class="remove-personal-data-idle"><button type="button" class="button remove-personal-data-handle"><?php _e( 'Erase Personal Data' ); ?></button></span>
     1537                                <span style="display:none" class="remove-personal-data-processing button updating-message" ><?php _e( 'Erasing Data...' ); ?></span>
     1538                                <span style="display:none" class="remove-personal-data-failed"><?php _e( 'Erasing Data has failed.' ); ?> <button type="button" class="button remove-personal-data-handle"><?php _e( 'Retry' ); ?></button></span>
    15371539                                <?php
    15381540
    … …  
    15451547                        case 'request-completed':
    15461548                                echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array(
    1547                                         'action' => 'delete',
     1549                                        'action'     => 'delete',
    15481550                                        'request_id' => array( $item->ID ),
    1549                                 ), admin_url( 'tools.php?page=remove_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>';
     1551                                ), admin_url( 'tools.php?page=remove_personal_data' ) ), 'bulk-privacy_requests' ) ) . '" class="button">' . esc_html__( 'Remove request' ) . '</a>';
    15501552                                break;
    15511553                }
  • branches/4.9/src/wp-admin/js/xfn.js

    r43204 r43213  
    2121        var strings = window.privacyToolsL10n || {};
    2222
    23         function set_action_state( $action, state ) {
     23        function setActionState( $action, state ) {
    2424                $action.children().hide();
    2525                $action.children( '.' + state ).show();
    … …  
    3333
    3434        function appendResultsAfterRow( $requestRow, classes, summaryMessage, additionalMessages ) {
     35                var itemList = '';
     36
    3537                clearResultsAfterRow( $requestRow );
    3638
    37                 var itemList = '';
    3839                if ( additionalMessages.length ) {
    3940                        $.each( additionalMessages, function( index, value ) {
    4041                                itemList = itemList + '<li>' + value + '</li>';
    41                         } );
     42                        });
    4243                        itemList = '<ul>' + itemList + '</ul>';
    4344                }
    … …  
    5152                                '</td>' +
    5253                                '</tr>';
    53                 } );
     54                });
    5455        }
    5556
    56         $( '.export_personal_data a' ).click( function( event ) {
     57        $( '.export-personal-data-handle' ).click( function( event ) {
     58
     59                var $this          = $( this ),
     60                        $action        = $this.parents( '.export-personal-data' ),
     61                        $requestRow    = $this.parents( 'tr' ),
     62                        requestID      = $action.data( 'request-id' ),
     63                        nonce          = $action.data( 'nonce' ),
     64                        exportersCount = $action.data( 'exporters-count' ),
     65                        sendAsEmail    = $action.data( 'send-as-email' ) ? true : false;
     66
    5767                event.preventDefault();
    5868                event.stopPropagation();
    5969
    60                 var $this          = $( this );
    61                 var $action        = $this.parents( '.export_personal_data' );
    62                 var $requestRow    = $this.parents( 'tr' );
    63                 var requestID      = $action.data( 'request-id' );
    64                 var nonce          = $action.data( 'nonce' );
    65                 var exportersCount = $action.data( 'exporters-count' );
    66                 var sendAsEmail    = $action.data( 'send-as-email' ) ? true : false;
    67 
    6870                $action.blur();
    6971                clearResultsAfterRow( $requestRow );
    7072
    71                 function on_export_done_success( zipUrl ) {
    72                         set_action_state( $action, 'export_personal_data_success' );
     73                function onExportDoneSuccess( zipUrl ) {
     74                        setActionState( $action, 'export-personal-data-success' );
    7375                        if ( 'undefined' !== typeof zipUrl ) {
    7476                                window.location = zipUrl;
    7577                        } else if ( ! sendAsEmail ) {
    76                                 on_export_failure( strings.noExportFile );
    77                         }
    78                 }
    79 
    80                 function on_export_failure( errorMessage ) {
    81                         set_action_state( $action, 'export_personal_data_failed' );
     78                                onExportFailure( strings.noExportFile );
     79                        }
     80                }
     81
     82                function onExportFailure( errorMessage ) {
     83                        setActionState( $action, 'export-personal-data-failed' );
    8284                        if ( errorMessage ) {
    8385                                appendResultsAfterRow( $requestRow, 'notice-error', strings.exportError, [ errorMessage ] );
    … …  
    8587                }
    8688
    87                 function do_next_export( exporterIndex, pageIndex ) {
     89                function doNextExport( exporterIndex, pageIndex ) {
    8890                        $.ajax(
    8991                                {
    … …  
    100102                                }
    101103                        ).done( function( response ) {
     104                                var responseData = response.data;
     105
    102106                                if ( ! response.success ) {
     107
    103108                                        // e.g. invalid request ID
    104                                         on_export_failure( response.data );
     109                                        onExportFailure( response.data );
    105110                                        return;
    106111                                }
    107                                 var responseData = response.data;
     112
    108113                                if ( ! responseData.done ) {
    109                                         setTimeout( do_next_export( exporterIndex, pageIndex + 1 ) );
     114                                        setTimeout( doNextExport( exporterIndex, pageIndex + 1 ) );
    110115                                } else {
    111116                                        if ( exporterIndex < exportersCount ) {
    112                                                 setTimeout( do_next_export( exporterIndex + 1, 1 ) );
     117                                                setTimeout( doNextExport( exporterIndex + 1, 1 ) );
    113118                                        } else {
    114                                                 on_export_done_success( responseData.url );
     119                                                onExportDoneSuccess( responseData.url );
    115120                                        }
    116121                                }
    117                         } ).fail( function( jqxhr, textStatus, error ) {
     122                        }).fail( function( jqxhr, textStatus, error ) {
     123
    118124                                // e.g. Nonce failure
    119                                 on_export_failure( error );
    120                         } );
     125                                onExportFailure( error );
     126                        });
    121127                }
    122128
    123129                // And now, let's begin
    124                 set_action_state( $action, 'export_personal_data_processing' );
    125                 do_next_export( 1, 1 );
    126         } );
    127 
    128         $( '.remove_personal_data a' ).click( function( event ) {
    129                 event.preventDefault();
     130                setActionState( $action, 'export-personal-data-processing' );
     131                doNextExport( 1, 1 );
     132        });
     133
     134        $( '.remove-personal-data-handle' ).click( function( event ) {
     135
     136                var $this         = $( this ),
     137                        $action       = $this.parents( '.remove-personal-data' ),
     138                        $requestRow   = $this.parents( 'tr' ),
     139                        requestID     = $action.data( 'request-id' ),
     140                        nonce         = $action.data( 'nonce' ),
     141                        erasersCount  = $action.data( 'erasers-count' ),
     142                        hasRemoved    = false,
     143                        hasRetained   = false,
     144                        messages      = [];
     145
    130146                event.stopPropagation();
    131 
    132                 var $this         = $( this );
    133                 var $action       = $this.parents( '.remove_personal_data' );
    134                 var $requestRow   = $this.parents( 'tr' );
    135                 var requestID     = $action.data( 'request-id' );
    136                 var nonce         = $action.data( 'nonce' );
    137                 var erasersCount  = $action.data( 'erasers-count' );
    138 
    139                 var hasRemoved    = false;
    140                 var hasRetained   = false;
    141                 var messages      = [];
    142147
    143148                $action.blur();
    144149                clearResultsAfterRow( $requestRow );
    145150
    146                 function on_erasure_done_success() {
    147                         set_action_state( $action, 'remove_personal_data_idle' );
     151                function onErasureDoneSuccess() {
    148152                        var summaryMessage = strings.noDataFound;
    149153                        var classes = 'notice-success';
     154
     155                        setActionState( $action, 'remove-personal-data-idle' );
     156
    150157                        if ( false === hasRemoved ) {
    151158                                if ( false === hasRetained ) {
    … …  
    166173                }
    167174
    168                 function on_erasure_failure() {
    169                         set_action_state( $action, 'remove_personal_data_failed' );
     175                function onErasureFailure() {
     176                        setActionState( $action, 'remove-personal-data-failed' );
    170177                        appendResultsAfterRow( $requestRow, 'notice-error', strings.removalError, [] );
    171178                }
    172179
    173                 function do_next_erasure( eraserIndex, pageIndex ) {
    174                         $.ajax( {
     180                function doNextErasure( eraserIndex, pageIndex ) {
     181                        $.ajax({
    175182                                url: window.ajaxurl,
    176183                                data: {
    … …  
    182189                                },
    183190                                method: 'post'
    184                         } ).done( function( response ) {
     191                        }).done( function( response ) {
     192                                var responseData = response.data;
     193
    185194                                if ( ! response.success ) {
    186                                         on_erasure_failure();
     195                                        onErasureFailure();
    187196                                        return;
    188197                                }
    189                                 var responseData = response.data;
    190198                                if ( responseData.items_removed ) {
    191199                                        hasRemoved = hasRemoved || responseData.items_removed;
    … …  
    198206                                }
    199207                                if ( ! responseData.done ) {
    200                                         setTimeout( do_next_erasure( eraserIndex, pageIndex + 1 ) );
     208                                        setTimeout( doNextErasure( eraserIndex, pageIndex + 1 ) );
    201209                                } else {
    202210                                        if ( eraserIndex < erasersCount ) {
    203                                                 setTimeout( do_next_erasure( eraserIndex + 1, 1 ) );
     211                                                setTimeout( doNextErasure( eraserIndex + 1, 1 ) );
    204212                                        } else {
    205                                                 on_erasure_done_success();
     213                                                onErasureDoneSuccess();
    206214                                        }
    207215                                }
    208                         } ).fail( function() {
    209                                 on_erasure_failure();
    210                         } );
     216                        }).fail( function() {
     217                                onErasureFailure();
     218                        });
    211219                }
    212220
    213221                // And now, let's begin
    214                 set_action_state( $action, 'remove_personal_data_processing' );
    215 
    216                 do_next_erasure( 1, 1 );
    217         } );
    218 } );
     222                setActionState( $action, 'remove-personal-data-processing' );
     223
     224                doNextErasure( 1, 1 );
     225        });
     226});
    219227
    220228( function( $ ) {
     229
    221230        // Privacy policy page, copy button.
    222231        $( document ).on( 'click', function( event ) {
    … …  
    249258        });
    250259
    251 } )( jQuery );
     260} ( jQuery ) );
  • branches/4.9/src/wp-includes/user.php

    r43200 r43213  
    28852885
    28862886        if ( $request && in_array( $request->action_name, _wp_privacy_action_request_types(), true ) ) {
    2887                 $message = '<p class="message">' . __( 'Action has been confirmed.' ) . '</p>';
     2887                $message  = '<p class="message">' . __( 'Action has been confirmed.' ) . '</p>';
    28882888                $message .= __( 'The site administrator has been notified and will fulfill your request as soon as possible.' );
    28892889        }
    … …  
    29182918
    29192919        $user    = get_user_by( 'email', $email_address );
    2920         $user_id = $user && ! is_wp_error( $user ) ? $user->ID: 0;
     2920        $user_id = $user && ! is_wp_error( $user ) ? $user->ID : 0;
    29212921
    29222922        // Check for duplicates.
Note: See TracChangeset for help on using the changeset viewer.