diff --git a/wp-includes/functions.php b/wp-includes/functions.php index 5dfbf58697..ba7ad34036 100644 --- a/wp-includes/functions.php +++ b/wp-includes/functions.php @@ -219,10 +219,12 @@ function wp_maybe_decline_date( $date ) { * translate this to 'on'. Do not translate into your own language. */ if ( 'on' === _x( 'off', 'decline months names: on or off' ) ) { + + $months = $wp_locale->month; + $months_genitive = $wp_locale->month_genitive; + // Match a format like 'j F Y' or 'j. F' if ( @preg_match( '#^\d{1,2}\.? [^\d ]+#u', $date ) ) { - $months = $wp_locale->month; - $months_genitive = $wp_locale->month_genitive; foreach ( $months as $key => $month ) { $months[ $key ] = '# ' . $month . '( |$)#u'; @@ -234,6 +236,19 @@ function wp_maybe_decline_date( $date ) { $date = preg_replace( $months, $months_genitive, $date ); } + + // Match a format like 'F jS' or 'F j' and change it to 'j F' + if ( @preg_match( '#^[^\d ]+ \d{1,2}(st|nd|rd|th)? #u', trim( $date ) ) ) { + foreach ( $months as $key => $month ) { + $months[ $key ] = '#' . $month . ' (\d{1,2})(st|nd|rd|th)?#u'; + } + + foreach ( $months_genitive as $key => $month ) { + $months_genitive[ $key ] = '$1 ' . $month; + } + + $date = preg_replace( $months, $months_genitive, $date ); + } } // Used for locale-specific rules diff --git a/wp-includes/version.php b/wp-includes/version.php index 4f0a37560a..93f9e8b1f2 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-45554'; +$wp_version = '5.3-alpha-45555'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.