Ticket #7394: basic.7394.diff
File basic.7394.diff, 1.4 KB (added by , 14 years ago) |
---|
-
wp-includes/query.php
2148 2148 preg_match_all('/".*?("|$)|((?<=[\\s",+])|^)[^\\s",+]+/', $q['s'], $matches); 2149 2149 $q['search_terms'] = array_map('_search_terms_tidy', $matches[0]); 2150 2150 } 2151 $q['search_terms'] = array_filter( (array) $q['search_terms'] ); 2152 2151 2153 $n = !empty($q['exact']) ? '' : '%'; 2152 2154 $searchand = ''; 2153 foreach ( (array)$q['search_terms'] as $term ) {2155 foreach ( $q['search_terms'] as $term ) { 2154 2156 $term = esc_sql( like_escape( $term ) ); 2155 2157 $search .= "{$searchand}(($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}'))"; 2156 2158 $searchand = ' AND '; … … 2345 2347 if ( empty($q['orderby']) ) 2346 2348 $q['orderby'] = "$wpdb->posts.post_date ".$q['order']; 2347 2349 } 2350 2351 // Order search results by relevance 2352 if ( !empty( $q['search_terms'] ) && empty( $q['exact'] ) ) { 2353 $orderby_search = array(); 2354 foreach ( $q['search_terms'] as $term ) { 2355 $term = esc_sql( like_escape( $term ) ); 2356 $orderby_search[] = "$wpdb->posts.post_title LIKE '%$term%'"; 2357 } 2358 $orderby_search = implode( ' OR ', $orderby_search ); 2348 2359 2360 $q['orderby'] = "($orderby_search) DESC, " . $q['orderby']; 2361 } 2362 2349 2363 if ( is_array( $post_type ) ) { 2350 2364 $post_type_cap = 'multiple_post_type'; 2351 2365 } else {