WordPress.org

Make WordPress Core

Ticket #14288: canonical_trunk.diff

File canonical_trunk.diff, 3.1 KB (added by rfw, 4 years ago)

Patch for canonical.php against trunk.

  • wp-includes/canonical.php

     
    187187 
    188188                // paging and feeds 
    189189                if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) { 
    190                         if ( !$redirect_url ) 
    191                                 $redirect_url = $requested_url; 
    192                         $paged_redirect = @parse_url($redirect_url); 
    193                         while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", $paged_redirect['path'] ) || preg_match( '#/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?$#', $paged_redirect['path'] ) || preg_match( '#/comment-page-[0-9]+(/+)?$#', $paged_redirect['path'] ) ) { 
     190                        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'] ) ) { 
    194191                                // Strip off paging and feed 
    195                                 $paged_redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $paged_redirect['path']); // strip off any existing paging 
    196                                 $paged_redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $paged_redirect['path']); // strip off feed endings 
    197                                 $paged_redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $paged_redirect['path']); // strip off any existing comment paging 
     192                                $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?$#", '/', $redirect['path']); // strip off any existing paging 
     193                                $redirect['path'] = preg_replace('#/(comments/?)?(feed|rss2?|rdf|atom)(/+|$)#', '/', $redirect['path']); // strip off feed endings 
     194                                $redirect['path'] = preg_replace('#/comment-page-[0-9]+?(/+)?$#', '/', $redirect['path']); // strip off any existing comment paging 
    198195                        } 
    199196 
    200197                        $addl_path = ''; 
     
    225222                                $redirect['query'] = remove_query_arg( 'cpage', $redirect['query'] ); 
    226223                        } 
    227224 
    228                         $paged_redirect['path'] = user_trailingslashit( preg_replace('|/index.php/?$|', '/', $paged_redirect['path']) ); // strip off trailing /index.php/ 
    229                         if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($paged_redirect['path'], '/index.php/') === false ) 
    230                                 $paged_redirect['path'] = trailingslashit($paged_redirect['path']) . 'index.php/'; 
     225                        $redirect['path'] = user_trailingslashit( preg_replace('|/index.php/?$|', '/', $redirect['path']) ); // strip off trailing /index.php/ 
     226                        if ( !empty( $addl_path ) && $wp_rewrite->using_index_permalinks() && strpos($redirect['path'], '/index.php/') === false ) 
     227                                $redirect['path'] = trailingslashit($redirect['path']) . 'index.php/'; 
    231228                        if ( !empty( $addl_path ) ) 
    232                                 $paged_redirect['path'] = trailingslashit($paged_redirect['path']) . $addl_path; 
    233                         $redirect_url = $paged_redirect['scheme'] . '://' . $paged_redirect['host'] . $paged_redirect['path']; 
    234                         $redirect['path'] = $paged_redirect['path']; 
     229                                $redirect['path'] = trailingslashit($redirect['path']) . $addl_path; 
     230                        $redirect_url = $redirect['scheme'] . '://' . $redirect['host'] . $redirect['path']; 
     231                        $redirect['path'] = $redirect['path']; 
    235232                } 
    236233        } 
    237234