From 11f20d737c85c6dc2983bee69e3f08c9f0fc11e9 Mon Sep 17 00:00:00 2001 From: scribu Date: Fri, 12 Nov 2010 20:05:37 +0000 Subject: [PATCH] Replace get_the_category() with get_the_categories(). Props filosofo. Fixes #15407 git-svn-id: https://develop.svn.wordpress.org/trunk@16332 602fd350-edb4-49c9-b593-d223f7449a82 --- .../includes/class-wp-posts-list-table.php | 2 +- wp-content/themes/twentyten/loop.php | 2 +- wp-includes/category-template.php | 26 ++++--------------- wp-includes/deprecated.php | 26 +++++++++++++++---- wp-includes/feed.php | 2 +- wp-includes/link-template.php | 2 +- wp-includes/post-template.php | 2 +- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/wp-admin/includes/class-wp-posts-list-table.php b/wp-admin/includes/class-wp-posts-list-table.php index dea8f65409..4f1f62b35b 100644 --- a/wp-admin/includes/class-wp-posts-list-table.php +++ b/wp-admin/includes/class-wp-posts-list-table.php @@ -596,7 +596,7 @@ class WP_Posts_List_Table extends WP_List_Table { case 'categories': ?> >
- + Posted in %2$s', 'twentyten' ), 'entry-utility-prep entry-utility-prep-cat-links', get_the_category_list( ', ' ) ); ?> diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 66b31cec5f..173183c324 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -57,35 +57,19 @@ function get_category_parents( $id, $link = false, $separator = '/', $nicename = /** * Retrieve post categories. * - * @since 0.71 - * @uses $post + * @since 3.1 * * @param int $id Optional, default to current post ID. The post ID. * @return array */ -function get_the_category( $id = false ) { - global $post; - - $id = (int) $id; - if ( !$id ) - $id = (int) $post->ID; - - $categories = get_object_term_cache( $id, 'category' ); - if ( false === $categories ) { - $categories = wp_get_object_terms( $id, 'category' ); - wp_cache_add($id, $categories, 'category_relationships'); - } - - if ( !empty( $categories ) ) - usort( $categories, '_usort_terms_by_name' ); - else - $categories = array(); +function get_the_categories( $id = false ) { + $categories = get_the_terms( $id, 'category' ); foreach ( (array) array_keys( $categories ) as $key ) { _make_cat_compat( $categories[$key] ); } - return $categories; + return apply_filters( 'get_the_categories', $categories ); } /** @@ -155,7 +139,7 @@ function get_the_category_by_ID( $cat_ID ) { */ function get_the_category_list( $separator = '', $parents='', $post_id = false ) { global $wp_rewrite; - $categories = get_the_category( $post_id ); + $categories = get_the_categories( $post_id ); if ( !is_object_in_taxonomy( get_post_type( $post_id ), 'category' ) ) return apply_filters( 'the_category', '', $separator, $parents ); diff --git a/wp-includes/deprecated.php b/wp-includes/deprecated.php index 9775e827fa..c56707b989 100644 --- a/wp-includes/deprecated.php +++ b/wp-includes/deprecated.php @@ -72,17 +72,17 @@ function start_wp() { * * @since 0.71 * @deprecated 0.71 - * @deprecated use get_the_category() - * @see get_the_category() + * @deprecated use get_the_categories() + * @see get_the_categories() * * @param bool $echo * @return null|int */ function the_category_ID($echo = true) { - _deprecated_function( __FUNCTION__, '0.71', 'get_the_category()' ); + _deprecated_function( __FUNCTION__, '0.71', 'get_the_categories()' ); // Grab the first cat in the list. - $categories = get_the_category(); + $categories = get_the_categories(); $cat = $categories[0]->term_id; if ( $echo ) @@ -108,7 +108,7 @@ function the_category_head($before='', $after='') { _deprecated_function( __FUNCTION__, '0.71', 'get_the_category_by_ID()' ); // Grab the first cat in the list. - $categories = get_the_category(); + $categories = get_the_categories(); $currentcat = $categories[0]->category_id; if ( $currentcat != $previouscat ) { echo $before; @@ -2556,3 +2556,19 @@ function is_plugin_page() { return false; } + +/** + * Retrieve post categories. + * + * @since 0.71 + * @uses $post + * @deprecated 3.1 + * @deprecated Use get_post_categories() instead. + * + * @param int $id Optional, default to current post ID. The post ID. + * @return array + */ +function get_the_category( $id = false ) { + _deprecated_function( __FUNCTION__, '3.1', 'get_the_categories()' ); + return get_the_categories( $id ); +} diff --git a/wp-includes/feed.php b/wp-includes/feed.php index 3ed2191787..2bbf20f136 100644 --- a/wp-includes/feed.php +++ b/wp-includes/feed.php @@ -299,7 +299,7 @@ function comment_text_rss() { function get_the_category_rss($type = null) { if ( empty($type) ) $type = get_default_feed(); - $categories = get_the_category(); + $categories = get_the_categories(); $tags = get_the_tags(); $the_list = ''; $cat_names = array(); diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index cfcdfd2abc..76a54a09ce 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -119,7 +119,7 @@ function get_permalink($id = 0, $leavename = false) { $category = ''; if ( strpos($permalink, '%category%') !== false ) { - $cats = get_the_category($post->ID); + $cats = get_the_categories($post->ID); if ( $cats ) { usort($cats, '_usort_terms_by_ID'); // order by ID $category = $cats[0]->slug; diff --git a/wp-includes/post-template.php b/wp-includes/post-template.php index 0b1db1a1bf..b76d0b693a 100644 --- a/wp-includes/post-template.php +++ b/wp-includes/post-template.php @@ -349,7 +349,7 @@ function get_post_class( $class = '', $post_id = null ) { // Categories if ( is_object_in_taxonomy( $post->post_type, 'category' ) ) { - foreach ( (array) get_the_category($post->ID) as $cat ) { + foreach ( (array) get_the_categories($post->ID) as $cat ) { if ( empty($cat->slug ) ) continue; $classes[] = 'category-' . sanitize_html_class($cat->slug, $cat->term_id);