acf_revisions::wp_restore_post_revisionpublicACF 1.0

wp_restore_post_revision

This action will copy and paste the metadata from a revision to the post

Method of the class: acf_revisions{}

No Hooks.

Returns

$revision_id. (int) the source post

Usage

$acf_revisions = new acf_revisions();
$acf_revisions->wp_restore_post_revision( $post_id, $revision_id );
$post_id(required)
.
$revision_id(required)
.

acf_revisions::wp_restore_post_revision() code ACF 6.0.4

function wp_restore_post_revision( $post_id, $revision_id ) {

	// copy postmeta from revision to post (restore from revision)
	acf_copy_postmeta( $revision_id, $post_id );

	// Make sure the latest revision is also updated to match the new $post data
	// get latest revision
	$revision = acf_get_post_latest_revision( $post_id );

	// save
	if ( $revision ) {

		// copy postmeta from revision to latest revision (potentialy may be the same, but most likely are different)
		acf_copy_postmeta( $revision_id, $revision->ID );

	}

}