WordPress.org

Make WordPress Core

Ticket #15033: 15033.2.diff

File 15033.2.diff, 1.5 KB (added by SergeyBiryukov, 16 months ago)
  • wp-admin/includes/ajax-actions.php

     
    13711371        else 
    13721372                $what = 'post'; 
    13731373 
    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        ); 
    13771382 
    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 ); 
    13871384 
    1388         $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" ); 
    1389  
    13901385        if ( ! $posts ) { 
    13911386                $posttype = get_post_type_object($what); 
    13921387                wp_die( $posttype->labels->not_found );