Changeset 35333
- Timestamp:
- 10/21/2015 04:53:51 PM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp.php
r35205 r35333 312 312 if ( ! is_admin() ) { 313 313 foreach ( get_taxonomies( array( 'public' => false ), 'objects' ) as $taxonomy => $t ) { 314 // Check first for taxonomy-specific query_var. 315 if ( $t->query_var && isset( $this->query_vars[ $t->query_var ] ) ) { 316 unset( $this->query_vars[ $t->query_var ] ); 317 } 318 319 // Next, check the 'taxonomy' query_var. 314 /* 315 * Disallow when set to the 'taxonomy' query var. 316 * Non-public taxonomies cannot register custom query vars. See register_taxonomy(). 317 */ 320 318 if ( isset( $this->query_vars['taxonomy'] ) && $taxonomy === $this->query_vars['taxonomy'] ) { 321 319 unset( $this->query_vars['taxonomy'], $this->query_vars['term'] ); -
trunk/src/wp-includes/taxonomy-functions.php
r35322 r35333 385 385 } 386 386 387 if ( false !== $args['query_var'] && ! empty( $wp ) ) {387 if ( false !== $args['query_var'] && false !== $args['public'] && ! empty( $wp ) ) { 388 388 if ( true === $args['query_var'] ) 389 389 $args['query_var'] = $taxonomy; -
trunk/tests/phpunit/includes/utils.php
r34802 r35333 358 358 359 359 foreach ( get_taxonomies( array() , 'objects' ) as $t ) { 360 if ( ! empty( $t->query_var ) )360 if ( $t->public && ! empty( $t->query_var ) ) 361 361 $GLOBALS['wp']->add_query_var( $t->query_var ); 362 362 } -
trunk/tests/phpunit/tests/taxonomy.php
r35242 r35333 467 467 * @ticket 21949 468 468 */ 469 public function test_it_should_be_possible_to_register_a_query_var_that_matches_the_name_of_a_nonpublic_taxonomy() { 470 global $wp; 471 472 register_taxonomy( 'wptests_tax', 'post', array( 473 'public' => false, 474 ) ); 475 $t = $this->factory->term->create_and_get( array( 476 'taxonomy' => 'wptests_tax', 477 ) ); 478 479 $p = $this->factory->post->create(); 480 wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); 481 482 add_filter( 'do_parse_request', array( $this, 'register_query_var' ) ); 483 $this->go_to( '/?wptests_tax=foo' ); 484 remove_filter( 'do_parse_request', array( $this, 'register_query_var' ) ); 485 486 // Not a taxonomy... 487 $this->assertFalse( is_tax( 'wptests_tax' ) ); 488 489 // ...but query var works. 490 $this->assertSame( 'foo', $wp->query_vars['wptests_tax'] ); 491 } 492 493 public static function register_query_var( $r ) { 494 global $wp; 495 496 $wp->add_query_var( 'wptests_tax' ); 497 498 return $r; 499 } 500 501 /** 502 * @ticket 21949 503 */ 469 504 public function test_nonpublic_taxonomy_should_not_be_queryable_using_taxonomy_and_term_vars() { 470 505 register_taxonomy( 'wptests_tax', 'post', array(
Note: See TracChangeset
for help on using the changeset viewer.