Make WordPress Core


Ignore:
Timestamp:
07/23/2022 03:40:10 PM (4 years ago)
Author:
SergeyBiryukov
Message:

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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/revision.php

    r53759 r53769  
    529529
    530530/**
    531  * Get latest revision and count of revisions for a post.
     531 * Returns the latest revision ID and count of revisions for a post.
    532532 *
    533533 * @since 6.1.0
    534534 *
    535  * @param int|WP_Post|null $post Optional. Post ID or WP_Post object. Default is global $post.
     535 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
    536536 * @return WP_Error|array {
    537  *     Returns associative array with last revision and total count.
    538  *
    539  *     @type int $revision The last revision post id or 0 if non existing.
    540  *     @type int $count The total count of revisions for $post_id.
     537 *     Returns associative array with last revision ID and total count.
     538 *
     539 *     @type int $revision The last revision post ID or 0 if no revisions exist.
     540 *     @type int $count    The total count of revisions for the given post.
    541541 * }
    542542 */
    543 function wp_get_lastest_revision_id_and_total_count( $post = null ) {
     543function wp_get_last_revision_id_and_total_count( $post = 0 ) {
    544544    $post = get_post( $post );
    545545
    546546    if ( ! $post ) {
    547         return new WP_Error( 'revision_error', __( 'Invalid post.' ) );
     547        return new WP_Error( 'invalid_post', __( 'Invalid post.' ) );
    548548    }
    549549
    550550    if ( ! wp_revisions_enabled( $post ) ) {
    551         return new WP_Error( 'revision_error', __( 'Revisions not enabled.' ) );
     551        return new WP_Error( 'revisions_not_enabled', __( 'Revisions not enabled.' ) );
    552552    }
    553553
Note: See TracChangeset for help on using the changeset viewer.