Ticket #16157: 16157.2.diff
| File 16157.2.diff, 3.6 KB (added by ryan, 2 years ago) |
|---|
-
wp-includes/taxonomy.php
671 671 $join .= " ON ($primary_table.$primary_id_column = $alias.object_id)"; 672 672 673 673 $where[] = "$alias.term_taxonomy_id $operator ($terms)"; 674 } 675 elseif ( 'NOT IN' == $operator ) { 674 } elseif ( 'NOT IN' == $operator ) { 676 675 677 676 if ( empty( $terms ) ) 678 677 continue; … … 684 683 FROM $wpdb->term_relationships 685 684 WHERE term_taxonomy_id IN ($terms) 686 685 )"; 686 } elseif ( 'AND' == $operator ) { 687 688 if ( empty( $terms ) ) 689 continue; 690 691 $num_terms = count( $terms ); 692 693 $terms = implode( ',', $terms ); 694 695 $where[] = "$primary_table.$primary_id_column IN ( 696 SELECT object_id 697 FROM $wpdb->term_relationships 698 WHERE term_taxonomy_id IN ($terms) 699 GROUP BY object_id HAVING COUNT(object_id) = $num_terms 700 )"; 687 701 } 688 702 689 703 $i++; -
wp-includes/query.php
1692 1692 } 1693 1693 1694 1694 if ( !empty($q['category__in']) ) { 1695 $q['category__in'] = array_ unique( $q['category__in']);1695 $q['category__in'] = array_map('absint', array_unique( $q['category__in'] ) ); 1696 1696 $tax_query[] = array( 1697 1697 'taxonomy' => 'category', 1698 1698 'terms' => $q['category__in'], … … 1701 1701 } 1702 1702 1703 1703 if ( !empty($q['category__not_in']) ) { 1704 $q['category__not_in'] = array_ unique( $q['category__not_in']);1704 $q['category__not_in'] = array_map('absint', array_unique( $q['category__not_in'] ) ); 1705 1705 $tax_query[] = array( 1706 1706 'taxonomy' => 'category', 1707 1707 'terms' => $q['category__not_in'], 1708 'operator' => 'NOT IN' ,1708 'operator' => 'NOT IN' 1709 1709 ); 1710 1710 } 1711 1711 1712 if ( !empty($q['category__and']) ) { 1713 $q['category__and'] = array_map('absint', array_unique( $q['category__and'] ) ); 1714 $tax_query[] = array( 1715 'taxonomy' => 'category', 1716 'terms' => $q['category__and'], 1717 'field' => 'term_id', 1718 'operator' => 'AND' 1719 ); 1720 } 1721 1712 1722 // Tag stuff 1713 1723 if ( !empty($q['tag_id']) ) { 1724 $q['tag_id'] = absint( $q['tag_id'] ); 1714 1725 $tax_query[] = array( 1715 1726 'taxonomy' => 'post_tag', 1716 'terms' => $q['tag_id'] ,1727 'terms' => $q['tag_id'] 1717 1728 ); 1718 1729 } 1719 1730 1720 1731 if ( !empty($q['tag__in']) ) { 1732 $q['tag__in'] = array_map('absint', array_unique( $q['tag__in'] ) ); 1721 1733 $tax_query[] = array( 1722 1734 'taxonomy' => 'post_tag', 1723 'terms' => $q['tag__in'] ,1735 'terms' => $q['tag__in'] 1724 1736 ); 1725 1737 } 1726 1738 1727 1739 if ( !empty($q['tag__not_in']) ) { 1740 $q['tag__not_in'] = array_map('absint', array_unique( $q['tag__not_in'] ) ); 1728 1741 $tax_query[] = array( 1729 1742 'taxonomy' => 'post_tag', 1730 1743 'terms' => $q['tag__not_in'], 1731 'operator' => 'NOT IN' ,1744 'operator' => 'NOT IN' 1732 1745 ); 1733 1746 } 1734 1747 1748 if ( !empty($q['tag__and']) ) { 1749 $q['tag__and'] = array_map('absint', array_unique( $q['tag__and'] ) ); 1750 $tax_query[] = array( 1751 'taxonomy' => 'post_tag', 1752 'terms' => $q['tag__and'], 1753 'operator' => 'AND' 1754 ); 1755 } 1756 1757 if ( !empty($q['tag_slug__in']) ) { 1758 $q['tag_slug__in'] = array_map('sanitize_title', $q['tag_slug__in']); 1759 $tax_query[] = array( 1760 'taxonomy' => 'post_tag', 1761 'terms' => $q['tag_slug__in'], 1762 'field' => 'slug' 1763 ); 1764 } 1765 1766 if ( !empty($q['tag_slug__and']) ) { 1767 $q['tag_slug__and'] = array_map('sanitize_title', $q['tag_slug__and']); 1768 $tax_query[] = array( 1769 'taxonomy' => 'post_tag', 1770 'terms' => $q['tag_slug__and'], 1771 'field' => 'slug', 1772 'operator' => 'AND' 1773 ); 1774 } 1775 1735 1776 $this->tax_query = new WP_Tax_Query( $tax_query ); 1736 1777 } 1737 1778