[wp-trac] [WordPress Trac] #39953: REST API: Add `date_auto_update` field for posts
WordPress Trac
noreply at wordpress.org
Thu Feb 23 23:18:14 UTC 2017
#39953: REST API: Add `date_auto_update` field for posts
------------------------------------------+------------------------------
Reporter: jnylen0 | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: Awaiting Review
Component: REST API | Version: 4.7
Severity: normal | Resolution:
Keywords: needs-patch needs-unit-tests | Focuses: rest-api
------------------------------------------+------------------------------
Comment (by jnylen0):
When you create a draft in WP, whether via `wp-admin` or the REST API, it
has a `post_date_gmt` value of `0000-00-00 00:00:00`.
When you update the draft again, most importantly when you publish it, WP
looks for this special value of `post_date_gmt`. If it's present, the
post date is reset to the current timestamp
([https://core.trac.wordpress.org/browser/tags/4.7.2/src/wp-
includes/post.php#L3110 ref]). Usually this is what you want (by default,
a post is dated when it's published, not when its draft is created).
This behavior dates back to [8920], we can't change it in the WP
internals.
If you update the date of the draft before publishing it, whether via `wp-
admin` or the REST API, both the `post_date` and `post_date_gmt` fields
are set to the new date you've specified. It's currently possible to undo
this operation and set the date back to "floating" in `wp-admin`, but this
hasn't been possible via any public release of the REST API.
After #38883, there's no way to tell via the REST API whether a post
actually has an internal `post_date_gmt` value of `0000-00-00 00:00:00` or
not, because if it does, we use the `post_date` field to calculate and
provide a reasonable value for `date_gmt`. Guaranteeing a usable value in
the `date_gmt` field is many times more useful than being able to know the
status of this internal flag.
The new field proposed in this ticket would contain (and allow updating)
this extra piece of information about the internal state of a post. If
the new field has a value of `true`, then the post is a draft with a
`post_date_gmt` value of `0000-00-00 00:00:00`; otherwise, the new field
is `false`.
Something like `date_floating` might make a better name for this field.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/39953#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list