WordPress.org

Make WordPress Core


Ignore:
Timestamp:
09/18/2007 04:32:22 PM (14 years ago)
Author:
ryan
Message:

Add checks for WP_Error. Props filosofo. see #4809

File:
1 edited

Legend:

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

    r6091 r6125  
    1313
    1414        $category = get_category($cat_id);
     15        if ( is_wp_error( $category ) )
     16            return $category;
    1517        if ( $category->parent == $id ) {
    1618            $chain .= $before.$category->term_id.$after;
     
    3032    } else {
    3133        $category = &get_category($category_id);
     34        if ( is_wp_error( $category ) )
     35            return $category;
    3236        $category_nicename = $category->slug;
    3337
     
    4448    $chain = '';
    4549    $parent = &get_category($id);
     50    if ( is_wp_error( $parent ) )
     51        return $parent;
    4652
    4753    if ( $nicename )
     
    99105    $cat_ID = (int) $cat_ID;
    100106    $category = &get_category($cat_ID);
     107    if ( is_wp_error( $category ) )
     108        return $category;
    101109    return $category->name;
    102110}
     
    314322
    315323    $return = wp_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args
    316     echo apply_filters( 'wp_tag_cloud', $return, $args );
     324    if ( is_wp_error( $return ) )
     325        return false;
     326    else
     327        echo apply_filters( 'wp_tag_cloud', $return, $args );
    317328}
    318329
     
    335346        $counts[$tag->name] = $tag->count;
    336347        $tag_links[$tag->name] = get_tag_link( $tag->term_id );
     348        if ( is_wp_error( $tag_links[$tag->name] ) )
     349            return $tag_links[$tag->name];
    337350        $tag_ids[$tag->name] = $tag->term_id;
    338351    }
     
    411424
    412425    $tag = &get_term($tag_id, 'post_tag');
     426    if ( is_wp_error( $tag ) )
     427        return $tag;
    413428    $slug = $tag->slug;
    414429
     
    451466
    452467    $tag_list = $before;
    453     foreach ( $tags as $tag )
    454         $tag_links[] = '<a href="' . get_tag_link($tag->term_id) . '" rel="tag">' . $tag->name . '</a>';
     468    foreach ( $tags as $tag ) {
     469        $link = get_tag_link($tag->term_id);
     470        if ( is_wp_error( $link ) )
     471            return $link;
     472        $tag_links[] = '<a href="' . $link . '" rel="tag">' . $tag->name . '</a>';
     473    }
    455474
    456475    $tag_links = join( $sep, $tag_links );
     
    464483
    465484function the_tags( $before = 'Tags: ', $sep = ', ', $after = '' ) {
    466     echo get_the_tag_list($before, $sep, $after);
     485    $return = get_the_tag_list($before, $sep, $after);
     486    if ( is_wp_error( $return ) )
     487        return false;
     488    else
     489        echo $return;
    467490}
    468491
Note: See TracChangeset for help on using the changeset viewer.