WordPress.org

Make WordPress Core

Ticket #15407: get_the_category.dry.15407.diff

File get_the_category.dry.15407.diff, 965 bytes (added by filosofo, 11 years ago)
  • wp-includes/category-template.php

     
    6464 * @return array
    6565 */
    6666function get_the_category( $id = false ) {
    67         global $post;
     67        $categories = get_the_terms( $id, 'category' );
    6868
    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();
    83 
    8469        foreach ( (array) array_keys( $categories ) as $key ) {
    8570                _make_cat_compat( $categories[$key] );
    8671        }
    87 
    88         return $categories;
     72       
     73        return apply_filters( 'get_the_categories', $categories );
    8974}
    9075
    9176/**