WordPress.org

Make WordPress Core

Ticket #21700: allow-feedmatching-query-vars.diff

File allow-feedmatching-query-vars.diff, 1.3 KB (added by wonderboymusic, 7 years ago)
  • wp-includes/canonical.php

     
    217217                        $redirect_url = trailingslashit( $redirect_url ) . user_trailingslashit( get_query_var( 'page' ), 'single_paged' );
    218218                        $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
    219219                }
     220               
     221                // check for query vars other than feed that have values that match feed slugs
     222                $no_feed_vars = true;
     223                foreach ( $GLOBALS['wp']->query_vars as $var => $slug ) {
     224                        if ( preg_match( '#feed|rss2?|rdf|atom#', $slug ) && 'feed' !== $var ) {
     225                                $no_feed_vars = false;
     226                                break;
     227                        }                       
     228                }
    220229
    221230                // paging and feeds
    222                 if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
     231                if ( get_query_var('paged') || ( is_feed() && $no_feed_vars ) || get_query_var('cpage') ) {
    223232                        while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $redirect['path'] ) ) {
    224233                                // Strip off paging and feed
    225234                                $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging