wp_restore_post_revision_meta

The timeline below displays how wordpress function wp_restore_post_revision_meta has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.4

/**
 * Restore the revisioned meta values for a post.
 *
 * @since 6.4.0
 *
 * @param int $post_id     The ID of the post to restore the meta to.
 * @param int $revision_id The ID of the revision to restore the meta from.
 */
function wp_restore_post_revision_meta($post_id, $revision_id)
{
    $post_type = get_post_type($post_id);
    if (!$post_type) {
        return;
    }
    // Restore revisioned meta fields.
    foreach (wp_post_revision_meta_keys($post_type) as $meta_key) {
        // Clear any existing meta.
        delete_post_meta($post_id, $meta_key);
        _wp_copy_post_meta($revision_id, $post_id, $meta_key);
    }
}