Fix an error caused by [28604] in `get_comments_number()` unit tests.
Props SergeyBiryukov. Fixes #26240. Built from https://develop.svn.wordpress.org/trunk@28638 git-svn-id: http://core.svn.wordpress.org/trunk@28456 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
9187e3bd55
commit
2d6721dbc9
|
@ -684,10 +684,11 @@ function comments_link( $deprecated = '', $deprecated_2 = '' ) {
|
|||
function get_comments_number( $post_id = 0 ) {
|
||||
$post = get_post( $post_id );
|
||||
|
||||
if ( ! isset( $post->comment_count ) ) {
|
||||
if ( ! $post ) {
|
||||
$count = 0;
|
||||
} else {
|
||||
$count = $post->comment_count;
|
||||
$post_id = $post->ID;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -698,7 +699,7 @@ function get_comments_number( $post_id = 0 ) {
|
|||
* @param int $count Number of comments a post has.
|
||||
* @param int $post_id Post ID.
|
||||
*/
|
||||
return apply_filters( 'get_comments_number', $count, $post->ID );
|
||||
return apply_filters( 'get_comments_number', $count, $post_id );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue