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
This commit is contained in:
Sergey Biryukov 2016-07-05 21:42:06 +00:00
parent fdb54dfe7b
commit eb176b40b8
1 changed files with 9 additions and 4 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 );
}
}