WordPress.org

Make WordPress Core

Ticket #21700: 21700.diff

File 21700.diff, 1.2 KB (added by wonderboymusic, 5 years ago)
  • wp-includes/canonical.php

    diff --git wp-includes/canonical.php wp-includes/canonical.php
    index 423dcc6..6bc4c1d 100644
    function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    218218                        $redirect['query'] = remove_query_arg( 'page', $redirect['query'] );
    219219                }
    220220
     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                }
     229
    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