Allow is_tag() to accept term_id, slug, 'term_name or array of any. Many other is_*()` funcs already do this. Adds unit tests.

Props ramiy.
Fixes #18746.



git-svn-id: https://develop.svn.wordpress.org/trunk@25287 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
Scott Taylor
2013-09-06 17:26:04 +00:00
parent c4068bc95b
commit 0474a18863
2 changed files with 25 additions and 10 deletions

View File

@@ -428,9 +428,20 @@ class Tests_Query_Conditionals extends WP_UnitTestCase {
// 'tag/(.+?)/?$' => 'index.php?tag=$matches[1]',
function test_tag() {
$this->factory->term->create( array( 'name' => 'tag-a', 'taxonomy' => 'post_tag' ) );
$term_id = $this->factory->term->create( array( 'name' => 'Tag Named A', 'slug' => 'tag-a', 'taxonomy' => 'post_tag' ) );
$this->go_to('/tag/tag-a/');
$this->assertQueryTrue('is_archive', 'is_tag');
$tag = get_term( $term_id, 'post_tag' );
$this->assertTrue( is_tag() );
$this->assertTrue( is_tag( $tag->name ) );
$this->assertTrue( is_tag( $tag->slug ) );
$this->assertTrue( is_tag( $tag->term_id ) );
$this->assertTrue( is_tag( array() ) );
$this->assertTrue( is_tag( array( $tag->name ) ) );
$this->assertTrue( is_tag( array( $tag->slug ) ) );
$this->assertTrue( is_tag( array( $tag->term_id ) ) );
}
// 'author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$' => 'index.php?author_name=$matches[1]&feed=$matches[2]',