acf_revisions::maybe_save_revision │ public │ ACF 6.2.6

Copies ACF field data to the latest revision.

Method of the class: acf_revisions{}

Returns

void. Nothing (null).

Usage

$acf_revisions = new acf_revisions();
$acf_revisions->maybe_save_revision( $revision_id, $post_id );
$revision_id(int) (required)
The ID of the revision that was just created.
$post_id(int) (required)
The ID of the post being updated.

Changelog

Since 6.2.6 Introduced.

acf_revisions::maybe_save_revision() code ACF 6.8.8

public function maybe_save_revision( $revision_id, $post_id ) {
	if ( apply_filters( 'acf/revisions/skip_legacy_metabox_handling', false ) ) {
		return;
	}

	// We don't have anything to copy over yet.
	if ( ! did_action( 'acf/save_post' ) ) {
		delete_metadata( 'post', $post_id, '_acf_changed' );
		delete_metadata( 'post', $revision_id, '_acf_changed' );
		return;
	}

	// Bail if this is an autosave in Classic Editor, it already has the field values.
	if ( acf_maybe_get_POST( '_acf_changed' ) && wp_is_post_autosave( $revision_id ) ) {
		return;
	}

	// Copy the saved meta from the main post to the latest revision.
	acf_save_post_revision( $post_id );
}