Making WordPress.org

Changeset 9803


Ignore:
Timestamp:
05/01/2020 05:12:07 AM (4 years ago)
Author:
dd32
Message:

Theme Directory: Ignore a bunch of query vars when processing WordPress requests.

We don't need to support most of the WordPress query vars as we only use a small number of them.

Fixes #5183.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/plugins/theme-directory/query-modifications.php

    r9522 r9803  
    207207}
    208208add_action( 'parse_request', 'wporg_themes_parse_request' );
     209
     210/**
     211 * Remove support for any query vars the Theme Directory doesn't support/need.
     212 *
     213 * This should only apply to Rewrite rules, so WP_Query can use anything it needs.
     214 */
     215function wporg_themes_remove_query_vars( $qv ) {
     216    $not_needed = [
     217        'm', 'w', 'year', 'monthnum', 'day', 'hour', 'minute', 'second',
     218        'posts', 'withcomments', 'withoutcomments',
     219        'search', 'exact', 'sentence', 'calendar', 'more', 'tb', 'pb',
     220        'attachment', 'attachment_id', 'subpost', 'subpost_id', 'preview',
     221        'favicon', 'cpage', 'embed', 'post_format',
     222    ];
     223
     224    return array_diff( $qv, $not_needed );
     225}
     226add_filter( 'query_vars', 'wporg_themes_remove_query_vars', 0 );
Note: See TracChangeset for help on using the changeset viewer.