Revisions: Correct the function name for retrieving the last revision ID and total count.

Includes:
* Renaming the function to `wp_get_last_revision_id_and_total_count()`.
* Making the default value for `$post` consistent with `wp_get_post_revisions()`.
* Making `WP_Error` codes more specific and using them in test assertions.
* Adjusting the function description per the documentation standards.

Follow-up to [53759].

Props JustinSainton, SergeyBiryukov.
See #55857.
Built from https://develop.svn.wordpress.org/trunk@53769


git-svn-id: http://core.svn.wordpress.org/trunk@53328 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov
2022-07-23 15:42:16 +00:00
parent 729ab2c971
commit e5fca86316
3 changed files with 12 additions and 11 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_lastest_revision_id_and_total_count( $post->ID );
$revision = wp_get_last_revision_id_and_total_count( $post->ID );
$revisions_count = ! is_wp_error( $revision ) ? $revision['count'] : 0;
$links['version-history'] = array(
@@ -2035,7 +2035,8 @@ class WP_REST_Posts_Controller extends WP_REST_Controller {
);
if ( $revisions_count > 0 ) {
$last_revision = $revision['revision'];
$last_revision = $revision['revision'];
$links['predecessor-version'] = array(
'href' => rest_url( trailingslashit( $base ) . $post->ID . '/revisions/' . $last_revision ),
'id' => $last_revision,