WP_Posts_List_Table::column_date( WP_Post $post )
Handles the post date column output.
Parameters
- $post
-
(Required) The current WP_Post object.
Source
File: wp-admin/includes/class-wp-posts-list-table.php
public function column_date( $post ) {
global $mode;
if ( '0000-00-00 00:00:00' === $post->post_date ) {
$t_time = $h_time = __( 'Unpublished' );
$time_diff = 0;
} else {
$t_time = get_the_time( __( 'Y/m/d g:i:s a' ) );
$m_time = $post->post_date;
$time = get_post_time( 'G', true, $post );
$time_diff = time() - $time;
if ( $time_diff > 0 && $time_diff < DAY_IN_SECONDS ) {
$h_time = sprintf( __( '%s ago' ), human_time_diff( $time ) );
} else {
$h_time = mysql2date( __( 'Y/m/d' ), $m_time );
}
}
if ( 'publish' === $post->post_status ) {
$status = __( 'Published' );
} elseif ( 'future' === $post->post_status ) {
if ( $time_diff > 0 ) {
$status = '<strong class="error-message">' . __( 'Missed schedule' ) . '</strong>';
} else {
$status = __( 'Scheduled' );
}
} else {
$status = __( 'Last Modified' );
}
/**
* Filters the status text of the post.
*
* @since WP-4.8.0
*
* @param string $status The status text.
* @param WP_Post $post Post object.
* @param string $column_name The column name.
* @param string $mode The list display mode ('excerpt' or 'list').
*/
$status = apply_filters( 'post_date_column_status', $status, $post, 'date', $mode );
if ( $status ) {
echo $status . '<br />';
}
if ( 'excerpt' === $mode ) {
/**
* Filters the published time of the post.
*
* If `$mode` equals 'excerpt', the published time and date are both displayed.
* If `$mode` equals 'list' (default), the publish date is displayed, with the
* time and date together available as an abbreviation definition.
*
* @since WP-2.5.1
*
* @param string $t_time The published time.
* @param WP_Post $post Post object.
* @param string $column_name The column name.
* @param string $mode The list display mode ('excerpt' or 'list').
*/
echo apply_filters( 'post_date_column_time', $t_time, $post, 'date', $mode );
} else {
/** This filter is documented in wp-admin/includes/class-wp-posts-list-table.php */
echo '<abbr title="' . $t_time . '">' . apply_filters( 'post_date_column_time', $h_time, $post, 'date', $mode ) . '</abbr>';
}
}
Changelog
Version | Description |
---|---|
4.3.0 | Introduced. |