From 6a5d2f8fb06d7bb2941797c100b9e0c01c874607 Mon Sep 17 00:00:00 2001 From: Scott Taylor Date: Wed, 2 Oct 2013 19:59:10 +0000 Subject: [PATCH] Rather than adding a `taxonomy` arg to `get_category()`, convert all uses of `get_category()` in core to `get_term()`. By doing so, we negate the need to call `_make_cat_compat()` in a few places that are only looking for a single property. Fixes #8722. Built from https://develop.svn.wordpress.org/trunk@25662 git-svn-id: http://core.svn.wordpress.org/trunk@25578 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-admin/includes/taxonomy.php | 6 ++++-- wp-includes/category-template.php | 4 ++-- wp-includes/category.php | 16 +++++++++++----- wp-includes/link-template.php | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/wp-admin/includes/taxonomy.php b/wp-admin/includes/taxonomy.php index fdc6d64d55..87fe6e6d67 100644 --- a/wp-admin/includes/taxonomy.php +++ b/wp-admin/includes/taxonomy.php @@ -34,7 +34,8 @@ function category_exists($cat_name, $parent = 0) { * @return unknown */ function get_category_to_edit( $id ) { - $category = get_category( $id, OBJECT, 'edit' ); + $category = get_term( $id, 'category', OBJECT, 'edit' ); + _make_cat_compat( $category ); return $category; } @@ -155,7 +156,8 @@ function wp_update_category($catarr) { return false; // First, get all of the original fields - $category = get_category($cat_ID, ARRAY_A); + $category = get_term( $cat_ID, 'category', ARRAY_A ); + _make_cat_compat( $category ); // Escape data pulled from DB. $category = wp_slash($category); diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index c87804c440..27b8bf221f 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -41,7 +41,7 @@ function get_category_link( $category ) { */ function get_category_parents( $id, $link = false, $separator = '/', $nicename = false, $visited = array() ) { $chain = ''; - $parent = get_category( $id ); + $parent = get_term( $id, 'category' ); if ( is_wp_error( $parent ) ) return $parent; @@ -135,7 +135,7 @@ function _usort_terms_by_ID( $a, $b ) { */ function get_the_category_by_ID( $cat_ID ) { $cat_ID = (int) $cat_ID; - $category = get_category( $cat_ID ); + $category = get_term( $cat_ID, 'category' ); if ( is_wp_error( $category ) ) return $category; return $category->name; diff --git a/wp-includes/category.php b/wp-includes/category.php index adac2475bf..1bddce3ada 100644 --- a/wp-includes/category.php +++ b/wp-includes/category.php @@ -133,13 +133,19 @@ function get_category_by_path( $category_path, $full_match = true, $output = OBJ $path = '/' . $curcategory->slug . $path; } - if ( $path == $full_path ) - return get_category( $category->term_id, $output ); + if ( $path == $full_path ) { + $category = get_term( $category->term_id, 'category', $output ); + _make_cat_compat( $category ); + return $category; + } } // If full matching is not required, return the first cat that matches the leaf. - if ( ! $full_match ) - return get_category( $categories[0]->term_id, $output ); + if ( ! $full_match ) { + $category = get_term( reset( $categories )->term_id, 'category', $output ); + _make_cat_compat( $category ); + return $category; + } return null; } @@ -185,7 +191,7 @@ function get_cat_ID( $cat_name ) { */ function get_cat_name( $cat_id ) { $cat_id = (int) $cat_id; - $category = get_category( $cat_id ); + $category = get_term( $cat_id, 'category' ); if ( ! $category || is_wp_error( $category ) ) return ''; return $category->name; diff --git a/wp-includes/link-template.php b/wp-includes/link-template.php index 9f6d819126..550a2029d2 100644 --- a/wp-includes/link-template.php +++ b/wp-includes/link-template.php @@ -131,7 +131,7 @@ function get_permalink( $id = 0, $leavename = false ) { // show default category in permalinks, without // having to assign it explicitly if ( empty($category) ) { - $default_category = get_category( get_option( 'default_category' ) ); + $default_category = get_term( get_option( 'default_category' ), 'category' ); $category = is_wp_error( $default_category ) ? '' : $default_category->slug; } }