WordPress.org

Make WordPress Core

Changeset 13480


Ignore:
Timestamp:
02/28/10 02:49:01 (4 years ago)
Author:
dd32
Message:

Dont clobber taxonomy intersections/unions. Only redirects to the canonical url if only one term has been queried. Props scribu for some of the commit. See #8948

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/canonical.php

    r13427 r13480  
    133133            if ( false !== $author && $redirect_url = get_author_posts_url($author->ID, $author->user_nicename) ) 
    134134                $redirect['query'] = remove_query_arg('author', $redirect['query']); 
    135         } 
    136  
    137         // Terms (Tags/categories) 
    138         if ( is_category() || is_tag() || is_tax() ) { 
     135        } elseif ( is_category() || is_tag() || is_tax() ) { // Terms (Tags/categories) 
     136 
     137            $term_count = 0; 
     138            foreach ( array('category__in', 'category__not_in', 'category__and', 'post__in', 'post__not_in', 
     139            'tag__in', 'tag__not_in', 'tag__and', 'tag_slug__in', 'tag_slug__and') as $key ) 
     140                $term_count += count($wp_query->query_vars[$key]); 
     141 
    139142            $obj = $wp_query->get_queried_object(); 
    140             if ( !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) { 
    141  
    142                 $redirect['query'] = remove_query_arg( array( 'category_name', 'tag', 'cat', 'tag_id', 'term', 'taxonomy'), $redirect['query']); 
    143                 if ( is_tax() ) { // Custom taxonomies will have a custom query var, remove those too: 
     143 
     144            if ( $term_count > 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) { 
     145 
     146                if ( is_category() ) { 
     147                    $redirect['query'] = remove_query_arg( array( 'category_name', 'category', 'cat'), $redirect['query']); 
     148                } elseif ( is_tag() ) { 
     149                    $redirect['query'] = remove_query_arg( array( 'tag', 'tag_id'), $redirect['query']); 
     150                } elseif ( is_tax() ) { // Custom taxonomies will have a custom query var, remove those too: 
    144151                    $tax = get_taxonomy( $obj->taxonomy ); 
    145152                    if ( false !== $tax->query_var) 
    146153                        $redirect['query'] = remove_query_arg($tax->query_var, $redirect['query']); 
     154                    else 
     155                        $redirect['query'] = remove_query_arg( array( 'term', 'taxonomy'), $redirect['query']); 
    147156                } 
    148157 
Note: See TracChangeset for help on using the changeset viewer.