wp_save_post_revision_on_insert()WP 6.4.0

Saves revisions for a post after all changes have been made.

No Hooks.

Return

null. Nothing (null).

Usage

wp_save_post_revision_on_insert( $post_id, $post, $update );
$post_id(int) (required)
The post id that was inserted.
$post(WP_Post) (required)
The post object that was inserted.
$update(true|false) (required)
Whether this insert is updating an existing post.

Changelog

Since 6.4.0 Introduced.

wp_save_post_revision_on_insert() code WP 6.6.2

function wp_save_post_revision_on_insert( $post_id, $post, $update ) {
	if ( ! $update ) {
		return;
	}

	if ( ! has_action( 'post_updated', 'wp_save_post_revision' ) ) {
		return;
	}

	wp_save_post_revision( $post_id );
}