Make WordPress Core

Changeset 50145


Ignore:
Timestamp:
02/02/2021 04:42:17 PM (3 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/includes/class-wp-privacy-requests-table.php

    r49333 r50145  
    485485     *
    486486     * @since 4.9.6
     487     * @since 5.7.0 Added `manage_{$this->screen->id}_custom_column` action.
    487488     *
    488489     * @param WP_User_Request $item        Item being shown.
    489490     * @param string          $column_name Name of column being shown.
    490      * @return string Default column output.
    491491     */
    492492    public function column_default( $item, $column_name ) {
    493         $cell_value = $item->$column_name;
    494 
    495         if ( in_array( $column_name, array( 'created_timestamp' ), true ) ) {
    496             return $this->get_timestamp_as_date( $cell_value );
    497         }
    498 
    499         return $cell_value;
     493        /**
     494         * Fires for each custom column of a specific request type in the Requests list table.
     495         *
     496         * Custom columns are registered using the {@see 'manage_export-personal-data_columns'}
     497         * and the {@see 'manage_erase-personal-data_columns'} filters.
     498         *
     499         * @since 5.7.0
     500         *
     501         * @param string          $column_name The name of the column to display.
     502         * @param WP_User_Request $item        The item being shown.
     503         */
     504        do_action( "manage_{$this->screen->id}_custom_column", $column_name, $item );
     505    }
     506
     507    /**
     508     * Created timestamp column. Overridden by children.
     509     *
     510     * @since 5.7.0
     511     *
     512     * @param WP_User_Request $item Item being shown.
     513     * @return string Human readable date.
     514     */
     515    public function column_created_timestamp( $item ) {
     516        return $this->get_timestamp_as_date( $item->created_timestamp );
    500517    }
    501518
Note: See TracChangeset for help on using the changeset viewer.