1247 | | $s = stripslashes($_POST['ps']); |
1248 | | preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
1249 | | $search_terms = array_map('_search_terms_tidy', $matches[0]); |
| 1247 | $args = array( |
| 1248 | 'post_type' => $what, |
| 1249 | 'post_status' => array('draft', 'publish'), |
| 1250 | 's' => $_POST['ps'], |
| 1251 | 'showposts' => 50, |
| 1252 | 'cache_results' => false, |
| 1253 | ); |
1251 | | $searchand = $search = ''; |
1252 | | foreach ( (array) $search_terms as $term ) { |
1253 | | $term = addslashes_gpc($term); |
1254 | | $search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))"; |
1255 | | $searchand = ' AND '; |
1256 | | } |
1257 | | $term = $wpdb->escape($s); |
1258 | | if ( count($search_terms) > 1 && $search_terms[0] != $s ) |
1259 | | $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; |
| 1255 | $posts = get_posts( $args ); |