Make WordPress Core

Changeset 17706


Ignore:
Timestamp:
04/26/2011 10:49:00 AM (14 years ago)
Author:
dd32
Message:

Allow Taxonomies to be queried by $_GET parameters on non-taxonomy url's. See #17174

File:
1 edited

Legend:

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

    r17498 r17706  
    165165                    }
    166166                }
     167
     168                $tax_obj = get_taxonomy( $obj->taxonomy );
     169                $tax_query_vars = array_diff( array_keys( $wp_query->query ), array_keys( $_GET ), array( 'taxonomy', 'term', $tax_obj->query_var ) );
     170
    167171                $tax_url = parse_url($tax_url);
    168                 if ( ! empty($tax_url['query']) ) { // Custom taxonomies may only be accessable via ?taxonomy=..&term=..
     172                if ( ! empty($tax_query_vars) ) {
     173                    foreach ( array( 'taxonomy', 'term', $tax_obj->query_var ) as $qv ) {
     174                        if ( !empty($wp_query->query[$qv]) )
     175                            $redirect['query'] = add_query_arg($qv, $wp_query->query[$qv], $redirect['query']);
     176                    }
     177                       
     178                } elseif ( ! empty($tax_url['query']) ) { // Custom taxonomies may only be accessable via ?taxonomy=..&term=..
    169179                    parse_str($tax_url['query'], $query_vars);
    170180                    $redirect['query'] = add_query_arg($query_vars, $redirect['query']);
Note: See TracChangeset for help on using the changeset viewer.