Changeset 26090
- Timestamp:
- 11/11/2013 06:35:21 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/query.php
r26081 r26090 1768 1768 1769 1769 // Category stuff 1770 if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular && $this->query_vars_changed ) { 1771 $q['cat'] = ''.urldecode($q['cat']).''; 1772 $q['cat'] = addslashes_gpc($q['cat']); 1773 $cat_array = preg_split('/[,\s]+/', $q['cat']); 1774 $q['cat'] = ''; 1775 $req_cats = array(); 1776 foreach ( (array) $cat_array as $cat ) { 1777 $cat = intval($cat); 1778 $req_cats[] = $cat; 1779 $in = ($cat > 0); 1780 $cat = abs($cat); 1781 if ( $in ) { 1782 $q['category__in'][] = $cat; 1783 $q['category__in'] = array_merge( $q['category__in'], get_term_children($cat, 'category') ); 1784 } else { 1785 $q['category__not_in'][] = $cat; 1786 $q['category__not_in'] = array_merge( $q['category__not_in'], get_term_children($cat, 'category') ); 1787 } 1788 } 1789 $q['cat'] = implode(',', $req_cats); 1770 if ( ! empty( $q['cat'] ) && ! $this->is_singular ) { 1771 $cat_in = $cat_not_in = array(); 1772 1773 $cat_array = preg_split( '/[,\s]+/', urldecode( $q['cat'] ) ); 1774 $cat_array = array_map( 'intval', $cat_array ); 1775 $q['cat'] = implode( ',', $cat_array ); 1776 1777 foreach ( $cat_array as $cat ) { 1778 if ( $cat > 0 ) 1779 $cat_in[] = $cat; 1780 elseif ( $cat < 0 ) 1781 $cat_not_in[] = abs( $cat ); 1782 } 1783 1784 if ( ! empty( $cat_in ) ) { 1785 $tax_query[] = array( 1786 'taxonomy' => 'category', 1787 'terms' => $cat_in, 1788 'field' => 'term_id', 1789 'include_children' => true 1790 ); 1791 } 1792 1793 if ( ! empty( $cat_not_in ) ) { 1794 $tax_query[] = array( 1795 'taxonomy' => 'category', 1796 'terms' => $cat_not_in, 1797 'field' => 'term_id', 1798 'operator' => 'NOT IN', 1799 'include_children' => true 1800 ); 1801 } 1802 unset( $cat_array, $cat_in, $cat_not_in ); 1790 1803 } 1791 1804
Note: See TracChangeset
for help on using the changeset viewer.