Make WordPress Core


Ignore:
Timestamp:
08/05/2022 01:00:57 PM (3 years ago)
Author:
SergeyBiryukov
Message:

Revisions: Use latest_id as the array key for the latest revision ID.

This updates wp_get_latest_revision_id_and_total_count() and its usage to be a bit more descriptive and a bit less repetitive, e.g. $revisions['latest_id'] instead of $revision['revision'].

Includes updating the @return tag to explain when the function returns a WP_Error.

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

See #55857.

File:
1 edited

Legend:

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

    r53779 r53841  
    534534 *
    535535 * @param int|WP_Post $post Optional. Post ID or WP_Post object. Default is global $post.
    536  * @return WP_Error|array {
    537  *     Returns associative array with latest revision ID and total count.
    538  *
    539  *     @type int $revision The latest revision post ID or 0 if no revisions exist.
    540  *     @type int $count    The total count of revisions for the given post.
     536 * @return array|WP_Error {
     537 *     Returns associative array with latest revision ID and total count,
     538 *     or a WP_Error if the post does not exist or revisions are not enabled.
     539 *
     540 *     @type int $latest_id The latest revision post ID or 0 if no revisions exist.
     541 *     @type int $count     The total count of revisions for the given post.
    541542 * }
    542543 */
     
    568569    if ( ! $revisions ) {
    569570        return array(
    570             'revision' => 0,
    571             'count'    => 0,
     571            'latest_id' => 0,
     572            'count'     => 0,
    572573        );
    573574    }
    574575
    575576    return array(
    576         'revision' => $revisions[0],
    577         'count'    => $revision_query->found_posts,
     577        'latest_id' => $revisions[0],
     578        'count'     => $revision_query->found_posts,
    578579    );
    579580}
Note: See TracChangeset for help on using the changeset viewer.