mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 01:27:36 +01:00
Allow get_comments_number()
to officially accept $post
or $post_id
. Adds unit tests.
Props coffee2code, JanHenkG. Fixes #26240. Built from https://develop.svn.wordpress.org/trunk@28558 git-svn-id: http://core.svn.wordpress.org/trunk@28384 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
03410a4067
commit
e8181b0934
@ -682,16 +682,13 @@ function comments_link( $deprecated = '', $deprecated_2 = '' ) {
|
||||
* @return int The number of comments a post has.
|
||||
*/
|
||||
function get_comments_number( $post_id = 0 ) {
|
||||
$post_id = absint( $post_id );
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( !$post_id )
|
||||
$post_id = get_the_ID();
|
||||
|
||||
$post = get_post($post_id);
|
||||
if ( ! isset($post->comment_count) )
|
||||
if ( ! isset( $post->comment_count ) ) {
|
||||
$count = 0;
|
||||
else
|
||||
} else {
|
||||
$count = $post->comment_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filter the returned comment count for a post.
|
||||
|
Loading…
Reference in New Issue
Block a user