[wp-trac] [WordPress Trac] #45114: Publish posts and fire related hooks on `rest_after_insert_{$this->post_type}` for rest requests.

WordPress Trac noreply at wordpress.org
Sat Nov 3 23:10:27 UTC 2018


#45114: Publish posts and fire related hooks on
`rest_after_insert_{$this->post_type}` for rest requests.
---------------------------+-------------------------
 Reporter:  peterwilsoncc  |       Owner:  (none)
     Type:  enhancement    |      Status:  closed
 Priority:  normal         |   Milestone:
Component:  REST API       |     Version:
 Severity:  normal         |  Resolution:  maybelater
 Keywords:                 |     Focuses:
---------------------------+-------------------------

Comment (by peterwilsoncc):

 I've thought about this further and continue to think firing the after
 post save hooks before all data has been updated will be more problematic
 than changing the hooks.

 A cursory glance at Jetpack shows it expects post meta to be saved on one
 of these hooks (within `wp_transition_post_status()`, looking at Yoast SEO
 it expects term data to be saved on one of these hooks (`save_post`).

 As @pento said in his [https://pento.net/2018/10/26/iterating-on-merge-
 proposals/ recent post on merge proposals], the REST API currently has low
 level of adoption. From version 5.0, it will reach roughly 100% of sites.

 I've attached [attachment:"45114.diff"] which I think has problems, but
 substantially fewer than the original POC:

 * only required data is passed to the new function, inferred data is
 calculated
 * the bypass option is placed inside an `args` setting within the post
 array, following a similar pattern used for `add_meta_box()`'s block
 editor setting
 * short array syntax removed to avoid fatals in old PHP

 As `REST_REQUEST` is only defined within HTTP requests to the rest API but
 not internal requests, it's an unsuitable check for the purpose of moving
 these hooks.

 Rather than start a status war, I am leaving this in a closed state for
 discussion to continue.

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


More information about the wp-trac mailing list