“Publish immediately” with custom post status

Few notes

  • We can get the “Publish immediately” notice within the post_submit_meta_box(() when the post_date_gmt is equal to '0000-00-00 00:00:00'.

  • We can see here within wp_update_post() and here and here within wp_insert_post(), how draft-, pending- or auto-draft posts are not date stamped.

  • It looks like if we had a filter on the post status array here and here that we could easily fix this for the custom editing status. I also wonder if it would make sense to control this from the register_post_status() setup?

  • It should be possible to modify the post_date_gmt within the wp_insert_post_data filter. Here we might try to get the previous post status from the hidden_post_status or hidden_post_status $postarr fields.

  • The handy transition_post_status hook, fires before the post is updated but before the wp_insert_post_data filter. It will therefore not work to adjust the corresponding database value at this stage, because it will just be overriden shortly after.

  • The post_updated hook fires after the post is updated. This hook provides an easy way to compare the post object before and after the update.

Example

Here’s one example how we can hook into post_updated to clear the post_date_gmt for the post, when the new status is editing and the previous is neither publish or editing:

add_action( 'post_updated', function( $post_ID, $post_after, $post_before ) use ( &$wpdb )
{
    if( 
           'editing' === $post_after->post_status
        && ! in_array( $post_before->post_status, [ 'editing', 'publish' ]  )
        && 'post' === $post_after->post_type
    )
        $wpdb->update( 
            $wpdb->posts, 
            [ 'post_date_gmt' => '0000-00-00 00:00:00' ], 
            [ 'ID' => $post_ID ] 
        );      

}, 10, 3 );

Hopefully you can test this further and adjust to your needs.