Make WordPress Core

Changeset 15860


Ignore:
Timestamp:
10/20/2010 12:07:23 PM (16 years ago)
Author:
scribu
Message:

Fix 'taxonomy' and 'term' query var logic. See #12891

Location:
trunk/wp-includes
Files:
2 edited

Legend:

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

    r15847 r15860  
    282282                                }
    283283
    284                                 if ( isset( $taxonomy_query_vars[$wpvar] ) ) {
    285                                         $this->query_vars['taxonomy'] = $taxonomy_query_vars[$wpvar];
    286                                         $this->query_vars['term'] = $this->query_vars[$wpvar];
    287                                 } elseif ( isset($post_type_query_vars[$wpvar] ) ) {
     284                                if ( isset($post_type_query_vars[$wpvar] ) ) {
    288285                                        $this->query_vars['post_type'] = $post_type_query_vars[$wpvar];
    289286                                        $this->query_vars['name'] = $this->query_vars[$wpvar];
  • trunk/wp-includes/query.php

    r15850 r15860  
    14531453                        $tax_query[] = array(
    14541454                                'taxonomy' => $q['taxonomy'],
    1455                                 'terms' => $q['term'],
     1455                                'terms' => array( $q['term'] ),
     1456                                'field' => 'slug',
    14561457                        );
    1457                 }
    1458 
    1459                 foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
    1460                         if ( $t->query_var && !empty( $q[$t->query_var] ) ) {
    1461                                 $tax_query_defaults = array(
    1462                                         'taxonomy' => $taxonomy,
    1463                                         'field' => 'slug',
    1464                                         'operator' => 'IN'
    1465                                 );
    1466 
    1467                                 if ( $t->rewrite['hierarchical'] ) {
    1468                                         $q[$t->query_var] = basename($q[$t->query_var]);
    1469                                         if ( $taxonomy == $q['taxonomy'] )
    1470                                                 $q['term'] = basename($q['term']);
    1471                                 }
    1472 
    1473                                 $term = $q[$t->query_var];
    1474 
    1475                                 if ( strpos($term, '+') !== false ) {
    1476                                         $terms = preg_split( '/[+\s]+/', $term );
    1477                                         foreach ( $terms as $term ) {
     1458                } else {
     1459                        foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
     1460                                if ( $t->query_var && !empty( $q[$t->query_var] ) ) {
     1461                                        $tax_query_defaults = array(
     1462                                                'taxonomy' => $taxonomy,
     1463                                                'field' => 'slug',
     1464                                                'operator' => 'IN'
     1465                                        );
     1466
     1467                                        if ( $t->rewrite['hierarchical'] ) {
     1468                                                $q[$t->query_var] = basename($q[$t->query_var]);
     1469                                                if ( $taxonomy == $q['taxonomy'] )
     1470                                                        $q['term'] = basename($q['term']);
     1471                                        }
     1472
     1473                                        $term = $q[$t->query_var];
     1474
     1475                                        if ( strpos($term, '+') !== false ) {
     1476                                                $terms = preg_split( '/[+\s]+/', $term );
     1477                                                foreach ( $terms as $term ) {
     1478                                                        $tax_query[] = array_merge( $tax_query_defaults, array(
     1479                                                                'terms' => array( $term )
     1480                                                        ) );
     1481                                                }
     1482                                        } else {
    14781483                                                $tax_query[] = array_merge( $tax_query_defaults, array(
    1479                                                         'terms' => array( $term )
     1484                                                        'terms' => preg_split('/[,\s]+/', $term)
    14801485                                                ) );
    14811486                                        }
    1482                                 } else {
    1483                                         $tax_query[] = array_merge( $tax_query_defaults, array(
    1484                                                 'terms' => preg_split('/[,\s]+/', $term)
    1485                                         ) );
    14861487                                }
    14871488                        }
Note: See TracChangeset for help on using the changeset viewer.