wp_get_post_revisions_url( int|WP_Post $post ): string|null

In this article

Returns the url for viewing and potentially restoring revisions of a given post.

Parameters

$postint|WP_Postoptional
Post ID or WP_Post object. Default is global $post.

Return

string|null The URL for editing revisions on the given post, otherwise null.

Source

	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'] );
}

/**
 * Determines whether revisions are enabled for a given post.
 *
 * @since 3.6.0
 *
 * @param WP_Post $post The post object.
 * @return bool True if number of revisions to keep isn't zero, false otherwise.

Changelog

VersionDescription
5.9.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.