[wp-trac] [WordPress Trac] #39953: REST API: Do not update date when preparing post if date is known to be "floating"

WordPress Trac noreply at wordpress.org
Thu Oct 18 23:20:31 UTC 2018


#39953: REST API: Do not update date when preparing post if date is known to be
"floating"
--------------------------------------+-----------------------
 Reporter:  jnylen0                   |       Owner:  (none)
     Type:  enhancement               |      Status:  new
 Priority:  normal                    |   Milestone:  5.0
Component:  REST API                  |     Version:  4.7
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:  rest-api
--------------------------------------+-----------------------
Changes (by pento):

 * keywords:  has-patch has-unit-tests commit => has-patch has-unit-tests


Comment:

 Have y'all explored the option of adding a "Scheduled Draft" post status?
 It seems like that would solve all of the problems presented here.

 For a post with a `post_status` of `draft`:
 - When requested, the object will have `post_date` and `post_date_gmt`
 appear as they currently are.
 - When updated, with `post_status` still set to `draft`, `post_date_gmt`
 will be ignored, regardless of if it's passed.
 - When updated, with `post_status` changed to `scheduled-draft`,
 `post_date_gmt` will be saved as passed. If `post_date_gmt` isn't passed
 at the time, I'm not really fussed if that's an error, or if it uses
 `now()`, instead.
 - When updated, with `post_status` changed to `publish`, behaviour stays
 the same as it currently is.

 For a post with `post_status` of `scheduled-draft`:
 - When requested, the object will have `post_date` and `post_date_gmt`
 appear as they currently are.
 - When updated, with `post_status` still set to `scheduled-draft`,
 `post_date_gmt` will be saved if it's passed, or unchanged if it isn't.
 - When updated, with `post_status` changed to `draft`, `post_date_gmt`
 will be cleared.
 - When published, `post_status` will be set to `publish` if
 `post_date_gmt` was in the past, or `future`, if it's in the future.

 From a UI perspective, we don't need to make any changes, really.
 `scheduled-draft` can be a hidden post status, it doesn't show in the
 status dropdown. The application should choose between `draft` and
 `scheduled-draft` based upon if the author has changed the post date, or
 clicked a "reset post date" button, or something of that nature. This
 resolves both this issue, and #44975.

 Back compat is a little trickier, as there are a lot of places that assume
 that the post statuses of drafts will only be `draft`. I think we can
 cover most usage pretty easily, though. `get_post()` could change the
 returned post status from `scheduled-draft` to `draft`, unless a flag is
 passed by code that knows how to deal with the two types of drafts. This
 also covers `get_posts()`, as `WP_Query` runs `get_post()` on the returned
 results.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/39953#comment:49>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list