Allow category and date filtering to coincide. Allow any number of spaces or commas to serve as item separators in the category and author arrays. http://mosquito.wordpress.org/view.php?id=221

git-svn-id: http://svn.automattic.com/wordpress/trunk@2295 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
rboren 2005-02-13 17:52:58 +00:00
parent 58990c99cc
commit 8ee644d067
1 changed files with 3 additions and 7 deletions

View File

@ -353,11 +353,7 @@ class WP_Query {
if ((empty($q['cat'])) || ($q['cat'] == '0') || if ((empty($q['cat'])) || ($q['cat'] == '0') ||
// Bypass cat checks if fetching specific posts // Bypass cat checks if fetching specific posts
( ( is_single() || is_page() )) {
intval($q['year']) || intval($q['monthnum']) || intval($q['day']) || intval($q['w']) ||
intval($q['p']) || !empty($q['name']) || !empty($q['s'])
)
) {
$whichcat=''; $whichcat='';
} else { } else {
$q['cat'] = ''.urldecode($q['cat']).''; $q['cat'] = ''.urldecode($q['cat']).'';
@ -375,7 +371,7 @@ class WP_Query {
$andor = 'OR'; $andor = 'OR';
} }
$join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) "; $join = " LEFT JOIN $wpdb->post2cat ON ($wpdb->posts.ID = $wpdb->post2cat.post_id) ";
$cat_array = explode(' ',$q['cat']); $cat_array = preg_split('/[,\s]+/', $q['cat']);
$whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]); $whichcat .= ' AND (category_id '.$eq.' '.intval($cat_array[0]);
$whichcat .= get_category_children($cat_array[0], ' '.$andor.' category_id '.$eq.' '); $whichcat .= get_category_children($cat_array[0], ' '.$andor.' category_id '.$eq.' ');
for ($i = 1; $i < (count($cat_array)); $i = $i + 1) { for ($i = 1; $i < (count($cat_array)); $i = $i + 1) {
@ -424,7 +420,7 @@ class WP_Query {
$eq = '='; $eq = '=';
$andor = 'OR'; $andor = 'OR';
} }
$author_array = explode(' ', $q['author']); $author_array = preg_split('/[,\s]+/', $q['author']);
$whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]); $whichauthor .= ' AND (post_author '.$eq.' '.intval($author_array[0]);
for ($i = 1; $i < (count($author_array)); $i = $i + 1) { for ($i = 1; $i < (count($author_array)); $i = $i + 1) {
$whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]); $whichauthor .= ' '.$andor.' post_author '.$eq.' '.intval($author_array[$i]);