Changeset 5868

Show
Ignore:
Timestamp:
08/14/07 03:01:26 (1 year ago)
Author:
ryan
Message:

Update in_category() to use object term cache API. Props technosailor. fixes #4442

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/wp-includes/category-template.php

    r5797 r5868  
    157157 
    158158function in_category( $category ) { // Check if the current post is in the given category 
    159     global $object_term_cache, $post, $blog_id; 
    160  
    161     if ( isset( $object_term_cache[$blog_id][$post->ID]['category'][$category] ) ) 
     159    global $post, $blog_id; 
     160 
     161    $categories = get_object_term_cache($post->ID, 'category'); 
     162    if ( false === $categories ) 
     163        $categories = get_object_terms($post->ID, 'category'); 
     164    if(array_key_exists($category, $categories)) 
    162165        return true; 
    163166    else