Ticket #33988: 33988.patch
| File 33988.patch, 2.0 KB (added by , 11 years ago) |
|---|
-
wp-includes/query.php
2128 2128 $searchand = ''; 2129 2129 $q['search_orderby_title'] = array(); 2130 2130 foreach ( $q['search_terms'] as $term ) { 2131 $searchoperator = 'OR'; 2132 $searchnotlike = ''; 2133 $term_should_be_included = true; 2134 // Terms that start with dashes are to be excluded from results. 2135 if ( '-' == substr( $term, 0, 1 ) ) { 2136 $term_should_be_included = false; 2137 $term = substr( $term, 1 ); 2138 $searchoperator = 'AND'; 2139 $searchnotlike = 'NOT '; 2140 } 2141 2131 2142 if ( $n ) { 2132 2143 $like = '%' . $wpdb->esc_like( $term ) . '%'; 2133 $q['search_orderby_title'][] = $wpdb->prepare( "$wpdb->posts.post_title LIKE %s", $like ); 2144 if ( $term_should_be_included ) { 2145 $q['search_orderby_title'][] = $wpdb->prepare( "$wpdb->posts.post_title LIKE %s", $like ); 2146 } 2134 2147 } 2135 2148 2136 2149 $like = $n . $wpdb->esc_like( $term ) . $n; 2137 $search .= $wpdb->prepare( "{$searchand}(($wpdb->posts.post_title LIKE %s) OR ($wpdb->posts.post_contentLIKE %s))", $like, $like );2150 $search .= $wpdb->prepare( "{$searchand}(($wpdb->posts.post_title {$searchnotlike}LIKE %s) {$searchoperator} ($wpdb->posts.post_content {$searchnotlike}LIKE %s))", $like, $like ); 2138 2151 $searchand = ' AND '; 2139 2152 } 2140 2153 … … 2234 2247 2235 2248 if ( $q['search_terms_count'] > 1 ) { 2236 2249 $num_terms = count( $q['search_orderby_title'] ); 2237 $like = '%' . $wpdb->esc_like( $q['s'] ) . '%';2238 2250 2251 // Filter out negative search terms 2252 $included_search_terms = array(); 2253 foreach ( $q['search_terms'] as $term ) { 2254 if ( 0 !== strpos( $term, '-' ) ) { 2255 $included_search_terms[] = $term; 2256 } 2257 } 2258 $included_search = implode( ' ', $included_search_terms ); 2259 2260 $like = '%' . $wpdb->esc_like( $included_search ) . '%'; 2261 2239 2262 $search_orderby = '(CASE '; 2240 2263 // sentence match in 'post_title' 2241 2264 $search_orderby .= $wpdb->prepare( "WHEN $wpdb->posts.post_title LIKE %s THEN 1 ", $like );
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)