Make WordPress Core


Ignore:
Timestamp:
11/09/2010 04:45:51 PM (16 years ago)
Author:
scribu
Message:

Allow mix of 'taxonomy' => 'foo', 'term' => 'bar' and 'foo2' => 'bar2'. Props filosofo. Fixes #15363

File:
1 edited

Legend:

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

    r16258 r16259  
    14731473                                'operator' => 'IN',
    14741474                        );
    1475                 } else {
    1476                         foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
    1477                                 if ( $t->query_var && !empty( $q[$t->query_var] ) ) {
    1478                                         $tax_query_defaults = array(
    1479                                                 'taxonomy' => $taxonomy,
    1480                                                 'field' => 'slug',
    1481                                                 'operator' => 'IN'
    1482                                         );
    1483 
    1484                                         if ( $t->rewrite['hierarchical'] ) {
    1485                                                 $q[$t->query_var] = wp_basename( $q[$t->query_var] );
    1486                                         }
    1487 
    1488                                         $term = str_replace( ' ', '+', $q[$t->query_var] );
    1489 
    1490                                         if ( strpos($term, '+') !== false ) {
    1491                                                 $terms = preg_split( '/[+]+/', $term );
    1492                                                 foreach ( $terms as $term ) {
    1493                                                         $tax_query[] = array_merge( $tax_query_defaults, array(
    1494                                                                 'terms' => array( $term )
    1495                                                         ) );
    1496                                                 }
    1497                                         } else {
     1475                }
     1476
     1477                foreach ( $GLOBALS['wp_taxonomies'] as $taxonomy => $t ) {
     1478                        if ( $t->query_var && !empty( $q[$t->query_var] ) ) {
     1479                                $tax_query_defaults = array(
     1480                                        'taxonomy' => $taxonomy,
     1481                                        'field' => 'slug',
     1482                                        'operator' => 'IN'
     1483                                );
     1484
     1485                                if ( $t->rewrite['hierarchical'] ) {
     1486                                        $q[$t->query_var] = wp_basename( $q[$t->query_var] );
     1487                                }
     1488
     1489                                $term = str_replace( ' ', '+', $q[$t->query_var] );
     1490
     1491                                if ( strpos($term, '+') !== false ) {
     1492                                        $terms = preg_split( '/[+]+/', $term );
     1493                                        foreach ( $terms as $term ) {
    14981494                                                $tax_query[] = array_merge( $tax_query_defaults, array(
    1499                                                         'terms' => preg_split( '/[,]+/', $term )
     1495                                                        'terms' => array( $term )
    15001496                                                ) );
    15011497                                        }
     1498                                } else {
     1499                                        $tax_query[] = array_merge( $tax_query_defaults, array(
     1500                                                'terms' => preg_split( '/[,]+/', $term )
     1501                                        ) );
    15021502                                }
    15031503                        }
Note: See TracChangeset for help on using the changeset viewer.