acf_revisions::wp_restore_post_revision() public ACF 1.0
This action will copy and paste the metadata from a revision to the post
{} Это метод класса: acf_revisions{}
Хуков нет.
Возвращает
$revision_id. (int) the source post
Использование
$acf_revisions = new acf_revisions(); $acf_revisions->wp_restore_post_revision( $post_id, $revision_id );
- (int)($parent_id) (обязательный)
- the destination post
Код acf_revisions::wp_restore_post_revision() acf revisions::wp restore post revision ACF 5.9.1
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 );
}
}