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:
parent
06f0822a1a
commit
584088045a
|
@ -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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue