Customize: Fall back to ISO date format for date/time control inputs if year, month, or day are missing from the `date_format` option.

Amends [42111].
Props dlh, westonruter.
Fixes #42394.

Built from https://develop.svn.wordpress.org/trunk@42117


git-svn-id: http://core.svn.wordpress.org/trunk@41946 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Weston Ruter 2017-11-06 20:28:48 +00:00
parent b8de3548d3
commit c15b2a0908
2 changed files with 8 additions and 9 deletions

View File

@ -100,14 +100,13 @@ class WP_Customize_Date_Time_Control extends WP_Customize_Control {
$timezone_info = $this->get_timezone_info();
$date_format = get_option( 'date_format' );
foreach ( array( 'Y', 'y', 'o' ) as $year_token ) {
$date_format = preg_replace( '/(?<!\\\\)' . $year_token . '/', '%1$s', $date_format );
}
foreach ( array( 'F', 'm', 'M', 'n' ) as $month_token ) {
$date_format = preg_replace( '/(?<!\\\\)' . $month_token . '/', '%2$s', $date_format );
}
foreach ( array( 'j', 'd' ) as $day_token ) {
$date_format = preg_replace( '/(?<!\\\\)' . $day_token . '/', '%3$s', $date_format );
$date_format = preg_replace( '/(?<!\\\\)[Yyo]/', '%1$s', $date_format );
$date_format = preg_replace( '/(?<!\\\\)[FmMn]/', '%2$s', $date_format );
$date_format = preg_replace( '/(?<!\\\\)[jd]/', '%3$s', $date_format );
// Fallback to ISO date format if year, month, or day are missing from the date format.
if ( 1 !== substr_count( $date_format, '%1$s' ) || 1 !== substr_count( $date_format, '%2$s' ) || 1 !== substr_count( $date_format, '%3$s' ) ) {
$date_format = '%1$s-%2$s-%3$s';
}
?>

View File

@ -4,7 +4,7 @@
*
* @global string $wp_version
*/
$wp_version = '4.9-RC1-42116';
$wp_version = '4.9-RC1-42117';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.