WordPress.org

Make WordPress Core

Changeset 49258


Ignore:
Timestamp:
10/20/2020 09:05:34 PM (5 months ago)
Author:
helen
Message:

Privacy: Add "Mark as completed" action.

Props garrett-eclipse, ocean90, joostdevalk, mista-flo, helen.
Fixes #46619.

Location:
trunk/src/wp-admin/includes
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php

    r47247 r49258  
    4848        $exporters       = apply_filters( 'wp_privacy_personal_data_exporters', array() );
    4949        $exporters_count = count( $exporters );
     50        $status          = $item->status;
    5051        $request_id      = $item->ID;
    5152        $nonce           = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
    5253
    53         $download_data_markup = '<div class="export-personal-data" ' .
     54        $download_data_markup = '<span class="export-personal-data" ' .
    5455            'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' .
    5556            'data-request-id="' . esc_attr( $request_id ) . '" ' .
     
    5758            '">';
    5859
    59         $download_data_markup .= '<span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download Personal Data' ) . '</button></span>' .
    60             '<span class="export-personal-data-processing hidden">' . __( 'Downloading Data...' ) . ' <span class="export-progress"></span></span>' .
    61             '<span class="export-personal-data-success hidden"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download Personal Data Again' ) . '</button></span>' .
     60        $download_data_markup .= '<span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download personal data' ) . '</button></span>' .
     61            '<span class="export-personal-data-processing hidden">' . __( 'Downloading data...' ) . ' <span class="export-progress"></span></span>' .
     62            '<span class="export-personal-data-success hidden"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download personal data again' ) . '</button></span>' .
    6263            '<span class="export-personal-data-failed hidden">' . __( 'Download failed.' ) . ' <button type="button" class="button-link">' . __( 'Retry' ) . '</button></span>';
    6364
    64         $download_data_markup .= '</div>';
     65        $download_data_markup .= '</span>';
    6566
    66         $row_actions = array(
    67             'download-data' => $download_data_markup,
    68         );
     67        $row_actions['download-data'] = $download_data_markup;
     68
     69        if ( 'request-completed' !== $status ) {
     70            $complete_request_markup  = '<span>';
     71            $complete_request_markup .= sprintf(
     72                '<a href="%s" class="complete-request" aria-label="%s">%s</a>',
     73                esc_url(
     74                    wp_nonce_url(
     75                        add_query_arg(
     76                            array(
     77                                'action'     => 'complete',
     78                                'request_id' => array( $request_id ),
     79                            ),
     80                            admin_url( 'export-personal-data.php' )
     81                        ),
     82                        'bulk-privacy_requests'
     83                    )
     84                ),
     85                esc_attr(
     86                    sprintf(
     87                        /* translators: %s: Request email. */
     88                        __( 'Mark export request for &#8220;%s&#8221; as completed.' ),
     89                        $item->email
     90                    )
     91                ),
     92                __( 'Complete request' )
     93            );
     94            $complete_request_markup .= '</span>';
     95        }
     96
     97        if ( ! empty ( $complete_request_markup ) ) {
     98            $row_actions['complete-request'] = $complete_request_markup;
     99        }
    69100
    70101        return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) );
     
    100131
    101132                ?>
    102                 <span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle"><?php _e( 'Send Export Link' ); ?></button></span>
    103                 <span class="export-personal-data-processing hidden"><?php _e( 'Sending Email...' ); ?> <span class="export-progress"></span></span>
     133                <span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle"><?php _e( 'Send export link' ); ?></button></span>
     134                <span class="export-personal-data-processing hidden"><?php _e( 'Sending email...' ); ?> <span class="export-progress"></span></span>
    104135                <span class="export-personal-data-success success-message hidden"><?php _e( 'Email sent.' ); ?></span>
    105136                <span class="export-personal-data-failed hidden"><?php _e( 'Email could not be sent.' ); ?> <button type="button" class="button-link export-personal-data-handle"><?php _e( 'Retry' ); ?></button></span>
  • trunk/src/wp-admin/includes/class-wp-privacy-data-removal-requests-list-table.php

    r47247 r49258  
    4848
    4949        // Allow the administrator to "force remove" the personal data even if confirmation has not yet been received.
    50         $status = $item->status;
     50        $status      = $item->status;
     51        $request_id  = $item->ID;
     52        $row_actions = array();
    5153        if ( 'request-confirmed' !== $status ) {
    5254            /** This filter is documented in wp-admin/includes/ajax-actions.php */
    5355            $erasers       = apply_filters( 'wp_privacy_personal_data_erasers', array() );
    5456            $erasers_count = count( $erasers );
    55             $request_id    = $item->ID;
    5657            $nonce         = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
    5758
    58             $remove_data_markup = '<div class="remove-personal-data force-remove-personal-data" ' .
     59            $remove_data_markup = '<span class="remove-personal-data force-remove-personal-data" ' .
    5960                'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' .
    6061                'data-request-id="' . esc_attr( $request_id ) . '" ' .
     
    6263                '">';
    6364
    64             $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>' .
    65                 '<span class="remove-personal-data-processing hidden">' . __( 'Erasing Data...' ) . ' <span class="erasure-progress"></span></span>' .
     65            $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>' .
     66                '<span class="remove-personal-data-processing hidden">' . __( 'Erasing data...' ) . ' <span class="erasure-progress"></span></span>' .
    6667                '<span class="remove-personal-data-success hidden">' . __( 'Erasure completed.' ) . '</span>' .
    67                 '<span class="remove-personal-data-failed hidden">' . __( 'Force Erasure has failed.' ) . ' <button type="button" class="button-link remove-personal-data-handle">' . __( 'Retry' ) . '</button></span>';
     68                '<span class="remove-personal-data-failed hidden">' . __( 'Force erasure has failed.' ) . ' <button type="button" class="button-link remove-personal-data-handle">' . __( 'Retry' ) . '</button></span>';
    6869
    69             $remove_data_markup .= '</div>';
     70            $remove_data_markup .= '</span>';
    7071
    71             $row_actions = array(
    72                 'remove-data' => $remove_data_markup,
     72            $row_actions['remove-data'] = $remove_data_markup;
     73        }
     74
     75        if ( 'request-completed' !== $status ) {
     76            $complete_request_markup  = '<span>';
     77            $complete_request_markup .= sprintf(
     78                '<a href="%s" class="complete-request" aria-label="%s">%s</a>',
     79                esc_url(
     80                    wp_nonce_url(
     81                        add_query_arg(
     82                            array(
     83                                'action'     => 'complete',
     84                                'request_id' => array( $request_id ),
     85                            ),
     86                            admin_url( 'erase-personal-data.php' )
     87                        ),
     88                        'bulk-privacy_requests'
     89                    )
     90                ),
     91                esc_attr(
     92                    sprintf(
     93                        /* translators: %s: Request email. */
     94                        __( 'Mark export request for &#8220;%s&#8221; as completed.' ),
     95                        $item->email
     96                    )
     97                ),
     98                __( 'Complete request' )
    7399            );
     100            $complete_request_markup .= '</span>';
     101        }
     102
     103        if ( ! empty ( $complete_request_markup ) ) {
     104            $row_actions['complete-request'] = $complete_request_markup;
    74105        }
    75106
     
    106137
    107138                ?>
    108                 <span class="remove-personal-data-idle"><button type="button" class="button-link remove-personal-data-handle"><?php _e( 'Erase Personal Data' ); ?></button></span>
    109                 <span class="remove-personal-data-processing hidden"><?php _e( 'Erasing Data...' ); ?> <span class="erasure-progress"></span></span>
     139                <span class="remove-personal-data-idle"><button type="button" class="button-link remove-personal-data-handle"><?php _e( 'Erase personal data' ); ?></button></span>
     140                <span class="remove-personal-data-processing hidden"><?php _e( 'Erasing data...' ); ?> <span class="erasure-progress"></span></span>
    110141                <span class="remove-personal-data-success success-message hidden" ><?php _e( 'Erasure completed.' ); ?></span>
    111                 <span class="remove-personal-data-failed hidden"><?php _e( 'Data Erasure has failed.' ); ?> <button type="button" class="button-link remove-personal-data-handle"><?php _e( 'Retry' ); ?></button></span>
     142                <span class="remove-personal-data-failed hidden"><?php _e( 'Data erasure has failed.' ); ?> <button type="button" class="button-link remove-personal-data-handle"><?php _e( 'Retry' ); ?></button></span>
    112143                <?php
    113144
  • trunk/src/wp-admin/includes/class-wp-privacy-requests-table.php

    r49190 r49258  
    4444            'status'            => __( 'Status' ),
    4545            'created_timestamp' => __( 'Requested' ),
    46             'next_steps'        => __( 'Next Steps' ),
     46            'next_steps'        => __( 'Next steps' ),
    4747        );
    4848        return $columns;
     
    211211    protected function get_bulk_actions() {
    212212        return array(
    213             'delete' => __( 'Delete Requests' ),
    214             'resend' => __( 'Resend Confirmation Requests' ),
     213            'resend'   => __( 'Resend confirmation requests' ),
     214            'complete' => __( 'Mark requests as completed' ),
     215            'delete'   => __( 'Delete requests' ),
    215216        );
    216217    }
     
    220221     *
    221222     * @since 4.9.6
     223     * @since 5.6.0 Added support for the `complete` action.
    222224     */
    223225    public function process_bulk_action() {
     
    232234
    233235        switch ( $action ) {
     236            case 'resend':
     237                foreach ( $request_ids as $request_id ) {
     238                    $resend = _wp_privacy_resend_request( $request_id );
     239
     240                    if ( $resend && ! is_wp_error( $resend ) ) {
     241                        $count++;
     242                    }
     243                }
     244
     245                add_settings_error(
     246                    'bulk_action',
     247                    'bulk_action',
     248                    /* translators: %d: Number of requests. */
     249                    sprintf( _n( 'Re-sent %d request.', 'Re-sent %d requests.', $count ), $count ),
     250                    'success'
     251                );
     252                break;
     253            case 'complete':
     254                foreach ( $request_ids as $request_id ) {
     255                    $result = _wp_privacy_completed_request( $request_id );
     256
     257                    if ( $result && ! is_wp_error( $result ) ) {
     258                        $count++;
     259                    }
     260                }
     261
     262                add_settings_error(
     263                    'bulk_action',
     264                    'bulk_action',
     265                    /* translators: %d: Number of requests. */
     266                    sprintf( _n( '%d request marked as complete.', '%d requests marked as complete.', $count ), $count ),
     267                    'success'
     268                );
     269                break;
    234270            case 'delete':
    235271                foreach ( $request_ids as $request_id ) {
     
    244280                    /* translators: %d: Number of requests. */
    245281                    sprintf( _n( 'Deleted %d request.', 'Deleted %d requests.', $count ), $count ),
    246                     'success'
    247                 );
    248                 break;
    249             case 'resend':
    250                 foreach ( $request_ids as $request_id ) {
    251                     $resend = _wp_privacy_resend_request( $request_id );
    252 
    253                     if ( $resend && ! is_wp_error( $resend ) ) {
    254                         $count++;
    255                     }
    256                 }
    257 
    258                 add_settings_error(
    259                     'bulk_action',
    260                     'bulk_action',
    261                     /* translators: %d: Number of requests. */
    262                     sprintf( _n( 'Re-sent %d request.', 'Re-sent %d requests.', $count ), $count ),
    263282                    'success'
    264283                );
Note: See TracChangeset for help on using the changeset viewer.