WordPress.org

Make WordPress Core

Changeset 42111


Ignore:
Timestamp:
11/02/17 22:59:04 (3 weeks ago)
Author:
westonruter
Message:

Customize: Present the date/time control input fields in the same format (and order) as date_format.

Props westonruter, obenland, atachibana for testing, Mirucon for testing.
See #42373, #28721.
Fixes #42394.

Location:
trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/css/customize-controls.css

    r42046 r42111  
    333333} 
    334334 
    335 .customize-control.customize-control-date_time .date-time-fields .date-input, 
    336 .customize-control.customize-control-date_time .date-time-fields .date-time-separator { 
    337     float: left; 
    338     margin-right: 5px; 
    339 } 
    340335.customize-control.customize-control-date_time .date-time-fields .date-input.day { 
    341336    margin-right: 0; 
     
    362357} 
    363358 
    364 .date-time-fields .date-time-separator { 
    365     line-height: 2; 
    366 } 
    367  
    368359.date-time-fields .time-row { 
    369360    margin-top: 12px; 
     
    371362 
    372363.date-time-fields .date-timezone { 
    373     float: left; 
    374364    line-height: 2.2; 
    375365    text-decoration: none; 
     
    28312821    } 
    28322822 
    2833     .date-time-fields .date-time-separator, 
    28342823    .date-time-fields .date-timezone { 
    28352824        line-height: 3.2; 
  • trunk/src/wp-includes/customize/class-wp-customize-date-time-control.php

    r42042 r42111  
    9999        $data = array_merge( $this->json(), $this->get_month_choices() ); 
    100100        $timezone_info = $this->get_timezone_info(); 
     101 
     102        $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 ); 
     111        } 
    101112        ?> 
    102113 
     
    117128                <legend class="title-day {{ ! data.includeTime ? 'screen-reader-text' : '' }}"><?php esc_html_e( 'Date' ); ?></legend> 
    118129                <div class="day-fields clear"> 
     130                    <?php ob_start(); ?> 
    119131                    <label for="{{ idPrefix }}date-time-month" class="screen-reader-text"><?php esc_html_e( 'Month' ); ?></label> 
    120132                    <select id="{{ idPrefix }}date-time-month" class="date-input month" data-component="month"> 
     
    130142                        <# } ); #> 
    131143                    </select> 
     144                    <?php $month_field = trim( ob_get_clean() ); ?> 
     145 
     146                    <?php ob_start(); ?> 
    132147                    <label for="{{ idPrefix }}date-time-day" class="screen-reader-text"><?php esc_html_e( 'Day' ); ?></label> 
    133148                    <input id="{{ idPrefix }}date-time-day" type="number" size="2" autocomplete="off" class="date-input day" data-component="day" min="1" max="31" /> 
    134                     <span class="time-special-char date-time-separator">,</span> 
     149                    <?php $day_field = trim( ob_get_clean() ); ?> 
     150 
     151                    <?php ob_start(); ?> 
    135152                    <label for="{{ idPrefix }}date-time-year" class="screen-reader-text"><?php esc_html_e( 'Year' ); ?></label> 
    136153                    <input id="{{ idPrefix }}date-time-year" type="number" size="4" autocomplete="off" class="date-input year" data-component="year" min="{{ data.minYear }}" max="{{ data.maxYear }}"> 
     154                    <?php $year_field = trim( ob_get_clean() ); ?> 
     155 
     156                    <?php printf( $date_format, $year_field, $month_field, $day_field ); ?> 
    137157                </div> 
    138158            </fieldset> 
     
    145165                        <# var minHour = data.twelveHourFormat ? 1 : 0; #> 
    146166                        <input id="{{ idPrefix }}date-time-hour" type="number" size="2" autocomplete="off" class="date-input hour" data-component="hour" min="{{ minHour }}" max="{{ maxHour }}"> 
    147                         <span class="time-special-char date-time-separator">:</span> 
     167                        : 
    148168                        <label for="{{ idPrefix }}date-time-minute" class="screen-reader-text"><?php esc_html_e( 'Minute' ); ?></label> 
    149169                        <input id="{{ idPrefix }}date-time-minute" type="number" size="2" autocomplete="off" class="date-input minute" data-component="minute" min="0" max="59"> 
Note: See TracChangeset for help on using the changeset viewer.