| 1374 | | $s = stripslashes($_POST['ps']); |
| 1375 | | preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $s, $matches); |
| 1376 | | $search_terms = array_map('_search_terms_tidy', $matches[0]); |
| | 1374 | $args = array( |
| | 1375 | 'post_type' => $what, |
| | 1376 | 'post_status' => array( 'draft', 'publish' ), |
| | 1377 | 's' => $_POST['ps'], |
| | 1378 | 'showposts' => 50, |
| | 1379 | 'cache_results' => false, |
| | 1380 | 'suppress_filters' => false, |
| | 1381 | ); |
| 1378 | | $searchand = $search = ''; |
| 1379 | | foreach ( (array) $search_terms as $term ) { |
| 1380 | | $term = esc_sql( like_escape( $term ) ); |
| 1381 | | $search .= "{$searchand}(($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%'))"; |
| 1382 | | $searchand = ' AND '; |
| 1383 | | } |
| 1384 | | $term = esc_sql( like_escape( $s ) ); |
| 1385 | | if ( count($search_terms) > 1 && $search_terms[0] != $s ) |
| 1386 | | $search .= " OR ($wpdb->posts.post_title LIKE '%{$term}%') OR ($wpdb->posts.post_content LIKE '%{$term}%')"; |
| | 1383 | $posts = get_posts( $args ); |