Skip to content
Permalink
Browse files

Posts, Post Types: Introduce `edit_post_{$post->post_type}` hook.

The hook fires before the general `edit_post` hook and has the same parameters.

It also complements the `save_post_{$post->post_type}` hook added in [25050].

Props Mte90, garrett-eclipse.
Merges [43535] and [43616] to the 4.9 branch.
Fixes #34706.

git-svn-id: https://develop.svn.wordpress.org/branches/4.9@43617 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
SergeyBiryukov committed Sep 3, 2018
1 parent 6a09c56 commit 29e5fe22387928bb9086836514cf12e082fc42cf
Showing with 25 additions and 1 deletion.
  1. +3 −0 src/wp-includes/class-wp-customize-manager.php
  2. +4 −0 src/wp-includes/comment.php
  3. +18 −1 src/wp-includes/post.php
@@ -2964,6 +2964,9 @@ public function trash_changeset_post( $post ) {
$post->post_status = $new_status;
wp_transition_post_status( $new_status, $old_status, $post );
/** This action is documented in wp-includes/post.php */
do_action( "edit_post_{$post->post_type}", $post->ID, $post );
/** This action is documented in wp-includes/post.php */
do_action( 'edit_post', $post->ID, $post );
@@ -2403,6 +2403,10 @@ function wp_update_comment_count_now($post_id) {
* @param int $old The old comment count.
*/
do_action( 'wp_update_comment_count', $post_id, $new, $old );
/** This action is documented in wp-includes/post.php */
do_action( "edit_post_{$post->post_type}", $post_id, $post );
/** This action is documented in wp-includes/post.php */
do_action( 'edit_post', $post_id, $post );
@@ -3624,6 +3624,19 @@ function wp_insert_post( $postarr, $wp_error = false ) {
}
if ( $update ) {
/**
* Fires once an existing post has been updated.
*
* The dynamic portion of the hook name, `$post->post_type`, refers to
* the post type slug.
*
* @since 4.9.9
*
* @param int $post_ID Post ID.
* @param WP_Post $post Post object.
*/
do_action( "edit_post_{$post->post_type}", $post_ID, $post );
/**
* Fires once an existing post has been updated.
*
@@ -3633,7 +3646,8 @@ function wp_insert_post( $postarr, $wp_error = false ) {
* @param WP_Post $post Post object.
*/
do_action( 'edit_post', $post_ID, $post );
$post_after = get_post($post_ID);
$post_after = get_post( $post_ID );
/**
* Fires once an existing post has been updated.
@@ -3772,6 +3786,9 @@ function wp_publish_post( $post ) {
$post->post_status = 'publish';
wp_transition_post_status( 'publish', $old_status, $post );
/** This action is documented in wp-includes/post.php */
do_action( "edit_post_{$post->post_type}", $post->ID, $post );
/** This action is documented in wp-includes/post.php */
do_action( 'edit_post', $post->ID, $post );

0 comments on commit 29e5fe2

Please sign in to comment.
You can’t perform that action at this time.