From e83be1d2cafb8bf71bfb48a5f0ee7fc12640496d Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Wed, 25 Jul 2007 03:04:46 +0000 Subject: [PATCH] In your cats, making them back compat. git-svn-id: https://develop.svn.wordpress.org/trunk@5818 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/category.php | 41 +++++++++++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/wp-includes/category.php b/wp-includes/category.php index 1fe799bc99..2f36b526f8 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -18,13 +18,22 @@ function &get_categories($args = '') { $taxonomy = 'category'; if ( 'link' == $args['type'] ) $taxonomy = 'link_category'; - return get_terms($taxonomy, $args); + $categories = get_terms($taxonomy, $args); + + foreach ( $categories as $category ) + _make_cat_compat($category); + + return $categories; } // Retrieves category data given a category ID or category object. // Handles category caching. function &get_category(&$category, $output = OBJECT) { - return get_term($category, 'category', $output); + $category = get_term($category, 'category', $output); + + _make_cat_compat($category); + + return $category; } function get_category_by_path($category_path, $full_match = true, $output = OBJECT) { @@ -64,7 +73,11 @@ function get_category_by_path($category_path, $full_match = true, $output = OBJE } function get_category_by_slug( $slug ) { - return get_term_by('slug', $slug, 'category'); + $category = get_term_by('slug', $slug, 'category'); + if ( $category ) + _make_cat_compat($category); + + return $category; } // Get the ID of a category from its name @@ -139,4 +152,26 @@ function clean_category_cache($id) { clean_term_cache($id, 'category'); } +// +// Private helpers +// + +function _make_cat_compat( &$category) { + if ( is_object($category) ) { + $category->cat_ID = &$category->term_id; + $category->category_count = &$category->count; + $category->category_description = &$category->description; + $category->cat_name = &$category->name; + $category->category_nicename = &$category->slug; + $category->category_parent = &$category->parent; + } else if ( is_array($category) && isset($category['term_id']) ) { + $category['cat_ID'] = &$category['term_id']; + $category['category_count'] = &$category['count']; + $category['category_description'] = &$category['description']; + $category['cat_name'] = &$category['name']; + $category['category_nicename'] = &$category['slug']; + $category['category_parent'] = &$category['parent']; + } +} + ?>