Date/Time: Make sure `get_the_date()` and related functions return correct time if the format was specified as `false`.
Technically, the `$format` argument should always be a string, but passing `false` used to work before [47808], so this restores backward compatibility. The list of affected functions: * `get_the_date()` * `get_the_time()` * `get_comment_date()` * `get_comment_time()` Props wittich, Rarst, akabarikalpesh, SergeyBiryukov. Fixes #51184. Built from https://develop.svn.wordpress.org/trunk@48912 git-svn-id: http://core.svn.wordpress.org/trunk@48674 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
e501d8ead8
commit
aec28121b3
|
@ -552,12 +552,12 @@ function get_comment_class( $class = '', $comment_id = null, $post_id = null ) {
|
||||||
function get_comment_date( $format = '', $comment_ID = 0 ) {
|
function get_comment_date( $format = '', $comment_ID = 0 ) {
|
||||||
$comment = get_comment( $comment_ID );
|
$comment = get_comment( $comment_ID );
|
||||||
|
|
||||||
if ( '' === $format ) {
|
if ( ! is_string( $format ) || '' === $format ) {
|
||||||
$date = mysql2date( get_option( 'date_format' ), $comment->comment_date );
|
$format = get_option( 'date_format' );
|
||||||
} else {
|
|
||||||
$date = mysql2date( $format, $comment->comment_date );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$date = mysql2date( $format, $comment->comment_date );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the returned comment date.
|
* Filters the returned comment date.
|
||||||
*
|
*
|
||||||
|
@ -1046,12 +1046,12 @@ function get_comment_time( $format = '', $gmt = false, $translate = true ) {
|
||||||
|
|
||||||
$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
|
$comment_date = $gmt ? $comment->comment_date_gmt : $comment->comment_date;
|
||||||
|
|
||||||
if ( '' === $format ) {
|
if ( ! is_string( $format ) || '' === $format ) {
|
||||||
$date = mysql2date( get_option( 'time_format' ), $comment_date, $translate );
|
$format = get_option( 'time_format' );
|
||||||
} else {
|
|
||||||
$date = mysql2date( $format, $comment_date, $translate );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$date = mysql2date( $format, $comment_date, $translate );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the returned comment time.
|
* Filters the returned comment time.
|
||||||
*
|
*
|
||||||
|
|
|
@ -2525,12 +2525,12 @@ function get_the_date( $format = '', $post = null ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( '' === $format ) {
|
if ( ! is_string( $format ) || '' === $format ) {
|
||||||
$the_date = get_post_time( get_option( 'date_format' ), false, $post, true );
|
$format = get_option( 'date_format' );
|
||||||
} else {
|
|
||||||
$the_date = get_post_time( $format, false, $post, true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$the_date = get_post_time( $format, false, $post, true );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the date a post was published.
|
* Filters the date a post was published.
|
||||||
*
|
*
|
||||||
|
@ -2654,12 +2654,12 @@ function get_the_time( $format = '', $post = null ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( '' === $format ) {
|
if ( ! is_string( $format ) || '' === $format ) {
|
||||||
$the_time = get_post_time( get_option( 'time_format' ), false, $post, true );
|
$format = get_option( 'time_format' );
|
||||||
} else {
|
|
||||||
$the_time = get_post_time( $format, false, $post, true );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$the_time = get_post_time( $format, false, $post, true );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Filters the time a post was written.
|
* Filters the time a post was written.
|
||||||
*
|
*
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @global string $wp_version
|
||||||
*/
|
*/
|
||||||
$wp_version = '5.6-alpha-48911';
|
$wp_version = '5.6-alpha-48912';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue