-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Enhance classic editor timestamp fields with native controls #12275
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: trunk
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -479,6 +479,46 @@ form#tags-filter { | |
| height: auto !important; | ||
| } | ||
|
|
||
| .misc-pub-curtime { | ||
| display: grid; | ||
| grid-template-columns: 27px minmax( 0, 1fr ); | ||
| } | ||
|
|
||
| .misc-pub-curtime .timestamp-display { | ||
| grid-column: 2; | ||
| min-width: 0; | ||
| } | ||
|
|
||
| .misc-pub-curtime:before { | ||
| content: "\f145"; | ||
| content: "\f145" / ''; | ||
| font: normal 20px/1 dashicons; | ||
| grid-column: 1; | ||
| grid-row: 1; | ||
| margin-left: -1px; | ||
| padding-right: 3px; | ||
| position: relative; | ||
| top: -1px; | ||
| -webkit-font-smoothing: antialiased; | ||
| -moz-osx-font-smoothing: grayscale; | ||
| } | ||
|
|
||
| .misc-pub-curtime #timestamp:before { | ||
| content: none; | ||
| } | ||
|
|
||
| .misc-pub-curtime .edit-timestamp { | ||
| margin-left: 0; | ||
| } | ||
|
|
||
| .misc-pub-curtime .edit-timestamp-label { | ||
| white-space: nowrap; | ||
| } | ||
|
|
||
| .misc-pub-curtime #timestampdiv { | ||
| grid-column: 1 / -1; | ||
| } | ||
|
|
||
| #post-body .misc-pub-post-status:before, | ||
| #post-body #visibility:before, | ||
| .curtime #timestamp:before, | ||
|
|
@@ -525,6 +565,10 @@ form#tags-filter { | |
| top: -1px; | ||
| } | ||
|
|
||
| .misc-pub-curtime #timestamp:before { | ||
| content: none; | ||
| } | ||
|
Comment on lines
+568
to
+570
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is duplicated |
||
|
|
||
| #post-body .misc-pub-uploadedby:before { | ||
| content: "\f110"; | ||
| content: "\f110" / ''; | ||
|
|
@@ -562,6 +606,41 @@ form#tags-filter { | |
| text-align: center; | ||
| } | ||
|
|
||
| #timestampdiv.has-native-timestamp-fields { | ||
| padding-top: 0; | ||
| } | ||
|
|
||
| #timestampdiv .timestamp-native-wrap { | ||
| margin: 3px 0 0; | ||
| } | ||
|
|
||
| #timestampdiv.has-native-timestamp-fields .timestamp-native-wrap { | ||
| display: grid; | ||
| gap: 8px; | ||
| } | ||
|
|
||
| #timestampdiv.has-native-timestamp-fields .timestamp-actions { | ||
| margin-top: 8px; | ||
| } | ||
|
|
||
| #timestampdiv .timestamp-native-wrap input { | ||
| box-sizing: border-box; | ||
| text-align: left; | ||
| width: 100%; | ||
| } | ||
|
|
||
| #timestampdiv .timestamp-native-wrap input.form-invalid, | ||
| #timestampdiv .timestamp-native-wrap input.form-invalid:focus { | ||
| border-color: #d63638 !important; | ||
| box-shadow: 0 0 2px rgba(214, 54, 56, 0.8); | ||
| } | ||
|
|
||
| #timestampdiv .timestamp-site-time { | ||
| color: #646970; | ||
| font-size: 12px; | ||
| margin: -2px 0 0; | ||
| } | ||
|
|
||
| .notification-dialog { | ||
| position: fixed; | ||
| top: 30%; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -285,18 +285,20 @@ function post_submit_meta_box( $post, $args = array() ) { | |
| if ( $can_publish ) : // Contributors don't get to choose the date of publish. | ||
| ?> | ||
| <div class="misc-pub-section curtime misc-pub-curtime"> | ||
| <span id="timestamp"> | ||
| <?php printf( $stamp, '<b>' . $date . '</b>' ); ?> | ||
| </span> | ||
| <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" role="button"> | ||
| <span aria-hidden="true"><?php _e( 'Edit' ); ?></span> | ||
| <span class="screen-reader-text"> | ||
| <?php | ||
| /* translators: Hidden accessibility text. */ | ||
| _e( 'Edit date and time' ); | ||
| ?> | ||
| <span class="timestamp-display"> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Noting that some of these markup changes might be necessary below in some of the other meta boxes. Or we need to ensure that our CSS changes affect only this one. But right now the changes may affect the other meta boxes in weird ways because some of those markup changes are missing |
||
| <span id="timestamp"> | ||
| <?php printf( $stamp, '<b>' . $date . '</b>' ); ?> | ||
| </span> | ||
| </a> | ||
| <a href="#edit_timestamp" class="edit-timestamp hide-if-no-js" role="button"> | ||
| <span aria-hidden="true" class="edit-timestamp-label"><?php _e( 'Edit' ); ?></span> | ||
| <span class="screen-reader-text"> | ||
| <?php | ||
| /* translators: Hidden accessibility text. */ | ||
| _e( 'Edit date and time' ); | ||
| ?> | ||
| </span> | ||
| </a> | ||
| </span> | ||
| <fieldset id="timestampdiv" class="hide-if-js"> | ||
| <legend class="screen-reader-text"> | ||
| <?php | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -831,6 +831,12 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { | |
| $cur_hh = current_time( 'H' ); | ||
| $cur_mn = current_time( 'i' ); | ||
|
|
||
| $timezone = wp_timezone_string(); | ||
| if ( preg_match( '/^([+-])(\d{2}):(\d{2})$/', $timezone, $timezone_matches ) ) { | ||
| $timezone = 'UTC' . $timezone_matches[1] . (int) $timezone_matches[2]; | ||
| $timezone .= ( '00' === $timezone_matches[3] ) ? '' : ':' . $timezone_matches[3]; | ||
| } | ||
|
Comment on lines
+834
to
+838
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| $month = '<label><span class="screen-reader-text">' . | ||
| /* translators: Hidden accessibility text. */ | ||
| __( 'Month' ) . | ||
|
|
@@ -865,7 +871,29 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { | |
| /* translators: 1: Month, 2: Day, 3: Year, 4: Hour, 5: Minute. */ | ||
| printf( __( '%1$s %2$s, %3$s at %4$s:%5$s' ), $month, $day, $year, $hour, $minute ); | ||
|
|
||
| echo '</div><input type="hidden" id="ss" name="ss" value="' . $ss . '" />'; | ||
| echo '</div>'; | ||
|
|
||
| if ( $for_post && ! $multi ) { | ||
| ?> | ||
| <div class="timestamp-native-wrap hide-if-no-js" hidden> | ||
| <label for="publish-date-native" class="screen-reader-text"><?php _e( 'Date' ); ?></label> | ||
| <input type="date" id="publish-date-native" class="form-required" value="<?php echo esc_attr( $aa . '-' . $mm . '-' . $jj ); ?>" /> | ||
| <label for="publish-time-native" class="screen-reader-text"><?php _e( 'Time' ); ?></label> | ||
| <input type="time" id="publish-time-native" class="form-required" value="<?php echo esc_attr( $hh . ':' . $mn ); ?>" /> | ||
| <p class="timestamp-site-time"> | ||
| <?php | ||
| printf( | ||
| /* translators: %s: The site's timezone. */ | ||
| __( 'Site time: %s' ), | ||
| '<span>' . esc_html( $timezone ) . '</span>' | ||
| ); | ||
| ?> | ||
| </p> | ||
| </div> | ||
| <?php | ||
| } | ||
|
|
||
| echo '<input type="hidden" id="ss" name="ss" value="' . $ss . '" />'; | ||
|
|
||
| if ( $multi ) { | ||
| return; | ||
|
|
@@ -890,7 +918,7 @@ function touch_time( $edit = 1, $for_post = 1, $tab_index = 0, $multi = 0 ) { | |
| } | ||
| ?> | ||
|
|
||
| <p> | ||
| <p class="timestamp-actions"> | ||
| <a href="#edit_timestamp" class="save-timestamp hide-if-no-js button"><?php _e( 'OK' ); ?></a> | ||
| <a href="#edit_timestamp" class="cancel-timestamp hide-if-no-js button-cancel"><?php _e( 'Cancel' ); ?></a> | ||
| </p> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we make these selectors consistent?