Wp_Helpers::is_draft_to_publish( $new_status, $old_status, $post )
Validate post status to see if its ‘Draft’ – ‘Publish’
Contents
Parameters Parameters
- $id
-
(Required) The id of the post.
- $post_object
-
(Required) The post object.
- $update
-
(Required) The status of the post. Revision and auto-draft is triggered so $update is always equals to yes.
Return Return
(boolean) Returns true when post status is from 'Draft' to 'Publish', otherwise true.
Source Source
File: src/integrations/wp/helpers/wp-helpers.php
public function is_draft_to_publish( $new_status, $old_status, $post ) { // Prevent from doing autosave. if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) { return false; } // Prevent auto draft, pending, revisions, and other post status. if ( 'publish' !== $post->post_status ) { return false; } // Prevent existing posts to trigger from post update. if ( 'publish' === $old_status && 'publish' === $new_status ) { return false; } // Create a hook once the validation have passed. do_action( 'uo_automator_post_draft_to_publish', $new_status, $old_status, $post ); return true; }
Expand full source code Collapse full source code View on Github