Make WordPress Core

Ticket #35089: 35089.diff

File 35089.diff, 1.2 KB (added by boonebgorges, 10 years ago)
  • src/wp-includes/taxonomy.php

    diff --git src/wp-includes/taxonomy.php src/wp-includes/taxonomy.php
    index 84cc91a..dba6e54 100644
    function register_taxonomy( $taxonomy, $object_type, $args = array() ) { 
    390390                else
    391391                        $args['query_var'] = sanitize_title_with_dashes( $args['query_var'] );
    392392                $wp->add_query_var( $args['query_var'] );
     393        } else {
     394                // Force query_var to false for non-public taxonomies.
     395                $args['query_var'] = false;
    393396        }
    394397
    395398        if ( false !== $args['rewrite'] && ( is_admin() || '' != get_option( 'permalink_structure' ) ) ) {
  • tests/phpunit/tests/taxonomy.php

    diff --git tests/phpunit/tests/taxonomy.php tests/phpunit/tests/taxonomy.php
    index 2063bbe..0cf6516 100644
    class Tests_Taxonomy extends WP_UnitTestCase { 
    517517
    518518                $this->assertFalse( is_tax( 'wptests_tax' ) );
    519519        }
     520
     521        /**
     522         * @ticket 35089
     523         */
     524        public function test_query_var_should_be_forced_to_false_for_non_public_taxonomy() {
     525                register_taxonomy( 'wptests_tax', 'post', array(
     526                        'public' => false,
     527                        'query_var' => true,
     528                ) );
     529
     530                $tax = get_taxonomy( 'wptests_tax' );
     531                $this->assertFalse( $tax->query_var );
     532        }
    520533}