Changeset 13170 for trunk/wp-includes/canonical.php
- Timestamp:
- 02/16/2010 09:08:26 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/canonical.php
r13099 r13170 131 131 if ( $redirect_url = get_year_link(get_query_var('year')) ) 132 132 $redirect['query'] = remove_query_arg('year', $redirect['query']); 133 } elseif ( is_category() && !empty($_GET['cat']) && preg_match( '|^[0-9]+$|', $_GET['cat'] ) ) {134 if ( $redirect_url = get_category_link(get_query_var('cat')) )135 $redirect['query'] = remove_query_arg('cat', $redirect['query']);136 133 } elseif ( is_author() && !empty($_GET['author']) && preg_match( '|^[0-9]+$|', $_GET['author'] ) ) { 137 134 $author = get_userdata(get_query_var('author')); … … 140 137 } 141 138 142 // redirect sub-terms of taxonomies to their correct urls 143 if ( is_category() || is_tax() ) { 144 if ( is_category() ) { 145 $taxonomy = 'category'; 146 $slug = get_query_var('category_name'); 147 } else { 148 $taxonomy = get_query_var('taxonomy'); 149 $slug = get_query_var('term'); 150 } 151 if ( $tax_url = get_term_link($slug, $taxonomy) ) { 139 // Terms (Tags/categories) 140 if ( is_category() || is_tag() || is_tax() ) { 141 $obj = $wp_query->get_queried_object(); 142 if ( !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) { 143 144 $redirect['query'] = remove_query_arg( array( 'category_name', 'tag', 'cat', 'tag_id', 'term', 'taxonomy'), $redirect['query']); 145 if ( is_tax() ) { // Custom taxonomies will have a custom query var, remove those too: 146 $tax = get_taxonomy( $obj->taxonomy ); 147 if ( false !== $tax->query_var) 148 $redirect['query'] = remove_query_arg($tax->query_var, $redirect['query']); 149 } 150 152 151 $tax_url = parse_url($tax_url); 153 $redirect['path'] = $tax_url['path']; 152 if ( ! empty($tax_url['query']) ) { // Custom taxonomies may only be accessable via ?taxonomy=..&term=.. 153 parse_str($tax_url['query'], $query_vars); 154 $redirect['query'] = add_query_arg($query_vars, $redirect['query']); 155 } else { // Taxonomy is accessable via a "pretty-URL" 156 $redirect['path'] = $tax_url['path']; 157 } 158 154 159 } 155 160 }
Note: See TracChangeset
for help on using the changeset viewer.