WordPress.org

Make WordPress Core

Ticket #39535: 39535.diff

File 39535.diff, 1.4 KB (added by asalce, 4 years ago)
  • wp-includes/canonical.php

    diff --git a/wp-includes/canonical.php b/wp-includes/canonical.php
    index 11c513d..cb8d1d2 100644
    a b function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    282282                        while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $redirect['path'] ) || preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] ) ) {
    283283                                // Strip off paging and feed
    284284                                $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging
    285                                 $redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings
    286285                                $redirect['path'] = preg_replace("#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing comment paging
     286                                // only strip comments/ from comment feed on site
     287                                if($redirect['path'] == preg_replace("#(https?:)?//[^/]+#","",get_feed_link('comments_rss2'))){
     288                                        $redirect['path'] = preg_replace('#/(comments/)(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']);
     289                                } else {
     290                                        $redirect['path'] = preg_replace('#/(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings
     291                                }
    287292                        }
    288293
    289294                        $addl_path = '';