Make WordPress Core

Changeset 6823


Ignore:
Timestamp:
02/13/2008 07:02:08 PM (17 years ago)
Author:
ryan
Message:

Allow is_single(), is_category(), and is_tag() to accept arrays. Props fitzrev. fixes #5593

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/query.php

    r6763 r6823  
    6666    $author_obj = $wp_query->get_queried_object();
    6767
    68     if ( $author == $author_obj->ID )
    69         return true;
    70     elseif ( $author == $author_obj->nickname )
    71         return true;
    72     elseif ( $author == $author_obj->user_nicename )
     68    $author = (array) $author;
     69
     70    if ( in_array( $author_obj->ID, $author ) )
     71        return true;
     72    elseif ( in_array( $author_obj->nickname, $author ) )
     73        return true;
     74    elseif ( in_array( $author_obj->user_nicename, $author ) )
    7375        return true;
    7476
     
    8789    $cat_obj = $wp_query->get_queried_object();
    8890
    89     if ( $category == $cat_obj->term_id )
    90         return true;
    91     else if ( $category == $cat_obj->name )
    92         return true;
    93     elseif ( $category == $cat_obj->slug )
     91    $category = (array) $category;
     92
     93    if ( in_array( $cat_obj->term_id, $category ) )
     94        return true;
     95    elseif ( in_array( $cat_obj->name, $category ) )
     96        return true;
     97    elseif ( in_array( $cat_obj->slug, $category ) )
    9498        return true;
    9599
     
    99103function is_tag( $slug = '' ) {
    100104    global $wp_query;
     105
    101106    if ( !$wp_query->is_tag )
    102107        return false;
     
    106111
    107112    $tag_obj = $wp_query->get_queried_object();
    108     if ( $slug == $tag_obj->slug )
    109         return true;
     113
     114    $slug = (array) $slug;
     115
     116    if ( in_array( $tag_obj->slug, $slug ) )
     117        return true;
     118
    110119    return false;
    111120}
     
    241250    $post_obj = $wp_query->get_queried_object();
    242251
    243     if ( $post == $post_obj->ID )
    244         return true;
    245     elseif ( $post == $post_obj->post_title )
    246         return true;
    247     elseif ( $post == $post_obj->post_name )
     252    $post = (array) $post;
     253
     254    if ( in_array( $post_obj->ID, $post ) )
     255        return true;
     256    elseif ( in_array( $post_obj->post_title, $post ) )
     257        return true;
     258    elseif ( in_array( $post_obj->post_name, $post ) )
    248259        return true;
    249260
Note: See TracChangeset for help on using the changeset viewer.