Make WordPress Core

Changeset 17438


Ignore:
Timestamp:
02/10/2011 08:19:02 PM (14 years ago)
Author:
ryan
Message:

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 3.1

Location:
branches/3.1/wp-includes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/3.1/wp-includes/category-template.php

    r17102 r17438  
    1313 * @see get_term_link()
    1414 *
    15  * @param int $category_id Category ID.
    16  * @return string|WP_Error Link on success, WP_Error if category does not exist.
    17  */
    18 function get_category_link( $category_id ) {
    19     return get_term_link((int)$category_id, 'category');
     15 * @param int $category Category ID, object, or slug.
     16 * @return string Link on success, empty string if category does not exist.
     17 */
     18function get_category_link( $category ) {
     19    return get_term_link( $category, 'category' );
    2020}
    2121
     
    965965 * @see get_term_link()
    966966 *
    967  * @param int $tag_id Tag (term) ID.
    968  * @return string|WP_Error Link on success, WP_Error if tag does not exist.
    969  */
    970 function get_tag_link( $tag_id ) {
    971     return get_term_link( (int)$tag_id, 'post_tag');
     967 * @param object|string|int $tag Tag ID, object, or slug.
     968 * @return string Link on success, empty string if tag does not exist.
     969 */
     970function get_tag_link( $tag ) {
     971    return get_term_link( $tag, 'post_tag' );
    972972}
    973973
  • branches/3.1/wp-includes/taxonomy.php

    r17373 r17438  
    28162816 * @param object|int|string $term
    28172817 * @param string $taxonomy (optional if $term is object)
    2818  * @return string|WP_Error HTML link to taxonomy term archive on success, WP_Error if term does not exist.
     2818 * @return string HTML link to taxonomy term archive on success, empty string if term does not exist.
    28192819 */
    28202820function get_term_link( $term, $taxonomy = '') {
     
    28332833
    28342834    if ( is_wp_error( $term ) )
    2835         return $term;
     2835        return '';
    28362836
    28372837    $taxonomy = $term->taxonomy;
Note: See TracChangeset for help on using the changeset viewer.