-
Notifications
You must be signed in to change notification settings - Fork 37
Conversation
</select> | ||
<# } else { #> | ||
<input | ||
type="text" |
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.
@johnregan3 Can we use number
as input type with max
and min
attributes?
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.
@PatelUtkarsh I would love to do that. I think it would help greatly with validation. @westonruter How closely do we want to match the existing interface? It uses simple text inputs.
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.
In number input that arrows(up and down) make it smaller(input needs more space) so maybe that's why the core is not using it?
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.
@PatelUtkarsh You know, I'm not really sure. I think they would just rather leave it alone since it's been used for so long. However, I think it's time for an update of that whole metabox. in addition to the UI changes, the JS for the date function could be greatly improved.
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.
How closely do we want to match the existing interface? It uses simple text inputs.
I really don't like the existing interface 😄
function getDateInputData() { | ||
var date, result = {}, singleCharLimit = 9; | ||
|
||
date = new Date( postData.post_date ); |
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.
Beware of timezones.
I've added a new scheduled countdown to appear with the timezone information when the status is If the time status is And again, you can reset the time to be empty so that it will update with the current time (notice placeholders). As noted above, clicking this button will cause the In these examples, notice that I've moved the description below the input fields. I'm still very much unhappy with how I've “designed” the info under the control. I don't like how the description and the reset button look. They should perhaps be collapsed by default in some |
<?php | ||
$tz_string = get_option( 'timezone_string' ); | ||
if ( $tz_string ) { | ||
$tz = new DateTimezone( get_option( 'timezone_string' ) ); |
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.
Reuse $tz_string
@westonruter or maybe a reset icon (this one's a refresh icon though) |
@ahmadawais great! Re: your tweet, I think to implement these changes, you'd add the appropriate CSS to wp-customize-posts/css/customize-posts.css Lines 224 to 236 in ebf331e
customize-control-title :
Open a PR to the |
…ntrol Feature/issue 56 Post Date Control Reset UI
…rom shadyvb/feature/editorconfig xwp/wp-dev-lib@449182d...4aba13a
Here's where the UI has ended up with input from @ahmadawais. I've moved the timezone and schedule countdown info into a |
I'll merge this at some point over the next 12 hours unless someone finds an issue needing fixed first. |
Fixes #56
Todos
post_date_gmt
post_status
is linked properly.publish
status for scheduled?future
status back topublish
when time passes?0000-00-00 00:00:00
?November 30, -0001
when post setting is invalid or empty?.future
status being returned from the server before getting converted back topublish
if the server/client times are out of sync at all.Date query?(This will require re-architecture ofWP_Query
)Sync post date to parent frame if opened from post preview.(Do this later when status is synced.)Update - 28 Jul 2:30 PM ET
This control has been improved and refactored significantly over the last few days, especially in light of Weston's comments.
I opted to deal with the post_date specifically (as opposed to post_date_gmt) because post_date timezones are easily converted in WP using
get_gmt_from_date()
, instead of wrangling a lot of JS. Using this method, the user's local browser time zone is never a factor; it's has the same UX as the Post Editor.In light of this, the JS has been greatly pared down because there isn't so much use of JS
Date
objects.Directly updating the post_date_gmt and post_status is no longer done in this control's JS. Now,
WP_Customize_Post_Setting::sanitize()
handles their updates when the Preview is saved. This functionality was almost completely in place from previous contributors.Notes:
sanitize()
as well.A couple of points for improvement:
js/customize-post-date.js
to eliminate using an HTML input element altogether.Update - 26 Jul 11 PM ET
I've got the basic functionality working as an extension of the Dynamic control. This is found in
js/customize-posts.js
.I am using JS's
Date
for handling the input as it will make comparison between the existing and new dates pretty simple by using operators like "<" and ">" and "=". This also allows us to utilize thegmt_offset
WP option to ensure thepost_date_gmt
is truly GMT.There are two new JS
Date
functions to handle formatting Date objects correctly based on a PHP-style format string. I went this route as they could possibly be reused elsewhere, especially when pulling in the WP options for date and time formatting. I may pull these out tomorrow, just to simplify things. What thoughts do you have?The custom template for the inputs is found in
php/class-wp-customize-post-date-control.php
.The current implementation saves both
post_date
andpost_date_gmt
.Up next:
Original Text
I'm looking to see if I'm on the right track with my work on the Post Date UI. This is my first time working heavily with the customizer in JS, and my first issue with Customize Posts, so this may be a bit clunky.
My goal is to take the post_date and split it up into separate inputs just as it is in the Post Edit screen.
in the Customizer, when any input is changed, it updates a hidden field, then that value is passed over to the preview pane. This way, we don't have to save each piece of the date (like the month, day, year, etc).