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 ); |
| 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 | /** |
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 ); |
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 | | /** |