Make WordPress Core

Ticket #42394: 42394.4.diff

File 42394.4.diff, 1.4 KB (added by westonruter, 7 years ago)
  • src/wp-includes/customize/class-wp-customize-date-time-control.php

    diff --git src/wp-includes/customize/class-wp-customize-date-time-control.php src/wp-includes/customize/class-wp-customize-date-time-control.php
    index c163ba1408..fdaa6837dc 100644
    class WP_Customize_Date_Time_Control extends WP_Customize_Control { 
    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 );
    105                 }
    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 );
     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 ISO date 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                        $date_format = '%1$s-%2$s-%3$s';
    111110                }
    112111                ?>
    113112