WordPress.org

Make WordPress Core

Changeset 28558


Ignore:
Timestamp:
05/23/2014 05:43:03 PM (8 years ago)
Author:
wonderboymusic
Message:

Allow get_comments_number() to officially accept $post or $post_id. Adds unit tests.

Props coffee2code, JanHenkG.
Fixes #26240.

Location:
trunk
Files:
1 added
1 edited

Legend:

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

    r28514 r28558  
    683683 */
    684684function get_comments_number( $post_id = 0 ) {
    685     $post_id = absint( $post_id );
    686 
    687     if ( !$post_id )
    688         $post_id = get_the_ID();
    689 
    690     $post = get_post($post_id);
    691     if ( ! isset($post->comment_count) )
     685    $post = get_post( $post_id );
     686
     687    if ( ! isset( $post->comment_count ) ) {
    692688        $count = 0;
    693     else
     689    } else {
    694690        $count = $post->comment_count;
     691    }
    695692
    696693    /**
Note: See TracChangeset for help on using the changeset viewer.