Make WordPress Core

Changeset 60293


Ignore:
Timestamp:
06/08/2025 09:20:31 PM (10 months ago)
Author:
audrasjb
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/post.php

    r60264 r60293  
    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 ) {
Note: See TracChangeset for help on using the changeset viewer.