From 5b1a91e0c3dbddb91fcdf935ed1eaad1c301ec17 Mon Sep 17 00:00:00 2001 From: Ryan Boren Date: Sat, 22 Dec 2007 08:19:10 +0000 Subject: [PATCH] Throw pages into search queries. Let's see how they handle. see #5149 git-svn-id: https://develop.svn.wordpress.org/trunk@6467 602fd350-edb4-49c9-b593-d223f7449a82 --- wp-includes/query.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/wp-includes/query.php b/wp-includes/query.php index 4edbfa05a1..3cf87c50bc 100644 --- a/wp-includes/query.php +++ b/wp-includes/query.php @@ -749,8 +749,12 @@ class WP_Query { $search = ''; $groupby = ''; - if ( !isset($q['post_type']) ) - $q['post_type'] = 'post'; + if ( !isset($q['post_type']) ) { + if ( $this->is_search ) + $q['post_type'] = 'any'; + else + $q['post_type'] = 'post'; + } $post_type = $q['post_type']; if ( !isset($q['posts_per_page']) || $q['posts_per_page'] == 0 ) $q['posts_per_page'] = get_option('posts_per_page'); @@ -885,8 +889,7 @@ class WP_Query { $q['s'] = stripslashes($q['s']); if ($q['sentence']) { $q['search_terms'] = array($q['s']); - } - else { + } else { preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q[s], $matches); $q['search_terms'] = array_map(create_function('$a', 'return trim($a, "\\"\'\\n\\r ");'), $matches[0]); } @@ -897,7 +900,7 @@ class WP_Query { $search .= "{$searchand}((post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}'))"; $searchand = ' AND '; } - $term = addslashes_gpc($q['s']); + $term = $wpdb->escape($q['s']); if (!$q['sentence'] && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] ) $search .= " OR (post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}')"; @@ -1145,6 +1148,8 @@ class WP_Query { $where .= " AND post_type = 'page'"; } elseif ($this->is_single) { $where .= " AND post_type = 'post'"; + } elseif ( 'any' == $post_type ) { + $where .= ''; } else { $where .= " AND post_type = '$post_type'"; }