Accept only IDs for get_term_link(). Prop filosofo. fixes #9323

git-svn-id: https://develop.svn.wordpress.org/trunk@11263 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Ryan Boren 2009-05-11 16:37:42 +00:00
parent 318e19884c
commit ed05a1e8f8
2 changed files with 11 additions and 15 deletions

View File

@ -887,7 +887,7 @@ function get_the_term_list( $id = 0, $taxonomy, $before = '', $sep = '', $after
return false; return false;
foreach ( $terms as $term ) { foreach ( $terms as $term ) {
$link = get_term_link( $term, $taxonomy ); $link = get_term_link( $term->term_id, $taxonomy );
if ( is_wp_error( $link ) ) if ( is_wp_error( $link ) )
return $link; return $link;
$term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>'; $term_links[] = '<a href="' . $link . '" rel="tag">' . $term->name . '</a>';

View File

@ -2151,28 +2151,24 @@ function _update_post_term_count( $terms ) {
* *
* @since 2.5.0 * @since 2.5.0
* *
* @param object|int|string $term * @param int $term_id The term id for which to get a link.
* @param string $taxonomy * @param string $taxonomy
* @return string HTML link to taxonomy term archive * @return string HTML link to taxonomy term archive
*/ */
function get_term_link( $term, $taxonomy ) { function get_term_link( $term_id, $taxonomy ) {
global $wp_rewrite; 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 // use legacy functions for core taxonomies until they are fully plugged in
if ( $taxonomy == 'category' ) if ( $taxonomy == 'category' )
return get_category_link((int) $term->term_id); return get_category_link((int) $term_id);
if ( $taxonomy == 'post_tag' ) if ( $taxonomy == 'post_tag' )
return get_tag_link((int) $term->term_id); return get_tag_link((int) $term_id);
$term = &get_term($term_id, $taxonomy);
if ( is_wp_error( $term ) )
return $term;
$termlink = $wp_rewrite->get_extra_permastruct($taxonomy); $termlink = $wp_rewrite->get_extra_permastruct($taxonomy);