WordPress.org

Make WordPress Core

Ticket #3722: wp_search.diff

File wp_search.diff, 790 bytes (added by charleshooper, 7 years ago)

Single comma search "hack"

  • wp-includes/query.php

     
    765765                                $searchand = ' AND '; 
    766766                        } 
    767767                        $term = addslashes_gpc($q['s']);  
    768                         if (!$q['sentence'] && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] ) $search .= " OR (post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}')"; 
    769                          
    770                         $search = " AND ({$search}) "; 
     768                        if (!$q['sentence'] && count($q['search_terms']) > 1 && $q['search_terms'][0] != $q['s'] ) 
     769                                $search .= " OR (post_title LIKE '{$n}{$term}{$n}') OR (post_content LIKE '{$n}{$term}{$n}')"; 
     770 
     771                        if ( !empty($search) ) 
     772                                $search = " AND ({$search}) "; 
    771773                } 
    772774 
    773775                // Category stuff