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/post-functions.php

    r34201 r34215  
    10731073    }
    10741074
    1075     if ( false !== $args->query_var && ! empty( $wp ) ) {
     1075    if ( false !== $args->query_var ) {
    10761076        if ( true === $args->query_var )
    10771077            $args->query_var = $post_type;
    10781078        else
    10791079            $args->query_var = sanitize_title_with_dashes( $args->query_var );
    1080         $wp->add_query_var( $args->query_var );
     1080
     1081        if ( $wp && is_post_type_viewable( $args ) ) {
     1082            $wp->add_query_var( $args->query_var );
     1083        }
    10811084    }
    10821085
Note: See TracChangeset for help on using the changeset viewer.