From 6a8ff6630560ddf66217a43733569f180d11e02a Mon Sep 17 00:00:00 2001 From: ryan Date: Thu, 10 Feb 2011 20:17:54 +0000 Subject: [PATCH] Return empty strings instead of WP_Errro from get_category_link(), get_term_link(), and get_tag_link() when passed an invalid term. Clarify phpdoc. Props nacin. fixes #16521 for trunk git-svn-id: http://svn.automattic.com/wordpress/trunk@17437 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/category-template.php | 16 ++++++++-------- wp-includes/taxonomy.php | 4 ++-- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/wp-includes/category-template.php b/wp-includes/category-template.php index 234b77665..c9d5a596a 100644 --- a/wp-includes/category-template.php +++ b/wp-includes/category-template.php @@ -12,11 +12,11 @@ * @since 1.0.0 * @see get_term_link() * - * @param int $category_id Category ID. - * @return string|WP_Error Link on success, WP_Error if category does not exist. + * @param int $category Category ID, object, or slug. + * @return string Link on success, empty string if category does not exist. */ -function get_category_link( $category_id ) { - return get_term_link((int)$category_id, 'category'); +function get_category_link( $category ) { + return get_term_link( $category, 'category' ); } /** @@ -964,11 +964,11 @@ class Walker_CategoryDropdown extends Walker { * @since 2.3.0 * @see get_term_link() * - * @param int $tag_id Tag (term) ID. - * @return string|WP_Error Link on success, WP_Error if tag does not exist. + * @param object|string|int $tag Tag ID, object, or slug. + * @return string Link on success, empty string if tag does not exist. */ -function get_tag_link( $tag_id ) { - return get_term_link( (int)$tag_id, 'post_tag'); +function get_tag_link( $tag ) { + return get_term_link( $tag, 'post_tag' ); } /** diff --git a/wp-includes/taxonomy.php b/wp-includes/taxonomy.php index 89532dcd6..32990652f 100644 --- a/wp-includes/taxonomy.php +++ b/wp-includes/taxonomy.php @@ -2815,7 +2815,7 @@ function _update_post_term_count( $terms, $taxonomy ) { * * @param object|int|string $term * @param string $taxonomy (optional if $term is object) - * @return string|WP_Error HTML link to taxonomy term archive on success, WP_Error if term does not exist. + * @return string HTML link to taxonomy term archive on success, empty string if term does not exist. */ function get_term_link( $term, $taxonomy = '') { global $wp_rewrite; @@ -2832,7 +2832,7 @@ function get_term_link( $term, $taxonomy = '') { $term = new WP_Error('invalid_term', __('Empty Term')); if ( is_wp_error( $term ) ) - return $term; + return ''; $taxonomy = $term->taxonomy;