Changeset 16555 for trunk/wp-includes/taxonomy.php
- Timestamp:
- 11/23/2010 08:22:27 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/taxonomy.php
r16535 r16555 525 525 526 526 $join = ''; 527 $where = '';527 $where = array(); 528 528 $i = 0; 529 530 if ( isset( $tax_query['relation'] ) && strtoupper( $tax_query['relation'] ) == 'OR' ) { 531 $relation = 'OR'; 532 } else { 533 $relation = 'AND'; 534 } 535 529 536 foreach ( $tax_query as $query ) { 537 if ( ! is_array( $query ) ) 538 continue; 539 530 540 extract( wp_parse_args( $query, array( 531 541 'taxonomy' => array(), … … 567 577 568 578 if ( 'IN' == $operator ) { 569 if ( empty( $terms ) ) 570 return array( 'join' => '', 'where' => ' AND 0 = 1'); 579 580 if ( empty( $terms ) ) { 581 if ( 'OR' == $relation ) 582 continue; 583 else 584 return array( 'join' => '', 'where' => ' AND 0 = 1' ); 585 } 571 586 572 587 $terms = implode( ',', $terms ); … … 578 593 $join .= " ON ($primary_table.$primary_id_column = $alias.object_id)"; 579 594 580 $where .= " AND $alias.term_taxonomy_id $operator ($terms)"; 581 582 $i++; 595 $where[] = "$alias.term_taxonomy_id $operator ($terms)"; 583 596 } 584 597 elseif ( 'NOT IN' == $operator ) { 598 585 599 if ( empty( $terms ) ) 586 600 continue; … … 588 602 $terms = implode( ',', $terms ); 589 603 590 $where .= " AND$primary_table.$primary_id_column NOT IN (591 SELECT object_id 592 FROM $wpdb->term_relationships 604 $where[] = "$primary_table.$primary_id_column NOT IN ( 605 SELECT object_id 606 FROM $wpdb->term_relationships 593 607 WHERE term_taxonomy_id IN ($terms) 594 608 )"; 595 609 } 596 } 610 611 $i++; 612 } 613 614 if ( !empty( $where ) ) 615 $where = ' AND ( ' . implode( " $relation ", $where ) . ' )'; 616 else 617 $where = ''; 597 618 598 619 return compact( 'join', 'where' );
Note: See TracChangeset
for help on using the changeset viewer.