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
This commit is contained in:
Scott Taylor 2013-10-02 19:59:10 +00:00
parent 3f42db549c
commit 6a5d2f8fb0
4 changed files with 18 additions and 10 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;
}
}