[wp-trac] [WordPress Trac] #34706: Introduce an edit_post_{$post->post_type} action
WordPress Trac
noreply at wordpress.org
Wed Feb 28 21:43:40 UTC 2018
#34706: Introduce an edit_post_{$post->post_type} action
-------------------------------+------------------
Reporter: garrett-eclipse | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 5.0
Component: Posts, Post Types | Version: 4.4
Severity: normal | Resolution:
Keywords: close | Focuses:
-------------------------------+------------------
Changes (by danieltj):
* keywords: dev-feedback => close
Comment:
After reviewing the state of this function within `post.php`, I don't
think there's a need for a new action here as the existing actions already
provide enough to check what the post type is.
In all honesty though, if this was added, I wouldn't have a problem but if
you want to trigger an action when a Book (example custom post type) is
updated, you could always do something to the effect of:
{{{
add_action( 'edit_post', 'my_edit_action', 10, 2 );
function my_edit_action( $post_id, $post ) {
if ( 'book' == $post->post_type ) {
// do something now...
}
}
}}}
Also, the `save_post` and `save_post_{$post->post_type}` hooks are called
irrespective of whether it's a post being saved or updated so they should
both be able to be used here without issues.
I'll recommend closing this, although feel free to reverse that.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34706#comment:6>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list