Fix in_category() when checking non-cached categories. fixes #7181

git-svn-id: https://develop.svn.wordpress.org/trunk@9289 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2008-10-22 21:31:55 +00:00
parent 06f0822a1a
commit 584088045a
1 changed files with 10 additions and 3 deletions

View File

@ -288,12 +288,19 @@ function in_category( $category ) {
}
$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 ( false !== $categories ) {
if ( array_key_exists( $category, $categories ) )
return true;
else
return false;
}
$categories = wp_get_object_terms( $post->ID, 'category', 'fields=ids' );
if ( is_array($categories) && in_array($category, $categories) )
return true;
else
return false;
}
/**