Skip to content

Commit 7d5fb7b

Browse files
committed
Posts, Post Types: Add pre_post_insert action hook before inserting a new post.
This changeset adds a `pre_post_insert` action hook before inserting a new post via `wp_insert_post()`, allowing developers to modify or inspect post data before insertion. It brings consistency with the `pre_post_update` action hook triggered when a post is updated. Props Hrohh, peterwilsoncc, audrasjb. Fixes #63115. git-svn-id: https://develop.svn.wordpress.org/trunk@60293 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 0664314 commit 7d5fb7b

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/wp-includes/post.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4874,6 +4874,15 @@ function wp_insert_post( $postarr, $wp_error = false, $fire_after_hooks = true )
48744874
}
48754875
}
48764876

4877+
/**
4878+
* Fires immediately before a new post is inserted in the database.
4879+
*
4880+
* @since 6.9.0
4881+
*
4882+
* @param array $data Array of unslashed post data.
4883+
*/
4884+
do_action( 'pre_post_insert', $data );
4885+
48774886
if ( false === $wpdb->insert( $wpdb->posts, $data ) ) {
48784887
if ( $wp_error ) {
48794888
if ( 'attachment' === $post_type ) {

0 commit comments

Comments
 (0)