Make WordPress Core

Ticket #44354: 44354.2.diff

File 44354.2.diff, 3.8 KB (added by pbiron, 6 years ago)

patch refresh and addition of 2 more hooks.

  • src/wp-admin/includes/class-wp-privacy-requests-table.php

    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 { 
    3434         * Get columns to show in the list table.
    3535         *
    3636         * @since 4.9.6
     37         * @since 5.3.0 Added `manage_privacy_requests_columns` and
     38         *              `manage_{$this->request_type}_columns` filters.
    3739         *
    3840         * @return array Array of columns.
    3941         */
    abstract class WP_Privacy_Requests_Table extends WP_List_Table { 
    4547                        'created_timestamp' => __( 'Requested' ),
    4648                        'next_steps'        => __( 'Next Steps' ),
    4749                );
    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 );
    4971        }
    5072
    5173        /**
    abstract class WP_Privacy_Requests_Table extends WP_List_Table { 
    391413         * Default column handler.
    392414         *
    393415         * @since 4.9.6
     416         * @since 5.3.0 Added `manage_privacy_request_custom_column` and
     417         *                    `manage_{$this->request_type}_custom_column` actions.
    394418         *
    395419         * @param WP_User_Request $item        Item being shown.
    396420         * @param string          $column_name Name of column being shown.
    397          * @return string Default column output.
    398421         */
    399422        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        }
    401446
    402                 if ( in_array( $column_name, array( 'created_timestamp' ), true ) ) {
    403                         return $this->get_timestamp_as_date( $cell_value );
    404                 }
    405447
    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 );
    407458        }
    408459
    409460        /**