Ticket #6749: in_category.diff
| File in_category.diff, 1.1 kB (added by Otto42, 6 months ago) |
|---|
-
wp-includes/category-template.php
old new 176 176 * 177 177 * @since 1.2.0 178 178 * 179 * @param int|string $category179 * @param int|string|array $category 180 180 * @return bool true if the post is in the supplied category 181 181 */ 182 182 function in_category( $category ) { // Check if the current post is in the given category … … 185 185 if ( empty($category) ) 186 186 return false; 187 187 188 $cat_ID = get_cat_ID($category); 189 if ( $cat_ID ) 190 $category = $cat_ID; 188 $category = (array) $category; 189 190 // get the ids of all the cats 191 foreach ($category as $index => $cat) { 192 if (is_string($cat)) { 193 $cat_ID = get_cat_ID($cat); 194 if ( $cat_ID ) $category[$index] = $cat_ID; 195 } 196 } 191 197 192 198 $categories = get_object_term_cache($post->ID, 'category'); 193 199 if ( false === $categories ) 194 200 $categories = wp_get_object_terms($post->ID, 'category'); 195 if ( array_key_exists($category, $categories) )201 if ( !empty(array_intersect($category, $categories) ) ) 196 202 return true; 197 203 else 198 204 return false;
