Make WordPress Core


Ignore:
Timestamp:
08/20/2017 08:12:50 PM (7 years ago)
Author:
DrewAPicture
Message:

Docs: Clarify that get_comments_number() can return either a numeric string (for compatibility reasons) or 0 if the post doesn't exist.

Also update the hook doc for the get_comments_number filter to reflect the mixed type for $count.

Props kiranpotphode for the initial patch.
Fixes #38369.

File:
1 edited

Legend:

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

    r41217 r41285  
    831831
    832832/**
    833  * Retrieve the amount of comments a post has.
     833 * Retrieves the amount of comments a post has.
    834834 *
    835835 * @since 1.5.0
    836836 *
    837  * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is global $post.
    838  * @return int The number of comments a post has.
     837 * @param int|WP_Post $post_id Optional. Post ID or WP_Post object. Default is the global `$post`.
     838 * @return string|int If the post exists, a numeric string representing the number of comments
     839 *                    the post has, otherwise 0.
    839840 */
    840841function get_comments_number( $post_id = 0 ) {
     
    853854     * @since 1.5.0
    854855     *
    855      * @param int $count   Number of comments a post has.
    856      * @param int $post_id Post ID.
     856     * @param string|int $count   A string representing the number of comments a post has, otherwise 0.
     857     * @param int        $post_id Post ID.
    857858     */
    858859    return apply_filters( 'get_comments_number', $count, $post_id );
Note: See TracChangeset for help on using the changeset viewer.