Make WordPress Core

Ticket #44354: 44354.3.diff

File 44354.3.diff, 6.1 KB (added by garrett-eclipse, 3 years ago)

Refresh

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

     
    3434         * Get columns to show in the list table.
    3535         *
    3636         * @since 4.9.6
     37         * @since 5.6.0 Added `manage_privacy_requests_columns` and
     38         *              `manage_{$this->request_type}_columns` filters.
    3739         *
    3840         * @return string[] Array of column titles keyed by their column name.
    3941         */
     
    4547                        'created_timestamp' => __( 'Requested' ),
    4648                        'next_steps'        => __( 'Next Steps' ),
    4749                );
    48                 return $columns;
     50
     51                /**
     52                 * Filters the columns displayed in the user privacy requests list tables.
     53                 *
     54                 * @since 5.6.0
     55                 *
     56                 * @param string[] $columns      An associative array of column headings.
     57                 * @param string   $request_type The user privacy request type.
     58                 */
     59                $columns = apply_filters( 'manage_privacy_requests_columns', $columns, $this->request_type );
     60
     61                /**
     62                 * Filters the columns displayed in the user privacy requests list table for a specific request type.
     63                 *
     64                 * The dynamic portion of the hook name, `$this->request_type`,
     65                 * refers to the user privacy request type.
     66                 *
     67                 * @since 5.6.0
     68                 *
     69                 * @param string[] $columns An associative array of column headings.
     70                 */
     71                return apply_filters( "manage_{$this->request_type}_columns", $columns );
    4972        }
    5073
    5174        /**
     
    320343        }
    321344
    322345        /**
     346         * Convert timestamp for display.
     347         *
     348         * @since 4.9.6
     349         *
     350         * @param int $timestamp Event timestamp.
     351         * @return string Human readable date.
     352         */
     353        protected function get_timestamp_as_date( $timestamp ) {
     354                if ( empty( $timestamp ) ) {
     355                        return '';
     356                }
     357
     358                $time_diff = time() - $timestamp;
     359
     360                if ( $time_diff >= 0 && $time_diff < DAY_IN_SECONDS ) {
     361                        /* translators: %s: Human-readable time difference. */
     362                        return sprintf( __( '%s ago' ), human_time_diff( $timestamp ) );
     363                }
     364
     365                return date_i18n( get_option( 'date_format' ), $timestamp );
     366        }
     367
     368        /**
     369         * Default column handler.
     370         *
     371         * @since 4.9.6
     372         * @since 5.6.0 Added `manage_privacy_request_custom_column` and
     373         *                    `manage_{$this->request_type}_custom_column` actions.
     374         *
     375         * @param WP_User_Request $item        The user privacy request item being shown.
     376         * @param string          $column_name Name of column being shown.
     377         */
     378        public function column_default( $item, $column_name ) {
     379                /**
     380                 * Fires for each custom column in the privacy requests list table.
     381                 *
     382                 * @since 5.6.0
     383                 *
     384                 * @param string          $column_name  The name of the column to display.
     385                 * @param WP_User_Request $item         The user privacy request item being shown.
     386                 * @param string          $request_type The user privacy request type.
     387                 */
     388                do_action( 'manage_privacy_request_custom_column', $column_name, $item, $this->request_type );
     389
     390                /**
     391                 * Fires for each custom column of a specific request type in the user privacy requests list table.
     392                 *
     393                 * The dynamic portion of the hook name, `$this->request_type`, refers to the user privacy request type.
     394                 *
     395                 * @since 5.6.0
     396                 *
     397                 * @param string          $column_name The name of the column to display.
     398                 * @param WP_User_Request $item        The user privacy request item being shown.
     399                 */
     400                do_action( "manage_{$this->request_type}_custom_column", $column_name, $item );
     401                return;
     402        }
     403
     404        /**
    323405         * Checkbox column.
    324406         *
    325407         * @since 4.9.6
    326408         *
    327          * @param WP_User_Request $item Item being shown.
     409         * @param WP_User_Request $item The user privacy request item being shown.
    328410         * @return string Checkbox column markup.
    329411         */
    330412        public function column_cb( $item ) {
     
    336418         *
    337419         * @since 4.9.6
    338420         *
    339          * @param WP_User_Request $item Item being shown.
     421         * @param WP_User_Request $item The user privacy request item being shown.
    340422         * @return string Status column markup.
    341423         */
    342424        public function column_status( $item ) {
     
    369451        }
    370452
    371453        /**
    372          * Convert timestamp for display.
     454         * Created timestamp column. Overridden by children.
    373455         *
    374          * @since 4.9.6
     456         * @since 5.6.0
    375457         *
    376          * @param int $timestamp Event timestamp.
     458         * @param WP_User_Request $item The user privacy request item being shown.
    377459         * @return string Human readable date.
    378460         */
    379         protected function get_timestamp_as_date( $timestamp ) {
    380                 if ( empty( $timestamp ) ) {
    381                         return '';
    382                 }
    383 
    384                 $time_diff = time() - $timestamp;
    385 
    386                 if ( $time_diff >= 0 && $time_diff < DAY_IN_SECONDS ) {
    387                         /* translators: %s: Human-readable time difference. */
    388                         return sprintf( __( '%s ago' ), human_time_diff( $timestamp ) );
    389                 }
    390 
    391                 return date_i18n( get_option( 'date_format' ), $timestamp );
     461        public function column_created_timestamp( $item ) {
     462                return $this->get_timestamp_as_date( $item->created_timestamp );
    392463        }
    393464
    394465        /**
    395          * Default column handler.
    396          *
    397          * @since 4.9.6
    398          *
    399          * @param WP_User_Request $item        Item being shown.
    400          * @param string          $column_name Name of column being shown.
    401          * @return string Default column output.
    402          */
    403         public function column_default( $item, $column_name ) {
    404                 $cell_value = $item->$column_name;
    405 
    406                 if ( in_array( $column_name, array( 'created_timestamp' ), true ) ) {
    407                         return $this->get_timestamp_as_date( $cell_value );
    408                 }
    409 
    410                 return $cell_value;
    411         }
    412 
    413         /**
    414466         * Actions column. Overridden by children.
    415467         *
    416468         * @since 4.9.6
    417469         *
    418          * @param WP_User_Request $item Item being shown.
     470         * @param WP_User_Request $item The user privacy request item being shown.
    419471         * @return string Email column markup.
    420472         */
    421473        public function column_email( $item ) {
     
    427479         *
    428480         * @since 4.9.6
    429481         *
    430          * @param WP_User_Request $item Item being shown.
     482         * @param WP_User_Request $item The user privacy request item being shown.
    431483         */
    432484        public function column_next_steps( $item ) {}
    433485
     
    436488         *
    437489         * @since 4.9.6
    438490         *
    439          * @param WP_User_Request $item The current item.
     491         * @param WP_User_Request $item The user privacy request item being shown.
    440492         */
    441493        public function single_row( $item ) {
    442494                $status = $item->status;