[wp-trac] [WordPress Trac] #45114: Fire publishing related hooks after all data is saved via the REST API.

WordPress Trac noreply at wordpress.org
Fri Nov 27 20:18:26 UTC 2020


#45114: Fire publishing related hooks after all data is saved via the REST API.
--------------------------------------+----------------------------
 Reporter:  peterwilsoncc             |       Owner:  peterwilsoncc
     Type:  defect (bug)              |      Status:  reopened
 Priority:  normal                    |   Milestone:  5.6
Component:  REST API                  |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  has-dev-note needs-patch  |     Focuses:
--------------------------------------+----------------------------

Comment (by Collizo4sky):

 Very happy this is being considered. Currently, my workaround feels hacky.


 {{{
             add_action('transition_post_status', function ($new_status,
 $old_status, WP_Post $post) {

                  global $mo_old_post_status;

                  if (isset($post->ID)) {
                      $mo_old_post_status[$post->ID] = $old_status;
                   }

             }, 1, 3);


             add_action('wp_after_insert_post', function ($post_id, WP_Post
 $post, $update) {

                 global $mo_old_post_status;

                 $this->new_publish_post($post->post_status,
 $mo_old_post_status[$post_id], $post);

             }, 1, 3);

 }}}


 Would love to eliminate the use of the globals.

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


More information about the wp-trac mailing list