1733 | | if ( !empty($q['cat']) && '0' != $q['cat'] && !$this->is_singular && $this->query_vars_changed ) { |
1734 | | $q['cat'] = ''.urldecode($q['cat']).''; |
1735 | | $q['cat'] = addslashes_gpc($q['cat']); |
1736 | | $cat_array = preg_split('/[,\s]+/', $q['cat']); |
1737 | | $q['cat'] = ''; |
1738 | | $req_cats = array(); |
1739 | | foreach ( (array) $cat_array as $cat ) { |
1740 | | $cat = intval($cat); |
1741 | | $req_cats[] = $cat; |
1742 | | $in = ($cat > 0); |
1743 | | $cat = abs($cat); |
1744 | | if ( $in ) { |
1745 | | $q['category__in'][] = $cat; |
1746 | | $q['category__in'] = array_merge( $q['category__in'], get_term_children($cat, 'category') ); |
1747 | | } else { |
1748 | | $q['category__not_in'][] = $cat; |
1749 | | $q['category__not_in'] = array_merge( $q['category__not_in'], get_term_children($cat, 'category') ); |
1750 | | } |
| 1733 | if ( !empty($q['cat']) && !$this->is_singular ) { |
| 1734 | $cat_in = $cat_not_in = array(); |
| 1735 | |
| 1736 | $cat_array = preg_split('/[,\s]+/', urldecode($q['cat']) ); |
| 1737 | $cat_array = array_map('intval', $cat_array); |
| 1738 | $q['cat'] = implode(',', $cat_array); |
| 1739 | |
| 1740 | foreach ( $cat_array as $cat ) { |
| 1741 | if ( $cat > 0 ) |
| 1742 | $cat_in[] = $cat; |
| 1743 | elseif ( $cat < 0 ) |
| 1744 | $cat_not_in[] = abs($cat); |
1752 | | $q['cat'] = implode(',', $req_cats); |
| 1746 | |
| 1747 | if ( !empty($cat_in) ) { |
| 1748 | $tax_query[] = array( |
| 1749 | 'taxonomy' => 'category', |
| 1750 | 'terms' => $cat_in, |
| 1751 | 'field' => 'term_id', |
| 1752 | 'include_children' => true |
| 1753 | ); |
| 1754 | } |
| 1755 | |
| 1756 | if ( !empty($cat_not_in) ) { |
| 1757 | $tax_query[] = array( |
| 1758 | 'taxonomy' => 'category', |
| 1759 | 'terms' => $cat_not_in, |
| 1760 | 'field' => 'term_id', |
| 1761 | 'operator' => 'NOT IN', |
| 1762 | 'include_children' => true |
| 1763 | ); |
| 1764 | } |
| 1765 | unset($cat_array, $cat_in, $cat_not_in); |