Make WordPress Core

Ticket #16133: 16133.diff

File 16133.diff, 2.3 KB (added by mdawaffe, 13 years ago)
  • wp-includes/canonical.php

     
    7979                }
    8080        }
    8181
     82        $preg_prefix = '';
     83
    8284        // These tests give us a WP-generated permalink
    8385        if ( is_404() ) {
    8486
     
    150152                                $term_count += count( $tax_query['terms'] );
    151153
    152154                        $obj = $wp_query->get_queried_object();
     155                        $taxonomy = get_taxonomy( $obj->taxonomy );
     156                        if ( $taxonomy->rewrite ) {
     157                                $preg_prefix = '(?<!/' . preg_quote( $taxonomy->rewrite['slug'], '#' ).  ')';
     158                        }
     159
    153160                        if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
    154161                                if ( !empty($redirect['query']) ) {
    155162                                        if ( is_category() ) {
     
    187194
    188195                // paging and feeds
    189196                if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
    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'] ) ) {
     197                        while ( preg_match( "#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?\$#", $redirect['path'] ) || preg_match( "#$preg_prefix/(comments/?)?(feed|rss|rdf|atom|rss2)(/+)?\$#", $redirect['path'] ) || preg_match( "#$preg_prefix/comment-page-[0-9]+(/+)?\$#", $redirect['path'] ) ) {
    191198                                // Strip off paging and feed
    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
     199                                $redirect['path'] = preg_replace("#/$wp_rewrite->pagination_base/?[0-9]+?(/+)?\$#", '/', $redirect['path']); // strip off any existing paging
     200                                $redirect['path'] = preg_replace("#$preg_prefix/(comments/?)?(feed|rss2?|rdf|atom)(/+|\$)#", '/', $redirect['path']); // strip off feed endings
     201                                $redirect['path'] = preg_replace("#$preg_prefix/comment-page-[0-9]+?(/+)?\$#", '/', $redirect['path']); // strip off any existing comment paging
    195202                        }
    196203
    197204                        $addl_path = '';