wp_get_post_revisions_url

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

WordPress Version: 6.1

/**
 * Returns the url for viewing and potentially restoring revisions of a given post.
 *
 * @since 5.9.0
 *
 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global `$post`.
 * @return string|null The URL for editing revisions on the given post, otherwise null.
 */
function wp_get_post_revisions_url($post = 0)
{
    $post = get_post($post);
    if (!$post instanceof WP_Post) {
        return null;
    }
    // If the post is a revision, return early.
    if ('revision' === $post->post_type) {
        return get_edit_post_link($post);
    }
    if (!wp_revisions_enabled($post)) {
        return null;
    }
    $revisions = wp_get_latest_revision_id_and_total_count($post->ID);
    if (is_wp_error($revisions) || 0 === $revisions['count']) {
        return null;
    }
    return get_edit_post_link($revisions['latest_id']);
}

WordPress Version: 5.9

/**
 * Returns the url for viewing and potentially restoring revisions of a given post.
 *
 * @since 5.9.0
 *
 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global `$post`.
 * @return null|string The URL for editing revisions on the given post, otherwise null.
 */
function wp_get_post_revisions_url($post_id = 0)
{
    $post = get_post($post_id);
    if (!$post instanceof WP_Post) {
        return null;
    }
    // If the post is a revision, return early.
    if ('revision' === $post->post_type) {
        return get_edit_post_link($post);
    }
    if (!wp_revisions_enabled($post)) {
        return null;
    }
    $revisions = wp_get_post_revisions($post->ID, array('posts_per_page' => 1));
    if (0 === count($revisions)) {
        return null;
    }
    $revision = reset($revisions);
    return get_edit_post_link($revision);
}