[wp-trac] [WordPress Trac] #47548: `transition_post_status` hook is triggered twice when a post is scheduled in the block editor
WordPress Trac
noreply at wordpress.org
Mon Jun 17 05:47:52 UTC 2019
#47548: `transition_post_status` hook is triggered twice when a post is scheduled
in the block editor
-------------------------------+-----------------------------
Reporter: sudar | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Posts, Post Types | Version: trunk
Severity: normal | Keywords:
Focuses: administration |
-------------------------------+-----------------------------
The `transition_post_status` hook is getting triggered twice for scheduled
posts when using block editor with the same `$old_status` and
`$new_status` parameters.
Here are the steps to replicate this.
{{{#!php
<?php
add_action( 'transition_post_status', 'on_post_status_changed',
10, 3 );
function on_post_status_changed( $old_status, $new_status, $post )
{
error_log( "$old_status -> $new_status for " . $post->ID
);
}
}}}
- Add the above code in a new plugin or functions.php file
- Create a new post in block editor and schedule it
- The hook will be triggered and you will get entries in the error log
- Now Make some changes and then click the Schedule button
- The hook will be triggered twice and you will two entires in the error
log. Both the entires will have the old and new status and `future`.
If we don't use the block editor but only the classic editor, then it will
be triggered only once.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/47548>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list