Make WordPress Core


Ignore:
Timestamp:
09/15/2015 06:53:12 PM (10 years ago)
Author:
wonderboymusic
Message:

In WP::parse_request(), don't add query vars of non-viewable post types to WP::public_query_vars. In register_post_type(), don't add query vars of non-viewable post types to WP::public_query_vars.
In _unregister_post_type() (unit tests), don't add query vars of non-viewable post types to WP::public_query_vars.

Adds unit test.

Fixes #30018.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp.php

    r33734 r34215  
    262262        $this->public_query_vars = apply_filters( 'query_vars', $this->public_query_vars );
    263263
    264         foreach ( get_post_types( array(), 'objects' ) as $post_type => $t )
    265             if ( $t->query_var )
     264        foreach ( get_post_types( array(), 'objects' ) as $post_type => $t ) {
     265            if ( is_post_type_viewable( $t ) && $t->query_var ) {
    266266                $post_type_query_vars[$t->query_var] = $post_type;
     267            }
     268        }
    267269
    268270        foreach ( $this->public_query_vars as $wpvar ) {
Note: See TracChangeset for help on using the changeset viewer.