Fix in_category() when checking non-cached categories. fixes #7181
git-svn-id: http://svn.automattic.com/wordpress/trunk@9289 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
85bc4ebd08
commit
461ac5808d
|
@ -288,12 +288,19 @@ function in_category( $category ) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$categories = get_object_term_cache( $post->ID, 'category' );
|
$categories = get_object_term_cache( $post->ID, 'category' );
|
||||||
if ( false === $categories )
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
$categories = wp_get_object_terms( $post->ID, 'category', 'fields=ids' );
|
||||||
|
if ( is_array($categories) && in_array($category, $categories) )
|
||||||
return true;
|
return true;
|
||||||
else
|
else
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue