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

Props desrosj, xkon.
See #43929.

git-svn-id: https://develop.svn.wordpress.org/trunk@43212 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Andrew Ozz
2018-05-10 10:00:19 +00:00
parent dd4322535b
commit 56079a45fd
4 changed files with 118 additions and 95 deletions

View File

@@ -663,7 +663,6 @@ function _wp_personal_data_handle_actions() {
'updated'
);
}
} elseif ( isset( $_POST['action'] ) ) {
$action = isset( $_POST['action'] ) ? sanitize_key( wp_unslash( $_POST['action'] ) ) : ''; // WPCS: input var ok, CSRF ok.
@@ -760,7 +759,7 @@ function _wp_personal_data_cleanup_requests() {
'posts_per_page' => -1,
'post_status' => 'request-pending',
'fields' => 'ids',
'date_query' => array(
'date_query' => array(
array(
'column' => 'post_modified_gmt',
'before' => $expires . ' seconds ago',
@@ -1112,7 +1111,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
* @return array
*/
protected function get_views() {
$current_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ): '';
$current_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : '';
$statuses = _wp_privacy_statuses();
$views = array();
$admin_url = admin_url( 'tools.php?page=' . $this->request_type );
@@ -1151,7 +1150,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
public function process_bulk_action() {
$action = $this->current_action();
$request_ids = isset( $_REQUEST['request_id'] ) ? wp_parse_id_list( wp_unslash( $_REQUEST['request_id'] ) ) : array(); // WPCS: input var ok, CSRF ok.
$count = 0;
$count = 0;
if ( $request_ids ) {
check_admin_referer( 'bulk-privacy_requests' );
@@ -1168,6 +1167,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
add_settings_error(
'bulk_action',
'bulk_action',
/* translators: %d: number of requests */
sprintf( _n( 'Deleted %d request', 'Deleted %d requests', $count ), $count ),
'updated'
);
@@ -1184,6 +1184,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
add_settings_error(
'bulk_action',
'bulk_action',
/* translators: %d: number of requests */
sprintf( _n( 'Re-sent %d request', 'Re-sent %d requests', $count ), $count ),
'updated'
);
@@ -1213,7 +1214,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
'post_type' => $this->post_type,
'post_name__in' => array( $this->request_type ),
'posts_per_page' => $posts_per_page,
'offset' => isset( $_REQUEST['paged'] ) ? max( 0, absint( $_REQUEST['paged'] ) - 1 ) * $posts_per_page: 0,
'offset' => isset( $_REQUEST['paged'] ) ? max( 0, absint( $_REQUEST['paged'] ) - 1 ) * $posts_per_page : 0,
'post_status' => 'any',
's' => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : '',
);
@@ -1305,6 +1306,7 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table {
$time_diff = current_time( 'timestamp', true ) - $timestamp;
if ( $time_diff >= 0 && $time_diff < DAY_IN_SECONDS ) {
/* translators: human readable timestamp */
return sprintf( __( '%s ago' ), human_time_diff( $timestamp ) );
}
@@ -1412,21 +1414,21 @@ class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table {
$request_id = $item->ID;
$nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
$download_data_markup = '<div class="export_personal_data" ' .
$download_data_markup = '<div class="export-personal-data" ' .
'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' .
'data-request-id="' . esc_attr( $request_id ) . '" ' .
'data-nonce="' . esc_attr( $nonce ) .
'">';
$download_data_markup .= '<span class="export_personal_data_idle"><a href="#" >' . __( 'Download Personal Data' ) . '</a></span>' .
'<span style="display:none" class="export_personal_data_processing" >' . __( 'Downloading Data...' ) . '</span>' .
'<span style="display:none" class="export_personal_data_success"><a href="#" >' . __( 'Download Personal Data Again' ) . '</a></span>' .
'<span style="display:none" class="export_personal_data_failed">' . __( 'Download has failed.' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>';
$download_data_markup .= '<span class="export-personal-data-idle"><button type="button" class="button-link export-personal-data-handle">' . __( 'Download Personal Data' ) . '</button></span>' .
'<span style="display:none" class="export-personal-data-processing" >' . __( 'Downloading Data...' ) . '</span>' .
'<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>' .
'<span style="display:none" class="export-personal-data-failed">' . __( 'Download has failed.' ) . ' <button type="button" class="button-link">' . __( 'Retry' ) . '</button></span>';
$download_data_markup .= '</div>';
$row_actions = array(
'download_data' => $download_data_markup,
'download-data' => $download_data_markup,
);
return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( $row_actions ) );
@@ -1452,7 +1454,7 @@ class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table {
$request_id = $item->ID;
$nonce = wp_create_nonce( 'wp-privacy-export-personal-data-' . $request_id );
echo '<div class="export_personal_data" ' .
echo '<div class="export-personal-data" ' .
'data-send-as-email="1" ' .
'data-exporters-count="' . esc_attr( $exporters_count ) . '" ' .
'data-request-id="' . esc_attr( $request_id ) . '" ' .
@@ -1460,10 +1462,10 @@ class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table {
'">';
?>
<span class="export_personal_data_idle"><a class="button" href="#" ><?php _e( 'Send Export Link' ); ?></a></span>
<span style="display:none" class="export_personal_data_processing button updating-message" ><?php _e( 'Sending Email...' ); ?></span>
<span style="display:none" class="export_personal_data_success success-message" ><?php _e( 'Email sent.' ); ?></span>
<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>
<span class="export-personal-data-idle"><button type="button" class="button export-personal-data-handle"><?php _e( 'Email Data' ); ?></button></span>
<span style="display:none" class="export-personal-data-processing button updating-message" ><?php _e( 'Sending Email...' ); ?></span>
<span style="display:none" class="export-personal-data-success success-message" ><?php _e( 'Email sent.' ); ?></span>
<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>
<?php
echo '</div>';
@@ -1473,9 +1475,9 @@ class WP_Privacy_Data_Export_Requests_Table extends WP_Privacy_Requests_Table {
break;
case 'request-completed':
echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array(
'action' => 'delete',
'request_id' => array( $item->ID )
), admin_url( 'tools.php?page=export_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>';
'action' => 'delete',
'request_id' => array( $item->ID ),
), admin_url( 'tools.php?page=export_personal_data' ) ), 'bulk-privacy_requests' ) ) . '" class="button">' . esc_html__( 'Remove request' ) . '</a>';
break;
}
}
@@ -1524,20 +1526,20 @@ class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Requests_Table {
$request_id = $item->ID;
$nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
$remove_data_markup = '<div class="remove_personal_data force_remove_personal_data" ' .
$remove_data_markup = '<div class="remove-personal-data force-remove-personal-data" ' .
'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' .
'data-request-id="' . esc_attr( $request_id ) . '" ' .
'data-nonce="' . esc_attr( $nonce ) .
'">';
$remove_data_markup .= '<span class="remove_personal_data_idle"><a href="#" >' . __( 'Force Erase Personal Data' ) . '</a></span>' .
'<span style="display:none" class="remove_personal_data_processing" >' . __( 'Erasing Data...' ) . '</span>' .
'<span style="display:none" class="remove_personal_data_failed">' . __( 'Force Erase has failed.' ) . ' <a href="#" >' . __( 'Retry' ) . '</a></span>';
$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>' .
'<span style="display:none" class="remove-personal-data-processing" >' . __( 'Erasing Data...' ) . '</span>' .
'<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>';
$remove_data_markup .= '</div>';
$row_actions = array(
'remove_data' => $remove_data_markup,
'remove-data' => $remove_data_markup,
);
}
@@ -1564,7 +1566,7 @@ class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Requests_Table {
$request_id = $item->ID;
$nonce = wp_create_nonce( 'wp-privacy-erase-personal-data-' . $request_id );
echo '<div class="remove_personal_data" ' .
echo '<div class="remove-personal-data" ' .
'data-force-erase="1" ' .
'data-erasers-count="' . esc_attr( $erasers_count ) . '" ' .
'data-request-id="' . esc_attr( $request_id ) . '" ' .
@@ -1572,9 +1574,9 @@ class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Requests_Table {
'">';
?>
<span class="remove_personal_data_idle"><a class="button" href="#" ><?php _e( 'Erase Personal Data' ); ?></a></span>
<span style="display:none" class="remove_personal_data_processing button updating-message" ><?php _e( 'Erasing Data...' ); ?></span>
<span style="display:none" class="remove_personal_data_failed"><?php _e( 'Erasing Data has failed.' ); ?> <a class="button" href="#" ><?php _e( 'Retry' ); ?></a></span>
<span class="remove-personal-data-idle"><button type="button" class="button remove-personal-data-handle"><?php _e( 'Erase Personal Data' ); ?></button></span>
<span style="display:none" class="remove-personal-data-processing button updating-message" ><?php _e( 'Erasing Data...' ); ?></span>
<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>
<?php
echo '</div>';
@@ -1585,9 +1587,9 @@ class WP_Privacy_Data_Removal_Requests_Table extends WP_Privacy_Requests_Table {
break;
case 'request-completed':
echo '<a href="' . esc_url( wp_nonce_url( add_query_arg( array(
'action' => 'delete',
'action' => 'delete',
'request_id' => array( $item->ID ),
), admin_url( 'tools.php?page=remove_personal_data' ) ), 'bulk-privacy_requests' ) ) . '">' . esc_html__( 'Remove request' ) . '</a>';
), admin_url( 'tools.php?page=remove_personal_data' ) ), 'bulk-privacy_requests' ) ) . '" class="button">' . esc_html__( 'Remove request' ) . '</a>';
break;
}
}