WordPress.org

Make WordPress Core

Ticket #43274: 43274.diff

File 43274.diff, 2.9 KB (added by dimadin, 3 years ago)
  • src/wp-includes/canonical.php

    diff --git src/wp-includes/canonical.php src/wp-includes/canonical.php
    index ad219c2711..2ee9fa0a3e 100644
    function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    294294
    295295                        // paging and feeds
    296296                if ( get_query_var( 'paged' ) || is_feed() || get_query_var( 'cpage' ) ) {
    297                         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'] ) ) {
     297                        while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $redirect['path'] ) || preg_match( "#/($wp_rewrite->comments_base/?)?(feed|rss|rdf|atom|rss2)(/+)?$#", $redirect['path'] ) || preg_match( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+(/+)?$#", $redirect['path'] ) ) {
    298298                                // Strip off paging and feed
    299299                                $redirect['path'] = preg_replace( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path'] ); // strip off any existing paging
    300                                 $redirect['path'] = preg_replace( '#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path'] ); // strip off feed endings
     300                                $redirect['path'] = preg_replace( "#/($wp_rewrite->comments_base/?)?(feed|rss2?|rdf|atom)(/+|$)#", '/', $redirect['path'] ); // strip off feed endings
    301301                                $redirect['path'] = preg_replace( "#/{$wp_rewrite->comments_pagination_base}-[0-9]+?(/+)?$#", '/', $redirect['path'] ); // strip off any existing comment paging
    302302                        }
    303303
    function redirect_canonical( $requested_url = null, $do_redirect = true ) { 
    305305                        if ( is_feed() && in_array( get_query_var( 'feed' ), $wp_rewrite->feeds ) ) {
    306306                                $addl_path = ! empty( $addl_path ) ? trailingslashit( $addl_path ) : '';
    307307                                if ( ! is_singular() && get_query_var( 'withcomments' ) ) {
    308                                         $addl_path .= 'comments/';
     308                                        $addl_path .= "$wp_rewrite->comments_base/";
    309309                                }
    310310                                if ( ( 'rss' == get_default_feed() && 'feed' == get_query_var( 'feed' ) ) || 'rss' == get_query_var( 'feed' ) ) {
    311                                         $addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' );
     311                                        $addl_path .= user_trailingslashit( "$wp_rewrite->feed_base/" . ( ( get_default_feed() == 'rss2' ) ? '' : 'rss2' ), 'feed' );
    312312                                } else {
    313                                         $addl_path .= user_trailingslashit( 'feed/' . ( ( get_default_feed() == get_query_var( 'feed' ) || 'feed' == get_query_var( 'feed' ) ) ? '' : get_query_var( 'feed' ) ), 'feed' );
     313                                        $addl_path .= user_trailingslashit( "$wp_rewrite->feed_base/" . ( ( get_default_feed() == get_query_var( 'feed' ) || 'feed' == get_query_var( 'feed' ) ) ? '' : get_query_var( 'feed' ) ), 'feed' );
    314314                                }
    315315                                $redirect['query'] = remove_query_arg( 'feed', $redirect['query'] );
    316316                        } elseif ( is_feed() && 'old' == get_query_var( 'feed' ) ) {