Switch to transition_post_status instead of save_post #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Scheduled posts don't get any love because the
save_post
action isn't fired bywp_transition_post_status()
.Switching to the
transition_post_status
action instead ofsave_post
fixes this problem. Since that action provides the old and new statuses, it also eliminates the need forget_post_status()
and lets you move the status check logic to the start of the function. Autosave doesn't trigger either, so that check can be eliminated.I love the plugin, but my scheduled posts weren't feeling the love.