Date/Time: Bring some consistency to `the_date()` and `the_weekday_date()`:
* Make `the_date()` always apply the the filter and return a value. * Use `is_new_day()` in `the_weekday_date()`. * Add a unit test for `the_weekday_date()`. Fixes #47354. Built from https://develop.svn.wordpress.org/trunk@45378 git-svn-id: http://core.svn.wordpress.org/trunk@45189 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
0b66be9cd7
commit
ed08643734
|
@ -2340,9 +2340,12 @@ function the_date_xml() {
|
|||
function the_date( $d = '', $before = '', $after = '', $echo = true ) {
|
||||
global $currentday, $previousday;
|
||||
|
||||
$the_date = '';
|
||||
|
||||
if ( is_new_day() ) {
|
||||
$the_date = $before . get_the_date( $d ) . $after;
|
||||
$previousday = $currentday;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the date a post was published for display.
|
||||
|
@ -2362,7 +2365,6 @@ function the_date( $d = '', $before = '', $after = '', $echo = true ) {
|
|||
} else {
|
||||
return $the_date;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2702,19 +2704,21 @@ function the_weekday() {
|
|||
*
|
||||
* @global WP_Locale $wp_locale The WordPress date and time locale object.
|
||||
* @global string $currentday The day of the current post in the loop.
|
||||
* @global string $previousweekday The day of the previous post in the loop.
|
||||
* @global string $previousday The day of the previous post in the loop.
|
||||
*
|
||||
* @param string $before Optional. Output before the date.
|
||||
* @param string $after Optional. Output after the date.
|
||||
*/
|
||||
function the_weekday_date( $before = '', $after = '' ) {
|
||||
global $wp_locale, $currentday, $previousweekday;
|
||||
global $wp_locale, $currentday, $previousday;
|
||||
|
||||
$the_weekday_date = '';
|
||||
if ( $currentday != $previousweekday ) {
|
||||
|
||||
if ( is_new_day() ) {
|
||||
$the_weekday_date .= $before;
|
||||
$the_weekday_date .= $wp_locale->get_weekday( mysql2date( 'w', get_post()->post_date, false ) );
|
||||
$the_weekday_date .= $after;
|
||||
$previousweekday = $currentday;
|
||||
$previousday = $currentday;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -2726,8 +2730,7 @@ function the_weekday_date( $before = '', $after = '' ) {
|
|||
* @param string $before The HTML to output before the date.
|
||||
* @param string $after The HTML to output after the date.
|
||||
*/
|
||||
$the_weekday_date = apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
|
||||
echo $the_weekday_date;
|
||||
echo apply_filters( 'the_weekday_date', $the_weekday_date, $before, $after );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.3-alpha-45377';
|
||||
$wp_version = '5.3-alpha-45378';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue