Make WordPress Core


Ignore:
Timestamp:
02/13/2010 06:17:59 AM (15 years ago)
Author:
dd32
Message:

Canonicalisation of the Taxonomy urls. Redirect /category/child/ to /category/parent/child/. Fix striping of slashes to use $redirect instead of $original. See #8948

File:
1 edited

Legend:

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

    r13072 r13091  
    140140        }
    141141
     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) ) {
     152                $tax_url = parse_url($tax_url);
     153                $redirect['path'] = $tax_url['path'];
     154            }
     155        }
     156
    142157        // paging and feeds
    143158        if ( get_query_var('paged') || is_feed() || get_query_var('cpage') ) {
     
    258273    // Strip multiple slashes out of the URL
    259274    if ( strpos($original['path'], '//') > -1 )
    260         $redirect['path'] = preg_replace('|/+|', '/', $original['path']);
     275        $redirect['path'] = preg_replace('|/+|', '/', $redirect['path']);
    261276
    262277    // Always trailing slash the Front Page URL
Note: See TracChangeset for help on using the changeset viewer.