2019-05-26 16:50:53 -04:00
< ? php
/**
* List Table API : WP_Privacy_Data_Removal_Requests_List_Table class
*
* @ package WordPress
* @ subpackage Administration
* @ since 4.9 . 6
*/
if ( ! class_exists ( 'WP_Privacy_Requests_Table' ) ) {
2020-02-06 01:33:11 -05:00
require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-requests-table.php' ;
2019-05-26 16:50:53 -04:00
}
/**
2019-06-07 20:30:51 -04:00
* WP_Privacy_Data_Removal_Requests_List_Table class .
2019-05-26 16:50:53 -04:00
*
* @ since 4.9 . 6
*/
class WP_Privacy_Data_Removal_Requests_List_Table extends WP_Privacy_Requests_Table {
/**
* Action name for the requests this table will work with .
*
* @ since 4.9 . 6
*
* @ var string $request_type Name of action .
*/
protected $request_type = 'remove_personal_data' ;
/**
* Post type for the requests .
*
* @ since 4.9 . 6
*
* @ var string $post_type The post type .
*/
protected $post_type = 'user_request' ;
/**
2023-06-14 02:34:27 -04:00
* Outputs the Actions column .
2019-05-26 16:50:53 -04:00
*
* @ since 4.9 . 6
*
* @ param WP_User_Request $item Item being shown .
* @ return string Email column markup .
*/
public function column_email ( $item ) {
$row_actions = array ();
// Allow the administrator to "force remove" the personal data even if confirmation has not yet been received.
2020-10-20 17:07:07 -04:00
$status = $item -> status ;
$request_id = $item -> ID ;
$row_actions = array ();
2019-05-26 16:50:53 -04:00
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 );
$nonce = wp_create_nonce ( 'wp-privacy-erase-personal-data-' . $request_id );
2020-10-20 17:07:07 -04:00
$remove_data_markup = '<span class="remove-personal-data force-remove-personal-data" ' .
2019-05-26 16:50:53 -04:00
'data-erasers-count="' . esc_attr ( $erasers_count ) . '" ' .
'data-request-id="' . esc_attr ( $request_id ) . '" ' .
'data-nonce="' . esc_attr ( $nonce ) .
'">' ;
2020-10-20 17:07:07 -04:00
$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 class="remove-personal-data-processing hidden">' . __ ( 'Erasing data...' ) . ' <span class="erasure-progress"></span></span>' .
2019-09-23 15:13:58 -04:00
'<span class="remove-personal-data-success hidden">' . __ ( 'Erasure completed.' ) . '</span>' .
2020-10-20 17:07:07 -04:00
'<span class="remove-personal-data-failed hidden">' . __ ( 'Force erasure has failed.' ) . ' <button type="button" class="button-link remove-personal-data-handle">' . __ ( 'Retry' ) . '</button></span>' ;
2019-05-26 16:50:53 -04:00
2020-10-20 17:07:07 -04:00
$remove_data_markup .= '</span>' ;
$row_actions [ 'remove-data' ] = $remove_data_markup ;
}
2019-05-26 16:50:53 -04:00
2020-10-20 17:07:07 -04:00
if ( 'request-completed' !== $status ) {
$complete_request_markup = '<span>' ;
$complete_request_markup .= sprintf (
'<a href="%s" class="complete-request" aria-label="%s">%s</a>' ,
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' )
2019-05-26 16:50:53 -04:00
);
2020-10-20 17:07:07 -04:00
$complete_request_markup .= '</span>' ;
}
2020-10-20 17:20:07 -04:00
if ( ! empty ( $complete_request_markup ) ) {
2020-10-20 17:07:07 -04:00
$row_actions [ 'complete-request' ] = $complete_request_markup ;
2019-05-26 16:50:53 -04:00
}
return sprintf ( '<a href="%1$s">%2$s</a> %3$s' , esc_url ( 'mailto:' . $item -> email ), $item -> email , $this -> row_actions ( $row_actions ) );
}
/**
2023-06-14 02:34:27 -04:00
* Outputs the Next steps column .
2019-05-26 16:50:53 -04:00
*
* @ since 4.9 . 6
*
* @ param WP_User_Request $item Item being shown .
*/
public function column_next_steps ( $item ) {
$status = $item -> status ;
switch ( $status ) {
case 'request-pending' :
esc_html_e ( 'Waiting for confirmation' );
break ;
case 'request-confirmed' :
/** 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 );
echo '<div class="remove-personal-data" ' .
'data-force-erase="1" ' .
'data-erasers-count="' . esc_attr ( $erasers_count ) . '" ' .
'data-request-id="' . esc_attr ( $request_id ) . '" ' .
'data-nonce="' . esc_attr ( $nonce ) .
'">' ;
?>
2020-10-20 17:07:07 -04:00
< span class = " remove-personal-data-idle " >< button type = " button " class = " button-link remove-personal-data-handle " >< ? php _e ( 'Erase personal data' ); ?> </button></span>
< span class = " remove-personal-data-processing hidden " >< ? php _e ( 'Erasing data...' ); ?> <span class="erasure-progress"></span></span>
2019-09-23 15:13:58 -04:00
< span class = " remove-personal-data-success success-message hidden " >< ? php _e ( 'Erasure completed.' ); ?> </span>
2020-10-20 17:07:07 -04:00
< 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>
2019-05-26 16:50:53 -04:00
< ? php
echo '</div>' ;
break ;
case 'request-failed' :
2020-02-10 16:15:05 -05:00
echo '<button type="submit" class="button-link" name="privacy_action_email_retry[' . $item -> ID . ']" id="privacy_action_email_retry[' . $item -> ID . ']">' . __ ( 'Retry' ) . '</button>' ;
2019-05-26 16:50:53 -04:00
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 ( 'erase-personal-data.php' )
),
'bulk-privacy_requests'
)
2020-02-10 16:15:05 -05:00
) . '">' . esc_html__ ( 'Remove request' ) . '</a>' ;
2019-05-26 16:50:53 -04:00
break ;
}
}
}