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

git-svn-id: http://svn.automattic.com/wordpress/trunk@6823 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan 2008-02-13 19:02:08 +00:00
parent 3b04c16b5e
commit daf0d9a7e9

View File

@ -65,11 +65,13 @@ function is_author ($author = '') {
$author_obj = $wp_query->get_queried_object(); $author_obj = $wp_query->get_queried_object();
if ( $author == $author_obj->ID ) $author = (array) $author;
if ( in_array( $author_obj->ID, $author ) )
return true; return true;
elseif ( $author == $author_obj->nickname ) elseif ( in_array( $author_obj->nickname, $author ) )
return true; return true;
elseif ( $author == $author_obj->user_nicename ) elseif ( in_array( $author_obj->user_nicename, $author ) )
return true; return true;
return false; return false;
@ -86,11 +88,13 @@ function is_category ($category = '') {
$cat_obj = $wp_query->get_queried_object(); $cat_obj = $wp_query->get_queried_object();
if ( $category == $cat_obj->term_id ) $category = (array) $category;
if ( in_array( $cat_obj->term_id, $category ) )
return true; return true;
else if ( $category == $cat_obj->name ) elseif ( in_array( $cat_obj->name, $category ) )
return true; return true;
elseif ( $category == $cat_obj->slug ) elseif ( in_array( $cat_obj->slug, $category ) )
return true; return true;
return false; return false;
@ -98,6 +102,7 @@ function is_category ($category = '') {
function is_tag( $slug = '' ) { function is_tag( $slug = '' ) {
global $wp_query; global $wp_query;
if ( !$wp_query->is_tag ) if ( !$wp_query->is_tag )
return false; return false;
@ -105,8 +110,12 @@ function is_tag( $slug = '' ) {
return true; return true;
$tag_obj = $wp_query->get_queried_object(); $tag_obj = $wp_query->get_queried_object();
if ( $slug == $tag_obj->slug )
$slug = (array) $slug;
if ( in_array( $tag_obj->slug, $slug ) )
return true; return true;
return false; return false;
} }
@ -240,11 +249,13 @@ function is_single ($post = '') {
$post_obj = $wp_query->get_queried_object(); $post_obj = $wp_query->get_queried_object();
if ( $post == $post_obj->ID ) $post = (array) $post;
if ( in_array( $post_obj->ID, $post ) )
return true; return true;
elseif ( $post == $post_obj->post_title ) elseif ( in_array( $post_obj->post_title, $post ) )
return true; return true;
elseif ( $post == $post_obj->post_name ) elseif ( in_array( $post_obj->post_name, $post ) )
return true; return true;
return false; return false;