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.
Метод класса: REST_Save{}
Хуков нет.
Возвращает
void. Ничего (null).
Использование
$REST_Save = new REST_Save(); $REST_Save->save_revision_meta( $revision_id, $post_id );
- $revision_id(int) (обязательный)
- The revision ID.
- $post_id(int) (обязательный)
- The parent post ID.
Список изменений
| С версии 6.8.1 | Введена. |
Код REST_Save::save_revision_meta() REST Save::save revision meta ACF 6.8.11
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 );
}
// The values were submitted by the user, so check them as the post's save did. Otherwise
// the revision would store selections the post's save rejected, and restoring it would
// copy them to the post.
$was_saving_submitted = acf_get_data( 'acf_saving_submitted_values' );
acf_set_data( 'acf_saving_submitted_values', true );
try {
acf_update_values( $values, $revision_id );
} finally {
acf_set_data( 'acf_saving_submitted_values', $was_saving_submitted );
_acf_clear_stored_post_ids_snapshot( $revision_id );
}
$this->current_acf_values = null;
}