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.

git-svn-id: https://develop.svn.wordpress.org/trunk@48912 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Sergey Biryukov
2020-08-31 15:56:41 +00:00
parent 34dc1cc2c9
commit 3309309f6b
5 changed files with 93 additions and 20 deletions
+8 -8
View File
@@ -2525,12 +2525,12 @@ function get_the_date( $format = '', $post = null ) {
return false;
}
if ( '' === $format ) {
$the_date = get_post_time( get_option( 'date_format' ), false, $post, true );
} else {
$the_date = get_post_time( $format, false, $post, true );
if ( ! is_string( $format ) || '' === $format ) {
$format = get_option( 'date_format' );
}
$the_date = get_post_time( $format, false, $post, true );
/**
* Filters the date a post was published.
*
@@ -2654,12 +2654,12 @@ function get_the_time( $format = '', $post = null ) {
return false;
}
if ( '' === $format ) {
$the_time = get_post_time( get_option( 'time_format' ), false, $post, true );
} else {
$the_time = get_post_time( $format, false, $post, true );
if ( ! is_string( $format ) || '' === $format ) {
$format = get_option( 'time_format' );
}
$the_time = get_post_time( $format, false, $post, true );
/**
* Filters the time a post was written.
*