Ticket #34491: 34491.patch
File 34491.patch, 6.3 KB (added by , 5 years ago) |
---|
-
src/wp-includes/class-wp.php
308 308 if ( $t->query_var && isset( $this->query_vars[$t->query_var] ) ) 309 309 $this->query_vars[$t->query_var] = str_replace( ' ', '+', $this->query_vars[$t->query_var] ); 310 310 311 // Don't allow non-public taxonomies to be queried from the front-end.311 // Don't allow non-publicly queryable taxonomies to be queried from the front-end. 312 312 if ( ! is_admin() ) { 313 foreach ( get_taxonomies( array( 'public ' => false ), 'objects' ) as $taxonomy => $t ) {313 foreach ( get_taxonomies( array( 'publicly_queryable' => false ), 'objects' ) as $taxonomy => $t ) { 314 314 /* 315 315 * Disallow when set to the 'taxonomy' query var. 316 * Non-public taxonomies cannot register custom query vars. See register_taxonomy().316 * Non-publicly queryable taxonomies cannot register custom query vars. See register_taxonomy(). 317 317 */ 318 318 if ( isset( $this->query_vars['taxonomy'] ) && $taxonomy === $this->query_vars['taxonomy'] ) { 319 319 unset( $this->query_vars['taxonomy'], $this->query_vars['term'] ); -
src/wp-includes/taxonomy-functions.php
289 289 * taxonomies. See accepted values in get_taxonomy_labels(). 290 290 * Default empty array. 291 291 * @type string $description A short descriptive summary of what the taxonomy is for. Default empty. 292 * @type bool $public Whether the taxonomy is publicly queryable. Default true. 292 * @type bool $public Whether a taxonomy is intended for use publicly either via 293 * the admin interface or by front-end users. While the default settings 294 * of `$publicly_queryable`, `$show_ui`, and `$show_in_nav_menus` 295 * are inherited from `$public`, each does not rely on this relationship 296 * and controls a very specific intention (default true). 297 * @type bool $publicly_queryable Whether the taxonomy is publicly queryable. 298 * If not set, the default is inherited from `$public` 293 299 * @type bool $hierarchical Whether the taxonomy is hierarchical. Default false. 294 300 * @type bool $show_ui Whether to generate and allow a UI for managing terms in this taxonomy in 295 301 * the admin. If not set, the default is inherited from `$public` … … 363 369 'labels' => array(), 364 370 'description' => '', 365 371 'public' => true, 372 'publicly_queryable' => null, 366 373 'hierarchical' => false, 367 374 'show_ui' => null, 368 375 'show_in_menu' => null, … … 384 391 return new WP_Error( 'taxonomy_length_invalid', __( 'Taxonomy names must be between 1 and 32 characters in length.' ) ); 385 392 } 386 393 387 if ( false !== $args['query_var'] && false !== $args['public'] && ! empty( $wp ) ) { 394 // If not set, default to the setting for public. 395 if ( null === $args['publicly_queryable'] ) { 396 $args['publicly_queryable'] = $args['public']; 397 } 398 399 if ( false !== $args['query_var'] && false !== $args['publicly_queryable'] && ! empty( $wp ) ) { 388 400 if ( true === $args['query_var'] ) 389 401 $args['query_var'] = $taxonomy; 390 402 else -
tests/phpunit/includes/utils.php
357 357 unset( $GLOBALS[$v] ); 358 358 359 359 foreach ( get_taxonomies( array() , 'objects' ) as $t ) { 360 if ( $t->public && ! empty( $t->query_var ) )360 if ( $t->publicly_queryable && ! empty( $t->query_var ) ) 361 361 $GLOBALS['wp']->add_query_var( $t->query_var ); 362 362 } 363 363 … … 398 398 */ 399 399 function benchmark_pcre_backtracking( $pattern, $subject, $strategy ) { 400 400 $saved_config = ini_get( 'pcre.backtrack_limit' ); 401 401 402 402 // Attempt to prevent PHP crashes. Adjust these lower when needed. 403 403 if ( version_compare( phpversion(), '5.4.8', '>' ) ) { 404 404 $limit = 1000000; … … 410 410 for( $i = 4; $i <= $limit; $i *= 2 ) { 411 411 412 412 ini_set( 'pcre.backtrack_limit', $i ); 413 413 414 414 switch( $strategy ) { 415 415 case 'split': 416 416 preg_split( $pattern, $subject ); -
tests/phpunit/tests/taxonomy.php
446 446 /** 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 454 454 $t = self::factory()->term->create_and_get( array( … … 466 466 /** 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( 476 476 'taxonomy' => 'wptests_tax', … … 501 501 /** 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 505 register_taxonomy( 'wptests_tax', 'post', array( 506 'public ' => false,506 'publicly_queryable' => false, 507 507 ) ); 508 508 509 509 $t = self::factory()->term->create_and_get( array(