I was doing some action on save_post
hook, and noticed that there exists
wp_is_post_autosave( $post_id )
function.
How does it differ from DOING_AUTOSAVE
constant?
If I want my action not to run on autosave should I do both
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return;
}
and
if ( \wp_is_post_autosave( $post_id ) ) {
return;
}
Or is one enough?
The DOING_AUTOSAVE
constant gets defined in wp-admin/includes/post.php
, wp-includes/class-wp-customize-manager.php
and wp-includes/rest-api/endpoints/class-wp-rest-autosaves-controller.php
, whereas wp_is_post_autosave()
checks if the post is revision and has autosave
in it’s name.
I’m a bit confused what to use, and if it’s good idea to use both.