mirror of
https://github.com/gosticks/wordpress-develop.git
synced 2026-10-04 14:47:02 +00:00
REST API, Posts: Add a hook to fire once a post, its terms and meta update.
Introduces the action `wp_after_insert_post` inside a wrapper function of the same name. This hook allows plugin developers to access a posts full data (including its terms and meta data) regardless of the workflow used to save it. A new parameter is introduced to `wp_insert_post()` to indicate whether the hook should be fired within the function call or will be fired afterward. Props aristath, Collizo4sky, danielbachhuber, joyously, kadamwhite, kraftbj, markparnell, mikeschroder, noisysocks, peterwilsoncc, SergeyBiryukov, talldanwp, thewebprincess, TimothyBlynJacobs. Fixes #45114. git-svn-id: https://develop.svn.wordpress.org/trunk@49172 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
@@ -685,12 +685,15 @@ function get_default_post_to_edit( $post_type = 'post', $create_in_db = false )
|
||||
'post_title' => __( 'Auto Draft' ),
|
||||
'post_type' => $post_type,
|
||||
'post_status' => 'auto-draft',
|
||||
)
|
||||
),
|
||||
false,
|
||||
true
|
||||
);
|
||||
$post = get_post( $post_id );
|
||||
if ( current_theme_supports( 'post-formats' ) && post_type_supports( $post->post_type, 'post-formats' ) && get_option( 'default_post_format' ) ) {
|
||||
set_post_format( $post, get_option( 'default_post_format' ) );
|
||||
}
|
||||
wp_after_insert_post( $post, false );
|
||||
|
||||
// Schedule auto-draft cleanup.
|
||||
if ( ! wp_next_scheduled( 'wp_scheduled_auto_draft_delete' ) ) {
|
||||
|
||||
Reference in New Issue
Block a user