Ticket #15752: 15752.diff
File 15752.diff, 3.4 KB (added by , 14 years ago) |
---|
-
wp-includes/taxonomy.php
533 533 $where = array(); 534 534 $i = 0; 535 535 536 if ( isset( $tax_query['relation'] ) && strtoupper( $tax_query['relation'] ) == 'OR' ) { 536 _set_tax_query_defaults( $tax_query ); 537 538 if ( strtoupper( $tax_query['relation'] ) == 'OR' ) { 537 539 $relation = 'OR'; 538 540 } else { 539 541 $relation = 'AND'; … … 543 545 if ( ! is_array( $query ) ) 544 546 continue; 545 547 546 extract( wp_parse_args( $query, array( 547 'taxonomy' => array(), 548 'terms' => array(), 549 'include_children' => true, 550 'field' => 'term_id', 551 'operator' => 'IN', 552 ) ) ); 548 extract( $query ); 553 549 554 550 $taxonomies = (array) $taxonomy; 555 551 … … 625 621 return compact( 'join', 'where' ); 626 622 } 627 623 624 function _set_tax_query_defaults( &$tax_query ) { 625 if ( ! isset( $tax_query['relation'] ) ) 626 $tax_query['relation'] = 'AND'; 627 628 $defaults = array( 629 'taxonomy' => array(), 630 'terms' => array(), 631 'include_children' => true, 632 'field' => 'term_id', 633 'operator' => 'IN', 634 ); 635 636 foreach ( $tax_query as $i => $query ) { 637 if ( ! is_array( $query ) ) 638 continue; 639 640 $tax_query[$i] = array_merge( $defaults, $query ); 641 642 $tax_query[$i]['terms'] = (array) $tax_query[$i]['terms']; 643 } 644 } 645 628 646 function _transform_terms( &$terms, $taxonomies, $field, $resulting_field ) { 629 647 global $wpdb; 630 648 -
wp-includes/query.php
1491 1491 'taxonomy' => $q['taxonomy'], 1492 1492 'terms' => array( $q['term'] ), 1493 1493 'field' => 'slug', 1494 'operator' => 'IN',1495 1494 ); 1496 1495 } 1497 1496 … … 1500 1499 $tax_query_defaults = array( 1501 1500 'taxonomy' => $taxonomy, 1502 1501 'field' => 'slug', 1503 'operator' => 'IN'1504 1502 ); 1505 1503 1506 1504 if ( isset( $t->rewrite['hierarchical'] ) && $t->rewrite['hierarchical'] ) { … … 1550 1548 $tax_query[] = array( 1551 1549 'taxonomy' => 'category', 1552 1550 'terms' => $q['category__in'], 1553 'operator' => 'IN',1554 1551 'field' => 'term_id' 1555 1552 ); 1556 1553 } … … 1561 1558 'taxonomy' => 'category', 1562 1559 'terms' => $q['category__not_in'], 1563 1560 'operator' => 'NOT IN', 1564 'field' => 'term_id'1565 1561 ); 1566 1562 } 1567 1563 … … 1570 1566 $tax_query[] = array( 1571 1567 'taxonomy' => 'post_tag', 1572 1568 'terms' => $qv['tag_id'], 1573 'operator' => 'IN',1574 'field' => 'term_id'1575 1569 ); 1576 1570 } 1577 1571 … … 1579 1573 $tax_query[] = array( 1580 1574 'taxonomy' => 'post_tag', 1581 1575 'terms' => $q['tag__in'], 1582 'operator' => 'IN',1583 'field' => 'term_id'1584 1576 ); 1585 1577 } 1586 1578 … … 1589 1581 'taxonomy' => 'post_tag', 1590 1582 'terms' => $q['tag__not_in'], 1591 1583 'operator' => 'NOT IN', 1592 'field' => 'term_id'1593 1584 ); 1594 1585 } 1595 1586 1587 _set_tax_query_defaults( $tax_query ); 1588 1596 1589 foreach ( $tax_query as $query ) { 1590 if ( ! is_array( $query ) ) 1591 continue; 1592 1597 1593 if ( 'IN' == $query['operator'] ) { 1598 1594 switch ( $query['taxonomy'] ) { 1599 1595 case 'category': … … 1945 1941 // Taxonomies 1946 1942 if ( !$this->is_singular ) { 1947 1943 $this->tax_query = $this->parse_tax_query( $q ); 1948 if ( !empty( $this->tax_query ) ) { 1944 1945 if ( ! empty( $this->tax_query ) ) { 1949 1946 $clauses = call_user_func_array( 'get_tax_sql', array( $this->tax_query, $wpdb->posts, 'ID', &$this) ); 1950 1947 1951 1948 $join .= $clauses['join'];