From 0d2249cc212e0b5363072b0f933a7508eb40bca4 Mon Sep 17 00:00:00 2001 From: Helen Hou-Sandi Date: Tue, 20 Oct 2020 21:05:34 +0000 Subject: [PATCH] Privacy: Add "Mark as completed" action. Props garrett-eclipse, ocean90, joostdevalk, mista-flo, helen. Fixes #46619. git-svn-id: https://develop.svn.wordpress.org/trunk@49258 602fd350-edb4-49c9-b593-d223f7449a82 --- ...rivacy-data-export-requests-list-table.php | 51 +++++++++++++---- ...ivacy-data-removal-requests-list-table.php | 55 +++++++++++++++---- .../class-wp-privacy-requests-table.php | 55 +++++++++++++------ 3 files changed, 121 insertions(+), 40 deletions(-) diff --git a/src/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php b/src/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php index 1aee73893b..25be2f1176 100644 --- a/src/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php +++ b/src/wp-admin/includes/class-wp-privacy-data-export-requests-list-table.php @@ -47,25 +47,56 @@ class WP_Privacy_Data_Export_Requests_List_Table extends WP_Privacy_Requests_Tab /** This filter is documented in wp-admin/includes/ajax-actions.php */ $exporters = apply_filters( 'wp_privacy_personal_data_exporters', array() ); $exporters_count = count( $exporters ); + $status = $item->status; $request_id = $item->ID; $nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id ); - $download_data_markup = '
'; - $download_data_markup .= '' . - '' . - '' . + $download_data_markup .= '' . + '' . + '' . ''; - $download_data_markup .= '
'; + $download_data_markup .= ''; - $row_actions = array( - 'download-data' => $download_data_markup, - ); + $row_actions['download-data'] = $download_data_markup; + + if ( 'request-completed' !== $status ) { + $complete_request_markup = ''; + $complete_request_markup .= sprintf( + '%s', + esc_url( + wp_nonce_url( + add_query_arg( + array( + 'action' => 'complete', + 'request_id' => array( $request_id ), + ), + admin_url( 'export-personal-data.php' ) + ), + 'bulk-privacy_requests' + ) + ), + esc_attr( + sprintf( + /* translators: %s: Request email. */ + __( 'Mark export request for “%s” as completed.' ), + $item->email + ) + ), + __( 'Complete request' ) + ); + $complete_request_markup .= ''; + } + + if ( ! empty ( $complete_request_markup ) ) { + $row_actions['complete-request'] = $complete_request_markup; + } return sprintf( '%2$s %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) ); } @@ -99,8 +130,8 @@ class WP_Privacy_Data_Export_Requests_List_Table extends WP_Privacy_Requests_Tab '">'; ?> - - + + status; + $status = $item->status; + $request_id = $item->ID; + $row_actions = array(); if ( 'request-confirmed' !== $status ) { /** This filter is documented in wp-admin/includes/ajax-actions.php */ $erasers = apply_filters( 'wp_privacy_personal_data_erasers', array() ); $erasers_count = count( $erasers ); - $request_id = $item->ID; $nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id ); - $remove_data_markup = '
'; - $remove_data_markup .= '' . - '' . + $remove_data_markup .= '' . + '' . '' . - ''; + ''; - $remove_data_markup .= '
'; + $remove_data_markup .= ''; - $row_actions = array( - 'remove-data' => $remove_data_markup, + $row_actions['remove-data'] = $remove_data_markup; + } + + if ( 'request-completed' !== $status ) { + $complete_request_markup = ''; + $complete_request_markup .= sprintf( + '%s', + esc_url( + wp_nonce_url( + add_query_arg( + array( + 'action' => 'complete', + 'request_id' => array( $request_id ), + ), + admin_url( 'erase-personal-data.php' ) + ), + 'bulk-privacy_requests' + ) + ), + esc_attr( + sprintf( + /* translators: %s: Request email. */ + __( 'Mark export request for “%s” as completed.' ), + $item->email + ) + ), + __( 'Complete request' ) ); + $complete_request_markup .= ''; + } + + if ( ! empty ( $complete_request_markup ) ) { + $row_actions['complete-request'] = $complete_request_markup; } return sprintf( '%2$s %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) ); @@ -105,10 +136,10 @@ class WP_Privacy_Data_Removal_Requests_List_Table extends WP_Privacy_Requests_Ta '">'; ?> - - + + - + '; diff --git a/src/wp-admin/includes/class-wp-privacy-requests-table.php b/src/wp-admin/includes/class-wp-privacy-requests-table.php index d2772bd60a..7f3476202f 100644 --- a/src/wp-admin/includes/class-wp-privacy-requests-table.php +++ b/src/wp-admin/includes/class-wp-privacy-requests-table.php @@ -43,7 +43,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table { 'email' => __( 'Requester' ), 'status' => __( 'Status' ), 'created_timestamp' => __( 'Requested' ), - 'next_steps' => __( 'Next Steps' ), + 'next_steps' => __( 'Next steps' ), ); return $columns; } @@ -210,8 +210,9 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table { */ protected function get_bulk_actions() { return array( - 'delete' => __( 'Delete Requests' ), - 'resend' => __( 'Resend Confirmation Requests' ), + 'resend' => __( 'Resend confirmation requests' ), + 'complete' => __( 'Mark requests as completed' ), + 'delete' => __( 'Delete requests' ), ); } @@ -219,6 +220,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table { * Process bulk actions. * * @since 4.9.6 + * @since 5.6.0 Added support for the `complete` action. */ public function process_bulk_action() { $action = $this->current_action(); @@ -231,21 +233,6 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table { } switch ( $action ) { - case 'delete': - foreach ( $request_ids as $request_id ) { - if ( wp_delete_post( $request_id, true ) ) { - $count ++; - } - } - - add_settings_error( - 'bulk_action', - 'bulk_action', - /* translators: %d: Number of requests. */ - sprintf( _n( 'Deleted %d request.', 'Deleted %d requests.', $count ), $count ), - 'success' - ); - break; case 'resend': foreach ( $request_ids as $request_id ) { $resend = _wp_privacy_resend_request( $request_id ); @@ -263,6 +250,38 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table { 'success' ); break; + case 'complete': + foreach ( $request_ids as $request_id ) { + $result = _wp_privacy_completed_request( $request_id ); + + if ( $result && ! is_wp_error( $result ) ) { + $count++; + } + } + + add_settings_error( + 'bulk_action', + 'bulk_action', + /* translators: %d: Number of requests. */ + sprintf( _n( '%d request marked as complete.', '%d requests marked as complete.', $count ), $count ), + 'success' + ); + break; + case 'delete': + foreach ( $request_ids as $request_id ) { + if ( wp_delete_post( $request_id, true ) ) { + $count ++; + } + } + + add_settings_error( + 'bulk_action', + 'bulk_action', + /* translators: %d: Number of requests. */ + sprintf( _n( 'Deleted %d request.', 'Deleted %d requests.', $count ), $count ), + 'success' + ); + break; } }