ACF\Pro\Datastore
REST_Save::save_revision_meta
Writes ACF field values to the revision after WordPress creates it.
Called via _wp_put_post_revision, which fires AFTER rest_after_insert (where save_post_rest writes values to the post). At this point the decoded values are available in $this->current_acf_values.
Method of the class: REST_Save{}
No Hooks.
Returns
null. Nothing (null).
Usage
$REST_Save = new REST_Save(); $REST_Save->save_revision_meta( $revision_id, $post_id );
- $revision_id(int) (required)
- The revision ID.
- $post_id(int) (required)
- The parent post ID.
Changelog
| Since 6.8.1 | Introduced. |
REST_Save::save_revision_meta() REST Save::save revision meta code ACF 6.8.8
public function save_revision_meta( $revision_id, $post_id ) {
if ( ! defined( 'REST_REQUEST' ) || ! REST_REQUEST ) {
return;
}
$is_autosave = wp_is_post_autosave( $revision_id );
// Clean up the transport-only _acf blob from the post.
// wp_save_revisioned_meta_fields (priority 10) has already copied
// it to the revision for future comparison.
if ( ! $is_autosave ) {
delete_post_meta( $post_id, '_acf' );
}
if ( empty( $this->current_acf_values ) || $is_autosave ) {
return;
}
$values = $this->current_acf_values;
if ( ! acf_allow_unfiltered_html() ) {
$values = wp_kses_post_deep( $values );
}
acf_update_values( $values, $revision_id );
$this->current_acf_values = null;
}