in_category(): Return immediately if category is empty.

git-svn-id: http://svn.automattic.com/wordpress/trunk@7505 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-03-24 20:39:05 +00:00
parent 4cc8c4e7f8
commit f9f1f16dca
1 changed files with 5 additions and 2 deletions

View File

@ -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;