From 3788f58c9e2b4148ddb20ef92c9e10e0c5b3225c Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Thu, 14 May 2009 04:09:01 +0000 Subject: [PATCH] Revert [11263]. Busted several themes. see #9323 git-svn-id: https://develop.svn.wordpress.org/trunk@11324 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/category-template.php | 2 +- wp-includes/taxonomy.php | 24 ++++++++++++++---------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 349193e536..69ec2ba782 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -887,7 +887,7 @@ function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after return false; foreach ( $terms as $term ) { - $link = get_term_link( $term->term_id, $taxonomy ); + $link = get_term_link( $term, $taxonomy ); if ( is_wp_error( $link ) ) return $link; $term_links[] = ''; diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index c00ef7c71e..3120faa866 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2151,24 +2151,28 @@ function _update_post_term_count( $terms ) { * * @since 2.5.0 * - * @param int $term_id The term id for which to get a link. + * @param object|int|string $term * @param string $taxonomy * @return string HTML link to taxonomy term archive */ -function get_term_link( $term_id, $taxonomy ) { +function get_term_link( $term, $taxonomy ) { global $wp_rewrite; - $term_id = intval($term_id); + + if ( !is_object($term) ) { + if ( is_int($term) ) { + $term = &get_term($term, $taxonomy); + } else { + $term = &get_term_by('slug', $term, $taxonomy); + } + } + if ( is_wp_error( $term ) ) + return $term; // use legacy functions for core taxonomies until they are fully plugged in if ( $taxonomy == 'category' ) - return get_category_link((int) $term_id); + return get_category_link((int) $term->term_id); if ( $taxonomy == 'post_tag' ) - return get_tag_link((int) $term_id); - - $term = &get_term($term_id, $taxonomy); - - if ( is_wp_error( $term ) ) - return $term; + return get_tag_link((int) $term->term_id); $termlink = $wp_rewrite->get_extra_permastruct($taxonomy);