mirror of
https://github.com/WordPress/WordPress.git
synced 2024-12-23 09:37:42 +01:00
[7064] introduces an extra query for each call to in_category(). Avoid the query if an int is passed.
git-svn-id: http://svn.automattic.com/wordpress/trunk@7904 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
87db175abe
commit
d8ee8494be
@ -185,9 +185,12 @@ function in_category( $category ) { // Check if the current post is in the given
|
|||||||
if ( empty($category) )
|
if ( empty($category) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
$cat_ID = get_cat_ID($category);
|
// If category is not an int, check to see if it's a name
|
||||||
if ( $cat_ID )
|
if ( ! is_int($category) ) {
|
||||||
$category = $cat_ID;
|
$cat_ID = get_cat_ID($category);
|
||||||
|
if ( $cat_ID )
|
||||||
|
$category = $cat_ID;
|
||||||
|
}
|
||||||
|
|
||||||
$categories = get_object_term_cache($post->ID, 'category');
|
$categories = get_object_term_cache($post->ID, 'category');
|
||||||
if ( false === $categories )
|
if ( false === $categories )
|
||||||
|
Loading…
Reference in New Issue
Block a user