Opened 17 years ago
Closed 17 years ago
#8792 closed enhancement (fixed)
Transitions should be called even if the status hasn't changed
| Reported by: |
|
Owned by: | |
|---|---|---|---|
| Milestone: | 2.8 | Priority: | normal |
| Severity: | normal | Version: | 2.7 |
| Component: | General | Keywords: | has-patch tested commit |
| Focuses: | Cc: |
Description
I wanted to be able to differentiate newly published posts and published posts, which are re-saved. The current transitions hooks offer either:
publish_posthook, which is called for all saves of published posts
or
oldstatus_to_publishhook, which is called only if the status has changed.
Thus, there is no way to hook to the case, in which the status hasn't changed.
The logical solution for me is to make all the hooks in wp_transition_post_status() to be called even if the status hasn't changed. It shouldn't cause any compatibility problems, so here is a patch.
Attachments (1)
Change History (8)
#2
follow-up:
↓ 3
@
17 years ago
Yeah, you'll probably want to look at Subscribe2 plugin and test with that.
#3
in reply to:
↑ 2
@
17 years ago
Replying to jacobsantos:
Yeah, you'll probably want to look at Subscribe2 plugin and test with that.
It doesn't use transition_post_status, it lists all types in xxx_to_publish hooks.
The change isn't big and if we include in the plugin upgrade docs it won't cause any trouble. I like it a lot better than introducing a new hook or just adding the old status to the common hook, because it will be a lot more generic and more cases can be handled with less code.
Wouldn't it be easier/safer to include the $old_status in the publish_post hook:
do_action("${new_status}_$post->post_type", $post->ID, $post, $old_status);There may be plugins that depend on the other actions being called only when a transitions occurs/post_status changes.