- Timestamp:
- 03/12/2014 04:07:41 AM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r27456 r27511 3664 3664 } 3665 3665 } elseif ( $this->is_tag ) { 3666 $term = get_term( $this->get( 'tag_id' ), 'post_tag' ); 3666 if ( $this->get( 'tag_id' ) ) { 3667 $term = get_term( $this->get( 'tag_id' ), 'post_tag' ); 3668 } elseif ( $this->get( 'tag' ) ) { 3669 $term = get_term_by( 'slug', $this->get( 'tag' ), 'post_tag' ); 3670 } 3667 3671 } else { 3668 3672 $tax_query_in_and = wp_list_filter( $this->tax_query->queries, array( 'operator' => 'NOT IN' ), 'NOT' ); -
trunk/tests/phpunit/tests/query.php
r27456 r27511 105 105 $query->set( 'posts_per_rss', 30 ); 106 106 } 107 108 /** 109 * @ticket 26627 110 */ 111 function test_tag_queried_object() { 112 $slug = 'tag-slug-26627'; 113 $this->factory->tag->create( array( 'slug' => $slug ) ); 114 $tag = get_term_by( 'slug', $slug, 'post_tag' ); 115 116 add_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 ); 117 118 $this->go_to( get_term_link( $tag ) ); 119 120 $this->assertQueryTrue( 'is_tag', 'is_archive' ); 121 $this->assertNotEmpty( get_query_var( 'tag_id' ) ); 122 $this->assertNotEmpty( get_query_var( 'tag' ) ); 123 $this->assertEmpty( get_query_var( 'tax_query' ) ); 124 $this->assertCount( 1, get_query_var( 'tag_slug__in' ) ); 125 $this->assertEquals( get_queried_object(), $tag ); 126 127 remove_action( 'pre_get_posts', array( $this, '_tag_queried_object' ), 11 ); 128 } 129 130 function _tag_queried_object( &$query ) { 131 $tag = get_term_by( 'slug', 'tag-slug-26627', 'post_tag' ); 132 $this->assertTrue( $query->is_tag() ); 133 $this->assertTrue( $query->is_archive() ); 134 $this->assertNotEmpty( $query->get( 'tag' ) ); 135 $this->assertCount( 1, $query->get( 'tag_slug__in' ) ); 136 $this->assertEquals( $query->get_queried_object(), $tag ); 137 } 107 138 }
Note: See TracChangeset
for help on using the changeset viewer.