Make WordPress Core


Ignore:
Timestamp:
07/05/2016 09:42:06 PM (10 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r37962 r37979  
    183183        if ( 'on' === _x( 'off', 'decline months names: on or off' ) ) {
    184184                // Match a format like 'j F Y' or 'j. F'
    185                 if ( @preg_match( '#^\d{1,2}\.? \w+#u', $date ) ) {
    186                         $months = $wp_locale->month;
     185                if ( @preg_match( '#^\d{1,2}\.? [^\d ]+#u', $date ) ) {
     186                        $months          = $wp_locale->month;
     187                        $months_genitive = $wp_locale->month_genitive;
    187188
    188189                        foreach ( $months as $key => $month ) {
    189                                 $months[ $key ] = '#\b' . $month . '\b#u';
     190                                $months[ $key ] = '# ' . $month . '( |$)#u';
    190191                        }
    191192
    192                         $date = preg_replace( $months, $wp_locale->month_genitive, $date );
     193                        foreach ( $months_genitive as $key => $month ) {
     194                                $months_genitive[ $key ] = ' ' . $month . '$1';
     195                        }
     196
     197                        $date = preg_replace( $months, $months_genitive, $date );
    193198                }
    194199        }
Note: See TracChangeset for help on using the changeset viewer.