in_category(): Return immediately if category is empty.
git-svn-id: https://develop.svn.wordpress.org/trunk@7505 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
c7cd740684
commit
d32e5b2e7c
|
@ -182,14 +182,17 @@ function get_the_category_list($separator = '', $parents='', $post_id = false) {
|
|||
function in_category( $category ) { // Check if the current post is in the given category
|
||||
global $post;
|
||||
|
||||
if ( empty($category) )
|
||||
return false;
|
||||
|
||||
$cat_ID = get_cat_ID($category);
|
||||
if (0 != $cat_ID)
|
||||
if ( $cat_ID )
|
||||
$category = $cat_ID;
|
||||
|
||||
$categories = get_object_term_cache($post->ID, 'category');
|
||||
if ( false === $categories )
|
||||
$categories = wp_get_object_terms($post->ID, 'category');
|
||||
if(array_key_exists($category, $categories))
|
||||
if ( array_key_exists($category, $categories) )
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue