2019-05-26 16:50:53 -04:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* List Table API: WP_Privacy_Requests_Table class
|
|
|
|
*
|
|
|
|
* @package WordPress
|
|
|
|
* @subpackage Administration
|
|
|
|
* @since 4.9.6
|
|
|
|
*/
|
|
|
|
|
|
|
|
abstract class WP_Privacy_Requests_Table extends WP_List_Table {
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Action name for the requests this table will work with. Classes
|
|
|
|
* which inherit from WP_Privacy_Requests_Table should define this.
|
|
|
|
*
|
|
|
|
* Example: 'export_personal_data'.
|
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
|
|
|
* @var string $request_type Name of action.
|
|
|
|
*/
|
|
|
|
protected $request_type = 'INVALID';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Post type to be used.
|
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
|
|
|
* @var string $post_type The post type.
|
|
|
|
*/
|
|
|
|
protected $post_type = 'INVALID';
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Gets columns to show in the list table.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
2019-11-05 16:30:03 -05:00
|
|
|
* @return string[] Array of column titles keyed by their column name.
|
2019-05-26 16:50:53 -04:00
|
|
|
*/
|
|
|
|
public function get_columns() {
|
|
|
|
$columns = array(
|
|
|
|
'cb' => '<input type="checkbox" />',
|
|
|
|
'email' => __( 'Requester' ),
|
|
|
|
'status' => __( 'Status' ),
|
|
|
|
'created_timestamp' => __( 'Requested' ),
|
2020-10-20 17:07:07 -04:00
|
|
|
'next_steps' => __( 'Next steps' ),
|
2019-05-26 16:50:53 -04:00
|
|
|
);
|
|
|
|
return $columns;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Normalizes the admin URL to the current page (by request_type).
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 5.3.0
|
|
|
|
*
|
|
|
|
* @return string URL to the current admin page.
|
|
|
|
*/
|
|
|
|
protected function get_admin_url() {
|
|
|
|
$pagenow = str_replace( '_', '-', $this->request_type );
|
|
|
|
|
|
|
|
if ( 'remove-personal-data' === $pagenow ) {
|
|
|
|
$pagenow = 'erase-personal-data';
|
|
|
|
}
|
|
|
|
|
|
|
|
return admin_url( $pagenow . '.php' );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Gets a list of sortable columns.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
|
|
|
* @return array Default sortable columns.
|
|
|
|
*/
|
|
|
|
protected function get_sortable_columns() {
|
2020-01-28 19:45:18 -05:00
|
|
|
/*
|
|
|
|
* The initial sorting is by 'Requested' (post_date) and descending.
|
|
|
|
* With initial sorting, the first click on 'Requested' should be ascending.
|
|
|
|
* With 'Requester' sorting active, the next click on 'Requested' should be descending.
|
|
|
|
*/
|
2019-05-26 16:50:53 -04:00
|
|
|
$desc_first = isset( $_GET['orderby'] );
|
|
|
|
|
|
|
|
return array(
|
|
|
|
'email' => 'requester',
|
|
|
|
'created_timestamp' => array( 'requested', $desc_first ),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Returns the default primary column.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
|
|
|
* @return string Default primary column name.
|
|
|
|
*/
|
|
|
|
protected function get_default_primary_column_name() {
|
|
|
|
return 'email';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Counts the number of requests for each status.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
2021-11-24 06:41:03 -05:00
|
|
|
* @global wpdb $wpdb WordPress database abstraction object.
|
|
|
|
*
|
2019-05-26 16:50:53 -04:00
|
|
|
* @return object Number of posts for each status.
|
|
|
|
*/
|
|
|
|
protected function get_request_counts() {
|
|
|
|
global $wpdb;
|
|
|
|
|
|
|
|
$cache_key = $this->post_type . '-' . $this->request_type;
|
|
|
|
$counts = wp_cache_get( $cache_key, 'counts' );
|
|
|
|
|
|
|
|
if ( false !== $counts ) {
|
|
|
|
return $counts;
|
|
|
|
}
|
|
|
|
|
|
|
|
$query = "
|
|
|
|
SELECT post_status, COUNT( * ) AS num_posts
|
|
|
|
FROM {$wpdb->posts}
|
|
|
|
WHERE post_type = %s
|
|
|
|
AND post_name = %s
|
|
|
|
GROUP BY post_status";
|
|
|
|
|
|
|
|
$results = (array) $wpdb->get_results( $wpdb->prepare( $query, $this->post_type, $this->request_type ), ARRAY_A );
|
|
|
|
$counts = array_fill_keys( get_post_stati(), 0 );
|
|
|
|
|
|
|
|
foreach ( $results as $row ) {
|
|
|
|
$counts[ $row['post_status'] ] = $row['num_posts'];
|
|
|
|
}
|
|
|
|
|
|
|
|
$counts = (object) $counts;
|
|
|
|
wp_cache_set( $cache_key, $counts, 'counts' );
|
|
|
|
|
|
|
|
return $counts;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Gets an associative array ( id => link ) with the list of views available on this table.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
2019-11-05 16:30:03 -05:00
|
|
|
* @return string[] An array of HTML links keyed by their view.
|
2019-05-26 16:50:53 -04:00
|
|
|
*/
|
|
|
|
protected function get_views() {
|
|
|
|
$current_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : '';
|
|
|
|
$statuses = _wp_privacy_statuses();
|
|
|
|
$views = array();
|
|
|
|
$counts = $this->get_request_counts();
|
|
|
|
$total_requests = absint( array_sum( (array) $counts ) );
|
|
|
|
|
2020-01-28 19:45:18 -05:00
|
|
|
// Normalized admin URL.
|
2019-05-26 16:50:53 -04:00
|
|
|
$admin_url = $this->get_admin_url();
|
|
|
|
|
2022-09-19 17:08:10 -04:00
|
|
|
$status_label = sprintf(
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: %s: Number of requests. */
|
2019-05-26 16:50:53 -04:00
|
|
|
_nx(
|
|
|
|
'All <span class="count">(%s)</span>',
|
|
|
|
'All <span class="count">(%s)</span>',
|
|
|
|
$total_requests,
|
|
|
|
'requests'
|
|
|
|
),
|
|
|
|
number_format_i18n( $total_requests )
|
|
|
|
);
|
|
|
|
|
2022-09-19 17:08:10 -04:00
|
|
|
$views['all'] = array(
|
|
|
|
'url' => esc_url( $admin_url ),
|
|
|
|
'label' => $status_label,
|
|
|
|
'current' => empty( $current_status ),
|
2019-05-26 16:50:53 -04:00
|
|
|
);
|
|
|
|
|
|
|
|
foreach ( $statuses as $status => $label ) {
|
|
|
|
$post_status = get_post_status_object( $status );
|
|
|
|
if ( ! $post_status ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2022-09-19 17:08:10 -04:00
|
|
|
$total_status_requests = absint( $counts->{$status} );
|
2019-05-26 16:50:53 -04:00
|
|
|
|
2020-07-03 12:28:04 -04:00
|
|
|
if ( ! $total_status_requests ) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-05-26 16:50:53 -04:00
|
|
|
$status_label = sprintf(
|
|
|
|
translate_nooped_plural( $post_status->label_count, $total_status_requests ),
|
|
|
|
number_format_i18n( $total_status_requests )
|
|
|
|
);
|
|
|
|
|
|
|
|
$status_link = add_query_arg( 'filter-status', $status, $admin_url );
|
|
|
|
|
2022-09-19 17:08:10 -04:00
|
|
|
$views[ $status ] = array(
|
|
|
|
'url' => esc_url( $status_link ),
|
|
|
|
'label' => $status_label,
|
|
|
|
'current' => $status === $current_status,
|
2019-05-26 16:50:53 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-09-19 17:08:10 -04:00
|
|
|
return $this->get_views_links( $views );
|
2019-05-26 16:50:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Gets bulk actions.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
2020-10-18 12:22:10 -04:00
|
|
|
* @return array Array of bulk action labels keyed by their action.
|
2019-05-26 16:50:53 -04:00
|
|
|
*/
|
|
|
|
protected function get_bulk_actions() {
|
|
|
|
return array(
|
2020-10-20 17:07:07 -04:00
|
|
|
'resend' => __( 'Resend confirmation requests' ),
|
|
|
|
'complete' => __( 'Mark requests as completed' ),
|
|
|
|
'delete' => __( 'Delete requests' ),
|
2019-05-26 16:50:53 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Process bulk actions.
|
|
|
|
*
|
|
|
|
* @since 4.9.6
|
2020-10-20 17:07:07 -04:00
|
|
|
* @since 5.6.0 Added support for the `complete` action.
|
2019-05-26 16:50:53 -04:00
|
|
|
*/
|
|
|
|
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();
|
|
|
|
|
2020-10-27 13:47:08 -04:00
|
|
|
if ( empty( $request_ids ) ) {
|
|
|
|
return;
|
2019-05-26 16:50:53 -04:00
|
|
|
}
|
|
|
|
|
2020-10-27 13:47:08 -04:00
|
|
|
$count = 0;
|
|
|
|
$failures = 0;
|
|
|
|
|
|
|
|
check_admin_referer( 'bulk-privacy_requests' );
|
|
|
|
|
2019-05-26 16:50:53 -04:00
|
|
|
switch ( $action ) {
|
2020-10-20 17:07:07 -04:00
|
|
|
case 'resend':
|
2019-05-26 16:50:53 -04:00
|
|
|
foreach ( $request_ids as $request_id ) {
|
2020-10-20 17:07:07 -04:00
|
|
|
$resend = _wp_privacy_resend_request( $request_id );
|
|
|
|
|
|
|
|
if ( $resend && ! is_wp_error( $resend ) ) {
|
|
|
|
$count++;
|
2020-10-27 13:47:08 -04:00
|
|
|
} else {
|
|
|
|
$failures++;
|
2019-05-26 16:50:53 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-27 14:19:06 -04:00
|
|
|
if ( $failures ) {
|
2020-10-27 13:47:08 -04:00
|
|
|
add_settings_error(
|
|
|
|
'bulk_action',
|
|
|
|
'bulk_action',
|
|
|
|
sprintf(
|
|
|
|
/* translators: %d: Number of requests. */
|
|
|
|
_n(
|
2020-10-27 14:19:06 -04:00
|
|
|
'%d confirmation request failed to resend.',
|
|
|
|
'%d confirmation requests failed to resend.',
|
|
|
|
$failures
|
2020-10-27 13:47:08 -04:00
|
|
|
),
|
2020-10-27 14:19:06 -04:00
|
|
|
$failures
|
2020-10-27 13:47:08 -04:00
|
|
|
),
|
2020-10-27 14:19:06 -04:00
|
|
|
'error'
|
2020-10-27 13:47:08 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2020-10-27 14:19:06 -04:00
|
|
|
if ( $count ) {
|
2020-10-27 13:47:08 -04:00
|
|
|
add_settings_error(
|
|
|
|
'bulk_action',
|
|
|
|
'bulk_action',
|
|
|
|
sprintf(
|
|
|
|
/* translators: %d: Number of requests. */
|
|
|
|
_n(
|
2020-10-27 14:19:06 -04:00
|
|
|
'%d confirmation request re-sent successfully.',
|
|
|
|
'%d confirmation requests re-sent successfully.',
|
|
|
|
$count
|
2020-10-27 13:47:08 -04:00
|
|
|
),
|
2020-10-27 14:19:06 -04:00
|
|
|
$count
|
2020-10-27 13:47:08 -04:00
|
|
|
),
|
2020-10-27 14:19:06 -04:00
|
|
|
'success'
|
2020-10-27 13:47:08 -04:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-05-26 16:50:53 -04:00
|
|
|
break;
|
2020-10-27 13:47:08 -04:00
|
|
|
|
2020-10-20 17:07:07 -04:00
|
|
|
case 'complete':
|
2019-05-26 16:50:53 -04:00
|
|
|
foreach ( $request_ids as $request_id ) {
|
2020-10-20 17:07:07 -04:00
|
|
|
$result = _wp_privacy_completed_request( $request_id );
|
2019-05-26 16:50:53 -04:00
|
|
|
|
2020-10-20 17:07:07 -04:00
|
|
|
if ( $result && ! is_wp_error( $result ) ) {
|
2019-05-26 16:50:53 -04:00
|
|
|
$count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
add_settings_error(
|
|
|
|
'bulk_action',
|
|
|
|
'bulk_action',
|
2020-10-27 13:47:08 -04:00
|
|
|
sprintf(
|
|
|
|
/* translators: %d: Number of requests. */
|
|
|
|
_n(
|
|
|
|
'%d request marked as complete.',
|
|
|
|
'%d requests marked as complete.',
|
|
|
|
$count
|
|
|
|
),
|
|
|
|
$count
|
|
|
|
),
|
2020-10-20 17:07:07 -04:00
|
|
|
'success'
|
|
|
|
);
|
|
|
|
break;
|
2020-10-27 13:47:08 -04:00
|
|
|
|
2020-10-20 17:07:07 -04:00
|
|
|
case 'delete':
|
|
|
|
foreach ( $request_ids as $request_id ) {
|
|
|
|
if ( wp_delete_post( $request_id, true ) ) {
|
2020-10-27 13:47:08 -04:00
|
|
|
$count++;
|
|
|
|
} else {
|
|
|
|
$failures++;
|
2020-10-20 17:07:07 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-27 13:47:08 -04:00
|
|
|
if ( $failures ) {
|
|
|
|
add_settings_error(
|
|
|
|
'bulk_action',
|
|
|
|
'bulk_action',
|
|
|
|
sprintf(
|
|
|
|
/* translators: %d: Number of requests. */
|
|
|
|
_n(
|
|
|
|
'%d request failed to delete.',
|
|
|
|
'%d requests failed to delete.',
|
|
|
|
$failures
|
|
|
|
),
|
|
|
|
$failures
|
|
|
|
),
|
|
|
|
'error'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( $count ) {
|
|
|
|
add_settings_error(
|
|
|
|
'bulk_action',
|
|
|
|
'bulk_action',
|
|
|
|
sprintf(
|
|
|
|
/* translators: %d: Number of requests. */
|
|
|
|
_n(
|
|
|
|
'%d request deleted successfully.',
|
|
|
|
'%d requests deleted successfully.',
|
|
|
|
$count
|
|
|
|
),
|
|
|
|
$count
|
|
|
|
),
|
|
|
|
'success'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2019-05-26 16:50:53 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Prepares items to output.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
* @since 5.1.0 Added support for column sorting.
|
|
|
|
*/
|
|
|
|
public function prepare_items() {
|
|
|
|
$this->items = array();
|
|
|
|
$posts_per_page = $this->get_items_per_page( $this->request_type . '_requests_per_page' );
|
|
|
|
$args = array(
|
|
|
|
'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,
|
|
|
|
'post_status' => 'any',
|
|
|
|
's' => isset( $_REQUEST['s'] ) ? sanitize_text_field( $_REQUEST['s'] ) : '',
|
|
|
|
);
|
|
|
|
|
|
|
|
$orderby_mapping = array(
|
|
|
|
'requester' => 'post_title',
|
|
|
|
'requested' => 'post_date',
|
|
|
|
);
|
|
|
|
|
|
|
|
if ( isset( $_REQUEST['orderby'] ) && isset( $orderby_mapping[ $_REQUEST['orderby'] ] ) ) {
|
|
|
|
$args['orderby'] = $orderby_mapping[ $_REQUEST['orderby'] ];
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( isset( $_REQUEST['order'] ) && in_array( strtoupper( $_REQUEST['order'] ), array( 'ASC', 'DESC' ), true ) ) {
|
|
|
|
$args['order'] = strtoupper( $_REQUEST['order'] );
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( ! empty( $_REQUEST['filter-status'] ) ) {
|
|
|
|
$filter_status = isset( $_REQUEST['filter-status'] ) ? sanitize_text_field( $_REQUEST['filter-status'] ) : '';
|
|
|
|
$args['post_status'] = $filter_status;
|
|
|
|
}
|
|
|
|
|
|
|
|
$requests_query = new WP_Query( $args );
|
|
|
|
$requests = $requests_query->posts;
|
|
|
|
|
|
|
|
foreach ( $requests as $request ) {
|
2020-02-10 14:57:05 -05:00
|
|
|
$this->items[] = wp_get_user_request( $request->ID );
|
2019-05-26 16:50:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
$this->items = array_filter( $this->items );
|
|
|
|
|
|
|
|
$this->set_pagination_args(
|
|
|
|
array(
|
|
|
|
'total_items' => $requests_query->found_posts,
|
|
|
|
'per_page' => $posts_per_page,
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Returns the markup for the Checkbox column.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
|
|
|
* @param WP_User_Request $item Item being shown.
|
|
|
|
* @return string Checkbox column markup.
|
|
|
|
*/
|
|
|
|
public function column_cb( $item ) {
|
2023-06-20 21:54:19 -04:00
|
|
|
return sprintf(
|
|
|
|
'<label class="label-covers-full-cell" for="requester_%1$s"><span class="screen-reader-text">%2$s</span></label>' .
|
|
|
|
'<input type="checkbox" name="request_id[]" id="requester_%1$s" value="%1$s" /><span class="spinner"></span>',
|
|
|
|
esc_attr( $item->ID ),
|
|
|
|
/* translators: Hidden accessibility text. %s: Email address. */
|
|
|
|
sprintf( __( 'Select %s' ), $item->email )
|
|
|
|
);
|
2019-05-26 16:50:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Status column.
|
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
|
|
|
* @param WP_User_Request $item Item being shown.
|
|
|
|
* @return string Status column markup.
|
|
|
|
*/
|
|
|
|
public function column_status( $item ) {
|
|
|
|
$status = get_post_status( $item->ID );
|
|
|
|
$status_object = get_post_status_object( $status );
|
|
|
|
|
|
|
|
if ( ! $status_object || empty( $status_object->label ) ) {
|
|
|
|
return '-';
|
|
|
|
}
|
|
|
|
|
|
|
|
$timestamp = false;
|
|
|
|
|
|
|
|
switch ( $status ) {
|
|
|
|
case 'request-confirmed':
|
|
|
|
$timestamp = $item->confirmed_timestamp;
|
|
|
|
break;
|
|
|
|
case 'request-completed':
|
|
|
|
$timestamp = $item->completed_timestamp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '<span class="status-label status-' . esc_attr( $status ) . '">';
|
|
|
|
echo esc_html( $status_object->label );
|
|
|
|
|
|
|
|
if ( $timestamp ) {
|
|
|
|
echo ' (' . $this->get_timestamp_as_date( $timestamp ) . ')';
|
|
|
|
}
|
|
|
|
|
|
|
|
echo '</span>';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Converts a timestamp for display.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
|
|
|
* @param int $timestamp Event timestamp.
|
|
|
|
* @return string Human readable date.
|
|
|
|
*/
|
|
|
|
protected function get_timestamp_as_date( $timestamp ) {
|
|
|
|
if ( empty( $timestamp ) ) {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
|
|
|
|
$time_diff = time() - $timestamp;
|
|
|
|
|
|
|
|
if ( $time_diff >= 0 && $time_diff < DAY_IN_SECONDS ) {
|
2019-09-02 20:41:05 -04:00
|
|
|
/* translators: %s: Human-readable time difference. */
|
2019-05-26 16:50:53 -04:00
|
|
|
return sprintf( __( '%s ago' ), human_time_diff( $timestamp ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return date_i18n( get_option( 'date_format' ), $timestamp );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Handles the default column.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
2021-02-02 11:44:04 -05:00
|
|
|
* @since 5.7.0 Added `manage_{$this->screen->id}_custom_column` action.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @param WP_User_Request $item Item being shown.
|
|
|
|
* @param string $column_name Name of column being shown.
|
|
|
|
*/
|
|
|
|
public function column_default( $item, $column_name ) {
|
2021-02-02 11:44:04 -05:00
|
|
|
/**
|
|
|
|
* Fires for each custom column of a specific request type in the Requests list table.
|
|
|
|
*
|
|
|
|
* Custom columns are registered using the {@see 'manage_export-personal-data_columns'}
|
|
|
|
* and the {@see 'manage_erase-personal-data_columns'} filters.
|
|
|
|
*
|
|
|
|
* @since 5.7.0
|
|
|
|
*
|
|
|
|
* @param string $column_name The name of the column to display.
|
|
|
|
* @param WP_User_Request $item The item being shown.
|
|
|
|
*/
|
|
|
|
do_action( "manage_{$this->screen->id}_custom_column", $column_name, $item );
|
|
|
|
}
|
2019-05-26 16:50:53 -04:00
|
|
|
|
2021-02-02 11:44:04 -05:00
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Returns the markup for the Created timestamp column. Overridden by children.
|
2021-02-02 11:44:04 -05:00
|
|
|
*
|
|
|
|
* @since 5.7.0
|
|
|
|
*
|
|
|
|
* @param WP_User_Request $item Item being shown.
|
|
|
|
* @return string Human readable date.
|
|
|
|
*/
|
|
|
|
public function column_created_timestamp( $item ) {
|
|
|
|
return $this->get_timestamp_as_date( $item->created_timestamp );
|
2019-05-26 16:50:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Actions column. Overridden by children.
|
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
|
|
|
* @param WP_User_Request $item Item being shown.
|
|
|
|
* @return string Email column markup.
|
|
|
|
*/
|
|
|
|
public function column_email( $item ) {
|
|
|
|
return sprintf( '<a href="%1$s">%2$s</a> %3$s', esc_url( 'mailto:' . $item->email ), $item->email, $this->row_actions( array() ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Returns the markup for the next steps column. Overridden by children.
|
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 ) {}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Generates content for a single row of the table,
|
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*
|
|
|
|
* @param WP_User_Request $item The current item.
|
|
|
|
*/
|
|
|
|
public function single_row( $item ) {
|
|
|
|
$status = $item->status;
|
|
|
|
|
|
|
|
echo '<tr id="request-' . esc_attr( $item->ID ) . '" class="status-' . esc_attr( $status ) . '">';
|
|
|
|
$this->single_row_columns( $item );
|
|
|
|
echo '</tr>';
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2023-06-14 02:34:27 -04:00
|
|
|
* Embeds scripts used to perform actions. Overridden by children.
|
2019-05-26 16:50:53 -04:00
|
|
|
*
|
|
|
|
* @since 4.9.6
|
|
|
|
*/
|
|
|
|
public function embed_scripts() {}
|
|
|
|
}
|