-
Notifications
You must be signed in to change notification settings - Fork 1
Open
Description
Hi @nfmohit
While working on a similar plugin, but for Buddy.works integration I was trying to tackle the problem related to auto-deployment and while looking at your code I saw one bug.
if ( 'auto-draft' == get_post_status( $post_id ) || 'draft' == get_post_status( $post_id ) || wp_is_post_revision( $post_id ) ) {
return;
}
So if we will unpublish the post/page it won't run and I think it should as unpublishing changes the content of the page.
I used a bit different approach. First of all I used transition_post_status action and then I went for something like this:
function check_post_status( $new_status, $old_status, $post ) {
if ( 'auto-draft' === $post->post_status || wp_is_post_revision( $post->ID ) ) {
return false;
}
// publishing or updating something
if ( 'publish' === $new_status ) {
return true;
}
// unpublishing
if ( 'publish' !== $new_status && 'publish' === $old_status ) {
return true;
}
return false;
}
Of course your functionality is a bit different, but I hope you get the point.
Metadata
Metadata
Assignees
Labels
No labels