Make WordPress Core


Ignore:
Timestamp:
11/12/2010 08:05:37 PM (14 years ago)
Author:
scribu
Message:

Replace get_the_category() with get_the_categories(). Props filosofo. Fixes #15407

File:
1 edited

Legend:

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

    r16331 r16332  
    5858 * Retrieve post categories.
    5959 *
    60  * @since 0.71
    61  * @uses $post
     60 * @since 3.1
    6261 *
    6362 * @param int $id Optional, default to current post ID. The post ID.
    6463 * @return array
    6564 */
    66 function get_the_category( $id = false ) {
    67     global $post;
    68 
    69     $id = (int) $id;
    70     if ( !$id )
    71         $id = (int) $post->ID;
    72 
    73     $categories = get_object_term_cache( $id, 'category' );
    74     if ( false === $categories ) {
    75         $categories = wp_get_object_terms( $id, 'category' );
    76         wp_cache_add($id, $categories, 'category_relationships');
    77     }
    78 
    79     if ( !empty( $categories ) )
    80         usort( $categories, '_usort_terms_by_name' );
    81     else
    82         $categories = array();
     65function get_the_categories( $id = false ) {
     66    $categories = get_the_terms( $id, 'category' );
    8367
    8468    foreach ( (array) array_keys( $categories ) as $key ) {
     
    8670    }
    8771
    88     return $categories;
     72    return apply_filters( 'get_the_categories', $categories );
    8973}
    9074
     
    156140function get_the_category_list( $separator = '', $parents='', $post_id = false ) {
    157141    global $wp_rewrite;
    158     $categories = get_the_category( $post_id );
     142    $categories = get_the_categories( $post_id );
    159143    if ( !is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) )
    160144        return apply_filters( 'the_category', '', $separator, $parents );
Note: See TracChangeset for help on using the changeset viewer.