WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 7 years ago

#4620 closed defect (bug) (fixed)

Post status transition actions

Reported by: ryan Owned by: ryan
Milestone: 2.3 Priority: normal
Severity: normal Version: 2.3
Component: Administration Keywords: status workflow
Focuses: Cc:

Description

Add post status transition actions so that plugins can hook into workflow. Example actions:

  • draft_to_publish
  • pending_to_publish
  • private_to_publish
  • future_to_publish
  • pending_to_draft

etc.

Also add hooks announcing new status.

  • draft_post
  • draft_page
  • publish_post
  • publish_page
  • pending_post
  • future_post

etc.

Finally, add a catch-all transition_post_status hook that passes the old and new status.

Attachments (1)

status_transit.diff (8.3 KB) - added by ryan 7 years ago.

Download all attachments as: .zip

Change History (5)

ryan7 years ago

comment:2 ryan7 years ago

[5797] rather

comment:3 Otto427 years ago

publish_post is being added in default_filters, but not being called by anything. There's no do_action('publish_post') in all of trunk.

Was this supposed to do something?

comment:4 markjaquith7 years ago

  • Resolution set to fixed
  • Status changed from new to closed

It's dynamically built... that's why you couldn't find it:

function wp_transition_post_status($new_status, $old_status, $post) {
	if ( $new_status != $old_status ) {
		do_action('transition_post_status', $new_status, $old_status, $post);
		do_action("${old_status}_to_$new_status", $post);
	}
	do_action("${new_status}_$post->post_type", $post->ID, $post);
}

This is really cool, BTW.

Note: See TracTickets for help on using tickets.