Make WordPress Core

Changeset 16332


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

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

Location:
trunk
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/includes/class-wp-posts-list-table.php

    r16315 r16332  
    597597            ?>
    598598            <td <?php echo $attributes ?>><?php
    599                 $categories = get_the_category();
     599                $categories = get_the_categories();
    600600                if ( !empty( $categories ) ) {
    601601                    $out = array();
  • trunk/wp-content/themes/twentyten/loop.php

    r16197 r16332  
    142142
    143143            <div class="entry-utility">
    144                 <?php if ( count( get_the_category() ) ) : ?>
     144                <?php if ( count( get_the_categories() ) ) : ?>
    145145                    <span class="cat-links">
    146146                        <?php printf( __( '<span class="%1$s">Posted in</span> %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?>
  • 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 );
  • trunk/wp-includes/deprecated.php

    r15590 r16332  
    7373 * @since 0.71
    7474 * @deprecated 0.71
    75  * @deprecated use get_the_category()
    76  * @see get_the_category()
     75 * @deprecated use get_the_categories()
     76 * @see get_the_categories()
    7777 *
    7878 * @param bool $echo
     
    8080 */
    8181function the_category_ID($echo = true) {
    82     _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' );
     82    _deprecated_function( __FUNCTION__, '0.71', 'get_the_categories()' );
    8383
    8484    // Grab the first cat in the list.
    85     $categories = get_the_category();
     85    $categories = get_the_categories();
    8686    $cat = $categories[0]->term_id;
    8787
     
    109109
    110110    // Grab the first cat in the list.
    111     $categories = get_the_category();
     111    $categories = get_the_categories();
    112112    $currentcat = $categories[0]->category_id;
    113113    if ( $currentcat != $previouscat ) {
     
    25572557    return false;
    25582558}
     2559
     2560/**
     2561 * Retrieve post categories.
     2562 *
     2563 * @since 0.71
     2564 * @uses $post
     2565 * @deprecated 3.1
     2566 * @deprecated Use get_post_categories() instead.
     2567 *
     2568 * @param int $id Optional, default to current post ID. The post ID.
     2569 * @return array
     2570 */
     2571function get_the_category( $id = false ) {
     2572    _deprecated_function( __FUNCTION__, '3.1', 'get_the_categories()' );
     2573    return get_the_categories( $id );
     2574}
  • trunk/wp-includes/feed.php

    r15371 r16332  
    300300    if ( empty($type) )
    301301        $type = get_default_feed();
    302     $categories = get_the_category();
     302    $categories = get_the_categories();
    303303    $tags = get_the_tags();
    304304    $the_list = '';
  • trunk/wp-includes/link-template.php

    r16114 r16332  
    120120        $category = '';
    121121        if ( strpos($permalink, '%category%') !== false ) {
    122             $cats = get_the_category($post->ID);
     122            $cats = get_the_categories($post->ID);
    123123            if ( $cats ) {
    124124                usort($cats, '_usort_terms_by_ID'); // order by ID
  • trunk/wp-includes/post-template.php

    r16331 r16332  
    350350    // Categories
    351351    if ( is_object_in_taxonomy( $post->post_type, 'category' ) ) {
    352         foreach ( (array) get_the_category($post->ID) as $cat ) {
     352        foreach ( (array) get_the_categories($post->ID) as $cat ) {
    353353            if ( empty($cat->slug ) )
    354354                continue;
Note: See TracChangeset for help on using the changeset viewer.