From 6a64367866710e3055a5ce4b970955b3465a4858 Mon Sep 17 00:00:00 2001
From: Paul Biron <paul@sparrowhawkcomputing.com>
Date: Fri, 7 Jun 2019 16:31:46 -0600
Subject: [PATCH] Improve `WP_Privacy_Requests_Table` to manage columns.
---
.../class-wp-privacy-requests-table.php | 65 +++++++++++++++++--
1 file changed, 58 insertions(+), 7 deletions(-)
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 fe5a516431..faf8822b90 100644
a
|
b
|
abstract class WP_Privacy_Requests_Table extends WP_List_Table { |
34 | 34 | * Get columns to show in the list table. |
35 | 35 | * |
36 | 36 | * @since 4.9.6 |
| 37 | * @since 5.3.0 Added `manage_privacy_requests_columns` and |
| 38 | * `manage_{$this->request_type}_columns` filters. |
37 | 39 | * |
38 | 40 | * @return array Array of columns. |
39 | 41 | */ |
… |
… |
abstract class WP_Privacy_Requests_Table extends WP_List_Table { |
45 | 47 | 'created_timestamp' => __( 'Requested' ), |
46 | 48 | 'next_steps' => __( 'Next Steps' ), |
47 | 49 | ); |
48 | | return $columns; |
| 50 | |
| 51 | /** |
| 52 | * Filters the columns displayed in the Requests list table. |
| 53 | * |
| 54 | * @since 5.3.0 |
| 55 | * |
| 56 | * @param string[] $columns An associative array of column headings. |
| 57 | * @param string $request_type The request type. |
| 58 | */ |
| 59 | $columns = apply_filters( 'manage_privacy_requests_columns', $columns, $this->request_type ); |
| 60 | |
| 61 | /** |
| 62 | * Filters the columns displayed in the Requests list table for a specific request type. |
| 63 | * |
| 64 | * The dynamic portion of the hook name, `$this->request_type`, refers to the request type. |
| 65 | * |
| 66 | * @since 5.3.0 |
| 67 | * |
| 68 | * @param string[] $columns An associative array of column headings. |
| 69 | */ |
| 70 | return apply_filters( "manage_{$this->request_type}_columns", $columns ); |
49 | 71 | } |
50 | 72 | |
51 | 73 | /** |
… |
… |
abstract class WP_Privacy_Requests_Table extends WP_List_Table { |
391 | 413 | * Default column handler. |
392 | 414 | * |
393 | 415 | * @since 4.9.6 |
| 416 | * @since 5.3.0 Added `manage_privacy_request_custom_column` and |
| 417 | * `manage_{$this->request_type}_custom_column` actions. |
394 | 418 | * |
395 | 419 | * @param WP_User_Request $item Item being shown. |
396 | 420 | * @param string $column_name Name of column being shown. |
397 | | * @return string Default column output. |
398 | 421 | */ |
399 | 422 | public function column_default( $item, $column_name ) { |
400 | | $cell_value = $item->$column_name; |
| 423 | /** |
| 424 | * Fires for each custom column of in the Requests list table. |
| 425 | * |
| 426 | * @since 5.3.0 |
| 427 | * |
| 428 | * @param string $column_name The name of the column to display. |
| 429 | * @param WP_User_Request $item The item being shown. |
| 430 | * @param string $request_type The request type. |
| 431 | */ |
| 432 | do_action( 'manage_privacy_request_custom_column', $column_name, $item, $this->request_type ); |
| 433 | |
| 434 | /** |
| 435 | * Fires for each custom column of a specific request type in the Requests list table. |
| 436 | * |
| 437 | * The dynamic portion of the hook name, `$this->request_type`, refers to the request type. |
| 438 | * |
| 439 | * @since 5.3.0 |
| 440 | * |
| 441 | * @param string $column_name The name of the column to display. |
| 442 | * @param WP_User_Request $item The item being shown. |
| 443 | */ |
| 444 | do_action( "manage_{$this->request_type}_custom_column", $column_name, $item ); |
| 445 | } |
401 | 446 | |
402 | | if ( in_array( $column_name, array( 'created_timestamp' ), true ) ) { |
403 | | return $this->get_timestamp_as_date( $cell_value ); |
404 | | } |
405 | 447 | |
406 | | return $cell_value; |
| 448 | /** |
| 449 | * Created timestamp column. Overridden by children. |
| 450 | * |
| 451 | * @since 5.3.0 |
| 452 | * |
| 453 | * @param WP_User_Request $item Item being shown. |
| 454 | * @return string Human readable date. |
| 455 | */ |
| 456 | public function column_created_timestamp( $item ) { |
| 457 | return $this->get_timestamp_as_date( $item->created_timestamp ); |
407 | 458 | } |
408 | 459 | |
409 | 460 | /** |