acf_revisions::check_acf_fields_have_changedpublicACF 6.2.6

Helps WordPress determine if fields have changed, and if in a legacy metabox AJAX request, copies the metadata to the new revision.

Method of the class: acf_revisions{}

Returns

boolean.

Usage

$acf_revisions = new acf_revisions();
$acf_revisions->check_acf_fields_have_changed( $post_has_changed, $last_revision, $post );
$post_has_changed(true|false) (required)
True if the post has changed, false if not.
$last_revision(WP_Post) (required)
The WP_Post object for the latest revision.
$post(WP_Post) (required)
The WP_Post object for the parent post.

Changelog

Since 6.2.6 Introduced.

acf_revisions::check_acf_fields_have_changed() code ACF 6.8.8

public function check_acf_fields_have_changed( $post_has_changed, $last_revision, $post ) {
	if ( apply_filters( 'acf/revisions/skip_legacy_metabox_handling', false ) ) {
		return $post_has_changed;
	}

	if ( acf_maybe_get_GET( 'meta-box-loader', false ) ) {
		// We're in a legacy AJAX request, so we copy fields over to the latest revision.
		$this->maybe_save_revision( $last_revision->ID, $post->ID );
	} elseif ( acf_maybe_get_POST( '_acf_changed', false ) ) {
		// We're in a classic editor save request, so notify WP that fields have changed.
		$post_has_changed = true;
	}

	// Let WordPress decide for REST/block editor requests.
	return $post_has_changed;
}