Changeset 36525
- Timestamp:
- 02/13/2016 03:50:37 AM (9 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp.php
r36365 r36525 332 332 $this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); 333 333 334 // Don't allow non-public taxonomies to be queried from the front-end.334 // Don't allow non-publicly queryable taxonomies to be queried from the front-end. 335 335 if ( ! is_admin() ) { 336 foreach ( get_taxonomies( array( 'public ' => false ), 'objects' ) as $taxonomy => $t ) {336 foreach ( get_taxonomies( array( 'publicly_queryable' => false ), 'objects' ) as $taxonomy => $t ) { 337 337 /* 338 338 * Disallow when set to the 'taxonomy' query var. 339 * Non-public taxonomies cannot register custom query vars. See register_taxonomy().339 * Non-publicly queryable taxonomies cannot register custom query vars. See register_taxonomy(). 340 340 */ 341 341 if ( isset( $this->query_vars['taxonomy'] ) && $taxonomy === $this->query_vars['taxonomy'] ) { -
trunk/src/wp-includes/taxonomy.php
r36516 r36525 289 289 * Default empty array. 290 290 * @type string $description A short descriptive summary of what the taxonomy is for. Default empty. 291 * @type bool $public Whether the taxonomy is publicly queryable. Default true. 291 * @type bool $public Whether a taxonomy is intended for use publicly either via 292 * the admin interface or by front-end users. The default settings 293 * of `$publicly_queryable`, `$show_ui`, and `$show_in_nav_menus` 294 * are inherited from `$public`. 295 * @type bool $publicly_queryable Whether the taxonomy is publicly queryable. 296 * If not set, the default is inherited from `$public` 292 297 * @type bool $hierarchical Whether the taxonomy is hierarchical. Default false. 293 298 * @type bool $show_ui Whether to generate and allow a UI for managing terms in this taxonomy in … … 363 368 'description' => '', 364 369 'public' => true, 370 'publicly_queryable' => null, 365 371 'hierarchical' => false, 366 372 'show_ui' => null, … … 384 390 } 385 391 386 // Non-public taxonomies should not register query vars, except in the admin. 387 if ( false !== $args['query_var'] && ( is_admin() || false !== $args['public'] ) && ! empty( $wp ) ) { 392 // If not set, default to the setting for public. 393 if ( null === $args['publicly_queryable'] ) { 394 $args['publicly_queryable'] = $args['public']; 395 } 396 397 // Non-publicly queryable taxonomies should not register query vars, except in the admin. 398 if ( false !== $args['query_var'] && ( is_admin() || false !== $args['publicly_queryable'] ) && ! empty( $wp ) ) { 388 399 if ( true === $args['query_var'] ) 389 400 $args['query_var'] = $taxonomy; -
trunk/tests/phpunit/includes/utils.php
r36316 r36525 363 363 364 364 foreach ( get_taxonomies( array() , 'objects' ) as $t ) { 365 if ( $t->public && ! empty( $t->query_var ) )365 if ( $t->publicly_queryable && ! empty( $t->query_var ) ) 366 366 $GLOBALS['wp']->add_query_var( $t->query_var ); 367 367 } -
trunk/tests/phpunit/tests/taxonomy.php
r36247 r36525 447 447 * @ticket 21949 448 448 */ 449 public function test_nonpublic _taxonomy_should_not_be_queryable_using_taxname_query_var() {449 public function test_nonpublicly_queryable_taxonomy_should_not_be_queryable_using_taxname_query_var() { 450 450 register_taxonomy( 'wptests_tax', 'post', array( 451 'public ' => false,451 'publicly_queryable' => false, 452 452 ) ); 453 453 … … 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() {469 public function test_it_should_be_possible_to_register_a_query_var_that_matches_the_name_of_a_nonpublicly_queryable_taxonomy() { 470 470 global $wp; 471 471 472 472 register_taxonomy( 'wptests_tax', 'post', array( 473 'public ' => false,473 'publicly_queryable' => false, 474 474 ) ); 475 475 $t = $this->factory->term->create_and_get( array( … … 502 502 * @ticket 21949 503 503 */ 504 public function test_nonpublic_taxonomy_should_not_be_queryable_using_taxonomy_and_term_vars() { 504 public function test_nonpublicly_queryable_taxonomy_should_not_be_queryable_using_taxonomy_and_term_vars() { 505 register_taxonomy( 'wptests_tax', 'post', array( 506 'publicly_queryable' => false, 507 ) ); 508 509 $t = self::factory()->term->create_and_get( array( 510 'taxonomy' => 'wptests_tax', 511 ) ); 512 513 $p = self::factory()->post->create(); 514 wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); 515 516 $this->go_to( '/?taxonomy=wptests_tax&term=' . $t->slug ); 517 518 $this->assertFalse( is_tax( 'wptests_tax' ) ); 519 } 520 521 /** 522 * @ticket 34491 523 */ 524 public function test_public_taxonomy_should_be_publicly_queryable() { 525 register_taxonomy( 'wptests_tax', 'post', array( 526 'public' => true, 527 ) ); 528 529 $this->assertContains( 'wptests_tax', get_taxonomies( array( 'publicly_queryable' => true ) ) ); 530 531 $t = self::factory()->term->create_and_get( array( 532 'taxonomy' => 'wptests_tax', 533 ) ); 534 535 $p = self::factory()->post->create(); 536 wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); 537 538 $this->go_to( '/?wptests_tax=' . $t->slug ); 539 540 $this->assertTrue( is_tax( 'wptests_tax' ) ); 541 } 542 543 /** 544 * @ticket 34491 545 */ 546 public function test_private_taxonomy_should_not_be_publicly_queryable() { 505 547 register_taxonomy( 'wptests_tax', 'post', array( 506 548 'public' => false, 507 549 ) ); 508 550 551 $this->assertContains( 'wptests_tax', get_taxonomies( array( 'publicly_queryable' => false ) ) ); 552 509 553 $t = self::factory()->term->create_and_get( array( 510 554 'taxonomy' => 'wptests_tax', … … 514 558 wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); 515 559 516 $this->go_to( '/? taxonomy=wptests_tax&term=' . $t->slug );560 $this->go_to( '/?wptests_tax=' . $t->slug ); 517 561 518 562 $this->assertFalse( is_tax( 'wptests_tax' ) ); 563 } 564 565 /** 566 * @ticket 34491 567 */ 568 public function test_private_taxonomy_should_be_overridden_by_publicly_queryable() { 569 register_taxonomy( 'wptests_tax', 'post', array( 570 'public' => false, 571 'publicly_queryable' => true, 572 ) ); 573 574 $this->assertContains( 'wptests_tax', get_taxonomies( array( 'publicly_queryable' => true ) ) ); 575 576 $t = self::factory()->term->create_and_get( array( 577 'taxonomy' => 'wptests_tax', 578 ) ); 579 580 $p = self::factory()->post->create(); 581 wp_set_object_terms( $p, $t->slug, 'wptests_tax' ); 582 583 $this->go_to( '/?wptests_tax=' . $t->slug ); 584 585 $this->assertTrue( is_tax( 'wptests_tax' ) ); 519 586 } 520 587
Note: See TracChangeset
for help on using the changeset viewer.