Make WordPress Core

Ticket #15033: 15033.diff

File 15033.diff, 1.4 KB (added by scribu, 14 years ago)
  • wp-admin/admin-ajax.php

     
    12441244        else
    12451245                $what = 'post';
    12461246
    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        );
    12501254
    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 );
    12601256
    1261         $posts = $wpdb->get_results( "SELECT ID, post_title, post_status, post_date FROM $wpdb->posts WHERE post_type = '$what' AND post_status IN ('draft', 'publish') AND ($search) ORDER BY post_date_gmt DESC LIMIT 50" );
    1262 
    12631257        if ( ! $posts ) {
    12641258                $posttype = get_post_type_object($what);
    12651259                exit($posttype->labels->not_found);