Make WordPress Core

Ticket #37411: 37411.patch

File 37411.patch, 1.4 KB (added by SergeyBiryukov, 9 years ago)
  • src/wp-includes/functions.php

     
    181181         * translate this to 'on'. Do not translate into your own language.
    182182         */
    183183        if ( 'on' === _x( 'off', 'decline months names: on or off' ) ) {
     184                $months          = $wp_locale->month;
     185                $months_genitive = $wp_locale->month_genitive;
     186
    184187                // Match a format like 'j F Y' or 'j. F'
    185                 if ( @preg_match( '#^\d{1,2}\.? [^\d ]+#u', $date ) ) {
    186                         $months          = $wp_locale->month;
    187                         $months_genitive = $wp_locale->month_genitive;
    188 
     188                if ( @preg_match( '#^\d{1,2}\.? [^\d ]+#u', trim( $date ) ) ) {
    189189                        foreach ( $months as $key => $month ) {
    190190                                $months[ $key ] = '# ' . $month . '( |$)#u';
    191191                        }
     
    196196
    197197                        $date = preg_replace( $months, $months_genitive, $date );
    198198                }
     199
     200                // Match a format like 'F jS' or 'F j' and change it to 'j F'
     201                if ( @preg_match( '#^[^\d ]+ \d{1,2}(st|nd|rd|th)? #u', trim( $date ) ) ) {
     202                        foreach ( $months as $key => $month ) {
     203                                $months[ $key ] = '#' . $month . ' (\d{1,2})(st|nd|rd|th)?#u';
     204                        }
     205
     206                        foreach ( $months_genitive as $key => $month ) {
     207                                $months_genitive[ $key ] = '$1 ' . $month;
     208                        }
     209
     210                        $date = preg_replace( $months, $months_genitive, $date );
     211                }
    199212        }
    200213
    201214        // Used for locale-specific rules