Ticket #26627: 26627.2.diff
| File 26627.2.diff, 2.5 KB (added by , 12 years ago) |
|---|
-
src/wp-includes/query.php
3264 3264 3265 3265 if ( $this->is_category || $this->is_tag || $this->is_tax ) { 3266 3266 if ( $this->is_category ) { 3267 $term = get_term( $this->get( 'cat' ), 'category' ); 3267 if ( $this->get( 'cat' ) ) { 3268 $term = get_term( $this->get( 'cat' ), 'category' ); 3269 } elseif ( $this->get( 'category_name' ) ) { 3270 $term = get_term_by( 'slug', $this->get( 'category_name' ), 'category' ); 3271 } 3268 3272 } elseif ( $this->is_tag ) { 3269 3273 $term = get_term( $this->get( 'tag_id' ), 'post_tag' ); 3270 3274 } else { -
tests/phpunit/tests/query/taxQuery.php
17 17 protected $post_id; 18 18 19 19 protected $cat; 20 protected $uncat; 20 21 protected $tag; 21 22 protected $tax; 22 23 … … 48 49 _make_cat_compat( $this->cat ); 49 50 $this->tag = get_term( $this->tag_id, 'post_tag' ); 50 51 52 $this->uncat = get_term_by( 'slug', 'uncategorized', 'category' ); 53 _make_cat_compat( $this->uncat ); 54 51 55 add_action( 'pre_get_posts', array( $this, 'pre_get_posts_tax_category_tax_query' ) ); 52 56 } 53 57 … … 106 110 $this->assertEquals( get_queried_object(), $this->cat ); 107 111 } 108 112 113 function test_cat_uncat_action_tax() { 114 // category with tax added 115 add_action( 'pre_get_posts', array( $this, '_cat_uncat_action_tax' ), 11 ); 116 117 $this->go_to( home_url( "/category/uncategorized/" ) ); 118 $this->assertQueryTrue( 'is_category', 'is_archive' ); 119 $this->assertNotEmpty( get_query_var( 'cat' ) ); 120 $this->assertNotEmpty( get_query_var( 'tax_query' ) ); 121 $this->assertNotEmpty( get_query_var( 'taxonomy' ) ); 122 $this->assertNotEmpty( get_query_var( 'term_id' ) ); 123 $this->assertEquals( get_queried_object(), $this->uncat ); 124 125 remove_action( 'pre_get_posts', array( $this, '_cat_uncat_action_tax' ), 11 ); 126 } 127 128 function _cat_uncat_action_tax( &$query ) { 129 $this->assertTrue( $query->is_category() ); 130 $this->assertTrue( $query->is_archive() ); 131 $this->assertNotEmpty( $query->get( 'category_name' ) ); 132 $this->assertNotEmpty( $query->get( 'tax_query' ) ); 133 $this->assertEquals( $query->get_queried_object(), $this->uncat ); 134 } 135 109 136 function test_tax_query_tag_action_tax() { 110 137 // tax + tag with tax added 111 138 $this->go_to( home_url( "/testtax/tax-slug2/?tag_id=$this->tag_id" ) );