From 0b9cff29e47ecf538588b4d6ed03c55c386daf9b Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 2 Feb 2021 16:42:17 +0000 Subject: [PATCH] Privacy: Introduce `manage_{$this->screen->id}_custom_column` action in `WP_Privacy_Requests_Table::column_default()`. This brings some consistency with other list tables and allows for adding custom column data to columns registered with `manage_export-personal-data_columns` or `manage_erase-personal-data_columns` filters. Props xkon, garrett-eclipse, birgire, pbiron, hellofromTonya, TimothyBlynJacobs, 7studio, mukesh27, Mista-Flo. Fixes #44354. git-svn-id: https://develop.svn.wordpress.org/trunk@50145 602fd350-edb4-49c9-b593-d223f7449a82 --- .../class-wp-privacy-requests-table.php | 31 ++++++++++++++----- 1 file changed, 24 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 bb1d445da7..4b2332ff9a 100644 --- a/src/wp-admin/includes/class-wp-privacy-requests-table.php +++ b/src/wp-admin/includes/class-wp-privacy-requests-table.php @@ -484,19 +484,36 @@ abstract class WP_Privacy_Requests_Table extends WP_List_Table { * Default column handler. * * @since 4.9.6 + * @since 5.7.0 Added `manage_{$this->screen->id}_custom_column` action. * * @param WP_User_Request $item Item being shown. * @param string $column_name Name of column being shown. - * @return string Default column output. */ public function column_default( $item, $column_name ) { - $cell_value = $item->$column_name; + /** + * 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 ); + } - if ( in_array( $column_name, array( 'created_timestamp' ), true ) ) { - return $this->get_timestamp_as_date( $cell_value ); - } - - return $cell_value; + /** + * Created timestamp column. Overridden by children. + * + * @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 ); } /**