Make WordPress Core


Ignore:
Timestamp:
10/04/2010 10:37:25 AM (15 years ago)
Author:
dd32
Message:

Introduce hierarchical taxonomy URL's, Can be enabled by setting 'hierarchical_url' to true upon taxonomy registration. See #12659

File:
1 edited

Legend:

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

    r15615 r15705  
    155155
    156156            $obj = $wp_query->get_queried_object();
    157 
    158             if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) )
    159                     && !is_wp_error($tax_url) && $redirect['query'] ) {
    160                 if ( is_category() ) {
    161                     $redirect['query'] = remove_query_arg( array( 'category_name', 'category', 'cat'), $redirect['query']);
    162                 } elseif ( is_tag() ) {
    163                     $redirect['query'] = remove_query_arg( array( 'tag', 'tag_id'), $redirect['query']);
    164                 } elseif ( is_tax() ) { // Custom taxonomies will have a custom query var, remove those too:
    165                     $tax = get_taxonomy( $obj->taxonomy );
    166                     if ( false !== $tax->query_var)
    167                         $redirect['query'] = remove_query_arg($tax->query_var, $redirect['query']);
    168                     else
    169                         $redirect['query'] = remove_query_arg( array( 'term', 'taxonomy'), $redirect['query']);
     157            if ( $term_count <= 1 && !empty($obj->term_id) && ( $tax_url = get_term_link((int)$obj->term_id, $obj->taxonomy) ) && !is_wp_error($tax_url) ) {
     158                if ( !empty($redirect['query']) ) {
     159                    if ( is_category() ) {
     160                        $redirect['query'] = remove_query_arg( array( 'category_name', 'category', 'cat'), $redirect['query']);
     161                    } elseif ( is_tag() ) {
     162                        $redirect['query'] = remove_query_arg( array( 'tag', 'tag_id'), $redirect['query']);
     163                    } elseif ( is_tax() ) { // Custom taxonomies will have a custom query var, remove those too:
     164                        $tax = get_taxonomy( $obj->taxonomy );
     165                        if ( false !== $tax->query_var)
     166                            $redirect['query'] = remove_query_arg($tax->query_var, $redirect['query']);
     167                        else
     168                            $redirect['query'] = remove_query_arg( array( 'term', 'taxonomy'), $redirect['query']);
     169                    }
    170170                }
    171 
    172171                $tax_url = parse_url($tax_url);
    173172                if ( ! empty($tax_url['query']) ) { // Custom taxonomies may only be accessable via ?taxonomy=..&term=..
     
    177176                    $redirect['path'] = $tax_url['path'];
    178177                }
    179 
    180178            }
    181179        } elseif ( is_single() && strpos($wp_rewrite->permalink_structure, '%category%') !== false ) {
Note: See TracChangeset for help on using the changeset viewer.