From eb176b40b8e3bedc41f3cf6584dd2b94ce891a99 Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Tue, 5 Jul 2016 21:42:06 +0000 Subject: [PATCH] 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. git-svn-id: https://develop.svn.wordpress.org/trunk@37979 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 6075f09b51..24a0431fea 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -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 ); } }