On this page
wp_get_post_revisions_url( int|WP_Post $post ): string|null
Returns the url for viewing and potentially restoring revisions of a given post.
Parameters
Return
string|null The URL for editing revisions on the given post, otherwise null.
Source
File: wp-includes/revision.php. View all references
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'] );
}
Related
Uses
| Uses | Description |
|---|---|
| wp_get_latest_revision_id_and_total_count() wp-includes/revision.php | Returns the latest revision ID and count of revisions for a post. |
| get_edit_post_link() wp-includes/link-template.php | Retrieves the edit post link for post. |
| wp_revisions_enabled() wp-includes/revision.php | Determines whether revisions are enabled for a given post. |
| get_post() wp-includes/post.php | Retrieves post data given a post ID or post object. |
| is_wp_error() wp-includes/load.php | Checks whether the given variable is a WordPress Error. |
Changelog
| Version | Description |
|---|---|
| 5.9.0 | Introduced. |
© 2003–2022 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/wp_get_post_revisions_url