[wp-trac] [WordPress Trac] #21450: wp_insert_new_post hook
WordPress Trac
wp-trac at lists.automattic.com
Thu Aug 2 10:42:57 UTC 2012
#21450: wp_insert_new_post hook
-----------------------------+-----------------------------
Reporter: rndbit | Owner:
Type: feature request | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Plugins | Version:
Severity: minor | Keywords: has-patch
-----------------------------+-----------------------------
Situation is this in wp_insert_post:
{{{
if ( $update ) {
do_action('edit_post', $post_ID, $post);
$post_after = get_post($post_ID);
do_action( 'post_updated', $post_ID, $post_after,
$post_before);
}
do_action('save_post', $post_ID, $post);
do_action('wp_insert_post', $post_ID, $post);
}}}
As you can see we have hooks that:
1. Get executed when post is '''updated'''
2. Get executed when post is '''updated or created'''
There is no hook that would be exectued only when post is '''created'''.
''wp_insert_post'' was most logical candidate for the task, however i
suspect changing it might break some plugins relying on it therefore i
propose new action '''wp_insert_new_post''' which should be executed
'''only when new post is created''', but '''never when post is updated'''.
Like so:
{{{
if ( $update ) {
do_action('edit_post', $post_ID, $post);
$post_after = get_post($post_ID);
do_action( 'post_updated', $post_ID, $post_after,
$post_before);
}
+ else
+ do_action('wp_insert_new_post', $post_ID, $post);
do_action('save_post', $post_ID, $post);
do_action('wp_insert_post', $post_ID, $post);
}}}
P.S. I marked ticket as having patch even tho there is just updated code
snippet above. Please excuse me :)
--
Ticket URL: <http://core.trac.wordpress.org/ticket/21450>
WordPress Trac <http://core.trac.wordpress.org/>
WordPress blogging software
More information about the wp-trac
mailing list