I18N: Adjust the regex in `wp_maybe_decline_date()` to avoid `\w` and `\b`, as they don't work with Unicode characters correctly in PHP 5.3.3 and earlier versions.

See [37975] for unit tests.

See #36790.
Built from https://develop.svn.wordpress.org/trunk@37979


git-svn-id: http://core.svn.wordpress.org/trunk@37920 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2016-07-05 21:43:30 +00:00
parent bfe46464c5
commit de1fab0b66
2 changed files with 10 additions and 5 deletions

View File

@ -182,14 +182,19 @@ function wp_maybe_decline_date( $date ) {
*/
if ( 'on' === _x( 'off', 'decline months names: on or off' ) ) {
// Match a format like 'j F Y' or 'j. F'
if ( @preg_match( '#^\d{1,2}\.? \w+#u', $date ) ) {
$months = $wp_locale->month;
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 ] = '#\b' . $month . '\b#u';
$months[ $key ] = '# ' . $month . '( |$)#u';
}
$date = preg_replace( $months, $wp_locale->month_genitive, $date );
foreach ( $months_genitive as $key => $month ) {
$months_genitive[ $key ] = ' ' . $month . '$1';
}
$date = preg_replace( $months, $months_genitive, $date );
}
}

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.6-beta1-37978';
$wp_version = '4.6-beta1-37979';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.