1263 | | $s = stripslashes($_POST['ps']); |
1264 | | preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
1265 | | $search_terms = array_map('_search_terms_tidy', $matches[0]); |
| 1263 | $args = array( |
| 1264 | 'post_type' => $what, |
| 1265 | 'post_status' => array('draft', 'publish'), |
| 1266 | 's' => $_POST['ps'], |
| 1267 | 'showposts' => 50, |
| 1268 | 'cache_results' => false, |
| 1269 | 'suppress_filters' => false, |
| 1270 | ); |
1267 | | $searchand = $search = ''; |
1268 | | foreach ( (array) $search_terms as $term ) { |
1269 | | $term = esc_sql( like_escape( $term ) ); |
1270 | | $search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))"; |
1271 | | $searchand = ' AND '; |
1272 | | } |
1273 | | $term = esc_sql( like_escape( $s ) ); |
1274 | | if ( count($search_terms) > 1 && $search_terms[0] != $s ) |
1275 | | $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; |
| 1272 | $posts = get_posts( $args ); |