Revisions: Rename the function for retrieving the latest revision ID and total count.

The new name is `wp_get_latest_revision_id_and_total_count()`.

This aims to reduce ambiguity about what exactly is the "first" or "last" revision, and bring more consistency with similar wording elsewhere in core, e.g. latest posts, latest comments, etc.

Follow-up to [53759], [53769].

Props peterwilsoncc.
See #55857.
Built from https://develop.svn.wordpress.org/trunk@53778


git-svn-id: http://core.svn.wordpress.org/trunk@53337 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-07-25 19:20:07 +00:00
parent a85bde79df
commit adb5ff451c
3 changed files with 8 additions and 8 deletions

View File

@ -2026,7 +2026,7 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
}
if ( in_array( $post->post_type, array( 'post', 'page' ), true ) || post_type_supports( $post->post_type, 'revisions' ) ) {
$revision = wp_get_last_revision_id_and_total_count( $post->ID );
$revision = wp_get_latest_revision_id_and_total_count( $post->ID );
$revisions_count = ! is_wp_error( $revision ) ? $revision['count'] : 0;
$links['version-history'] = array(
@ -2035,11 +2035,11 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
);
if ( $revisions_count > 0 ) {
$last_revision = $revision['revision'];
$latest_revision = $revision['revision'];
$links['predecessor-version'] = array(
'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions/' . $last_revision ),
'id' => $last_revision,
'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions/' . $latest_revision ),
'id' => $latest_revision,
);
}
}

View File

@ -534,13 +534,13 @@ function wp_get_post_revisions( $post = 0, $args = null ) {
*
* @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
* @return WP_Error|array {
* Returns associative array with last revision ID and total count.
* Returns associative array with latest revision ID and total count.
*
* @type int $revision The last revision post ID or 0 if no revisions exist.
* @type int $revision The latest revision post ID or 0 if no revisions exist.
* @type int $count The total count of revisions for the given post.
* }
*/
function wp_get_last_revision_id_and_total_count( $post = 0 ) {
function wp_get_latest_revision_id_and_total_count( $post = 0 ) {
$post = get_post( $post );
if ( ! $post ) {

View File

@ -16,7 +16,7 @@
*
* @global string $wp_version
*/
$wp_version = '6.1-alpha-53777';
$wp_version = '6.1-alpha-53778';
/**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.