Make WordPress Core

Ticket #42394: 42394.diff

File 42394.diff, 1.5 KB (added by Mirucon, 7 years ago)
  • wp-includes/customize/class-wp-customize-date-time-control.php

     
    100100                $timezone_info = $this->get_timezone_info();
    101101
    102102                $date_format = get_option( 'date_format' );
    103                 foreach ( array( 'Y', 'y', 'o' ) as $year_token ) {
    104                         $date_format = preg_replace( '/(?<!\\\\)' . $year_token . '/', '%1$s', $date_format );
     103                $date_format = preg_replace( '/(?<!\\\\)[Yyo]/', '%1$s', $date_format );
     104                $date_format = preg_replace( '/(?<!\\\\)[FmMn]/', '%2$s', $date_format );
     105                $date_format = preg_replace( '/(?<!\\\\)[jd]/', '%3$s', $date_format );
     106
     107                // Fallback to locate default format if year, month, or day are missing from the date format.
     108                if ( 1 !== substr_count( $date_format, '%1$s' ) || 1 !== substr_count( $date_format, '%2$s' ) || 1 !== substr_count( $date_format, '%3$s' ) ) {
     109                        /* translators: 1: year, 2: month, 3: day */
     110                        $date_format = __( '%1$s-%2$s-%3$s' );
    105111                }
    106                 foreach ( array( 'F', 'm', 'M', 'n' ) as $month_token ) {
    107                         $date_format = preg_replace( '/(?<!\\\\)' . $month_token . '/', '%2$s', $date_format );
    108                 }
    109                 foreach ( array( 'j', 'd' ) as $day_token ) {
    110                         $date_format = preg_replace( '/(?<!\\\\)' . $day_token . '/', '%3$s', $date_format );
    111                 }
    112112                ?>
    113113
    114114                <# _.defaults( data, <?php echo wp_json_encode( $data ); ?> ); #>