From ce816eeda13357bfef79ea3bd96d0ffc8148e754 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 2 Feb 2021 16:44:04 +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. Built from https://develop.svn.wordpress.org/trunk@50145 git-svn-id: http://core.svn.wordpress.org/trunk@49824 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- .../class-wp-privacy-requests-table.php | 31 ++++++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/wp-admin/includes/class-wp-privacy-requests-table.php b/wp-admin/includes/class-wp-privacy-requests-table.php index bb1d445da7..4b2332ff9a 100644 --- a/wp-admin/includes/class-wp-privacy-requests-table.php +++ b/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 ); } /** diff --git a/wp-includes/version.php b/wp-includes/version.php index 582669cd3a..23a5e70ad7 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.7-alpha-50144'; +$wp_version = '5.7-alpha-50145'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.