Make WordPress Core

Ticket #16521: 16521.3.diff

File 16521.3.diff, 2.0 KB (added by ryan, 15 years ago)
  • wp-includes/taxonomy.php

     
    28152815 *
    28162816 * @param object|int|string $term
    28172817 * @param string $taxonomy (optional if $term is object)
    2818  * @return string HTML link to taxonomy term archive on success, empty string if term does not exist.
     2818 * @return string|WP_Error HTML link to taxonomy term archive on success, WP_Error if term does not exist.
    28192819 */
    28202820function get_term_link( $term, $taxonomy = '') {
    28212821        global $wp_rewrite;
     
    28322832                $term = new WP_Error('invalid_term', __('Empty Term'));
    28332833
    28342834        if ( is_wp_error( $term ) )
    2835                 return '';
     2835                return $term;
    28362836
    28372837        $taxonomy = $term->taxonomy;
    28382838
  • wp-includes/category-template.php

     
    1212 * @since 1.0.0
    1313 * @see get_term_link()
    1414 *
    15  * @param int $category Category ID, object, or slug.
     15 * @param int|object $category Category ID or object.
    1616 * @return string Link on success, empty string if category does not exist.
    1717 */
    1818function get_category_link( $category ) {
    19         return get_term_link( $category, 'category' );
     19        if ( ! is_object( $category ) )
     20                $category = (int) $category;
     21
     22        $category = get_term_link( $category, 'category' );
     23
     24        if ( is_wp_error( $category ) )
     25                return '';
     26
     27        return $category;
    2028}
    2129
    2230/**
     
    964972 * @since 2.3.0
    965973 * @see get_term_link()
    966974 *
    967  * @param object|string|int $tag Tag ID, object, or slug.
     975 * @param int|object $tag Tag ID or object.
    968976 * @return string Link on success, empty string if tag does not exist.
    969977 */
    970978function get_tag_link( $tag ) {
    971         return get_term_link( $tag, 'post_tag' );
     979        if ( ! is_object( $tag ) )
     980                $tag = (int) $tag;
     981
     982        $tag = get_term_link( $tag, 'post_tag' );
     983
     984        if ( is_wp_error( $tag ) )
     985                return '';
     986
     987        return $tag;
    972988}
    973989
    974990/**