Anchor user search queries to the front. Limit columns searched based on what the search string looks like. see #15170

git-svn-id: http://svn.automattic.com/wordpress/trunk@16168 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
ryan
2010-11-03 19:02:42 +00:00
parent b713a76272
commit 6291fa9dc6
2 changed files with 16 additions and 3 deletions

View File

@@ -233,8 +233,12 @@ class WP_Object_Query {
$string = esc_sql( $string );
$searches = array();
foreach ( $cols as $col )
$searches[] = "$col LIKE '%$string%'";
foreach ( $cols as $col ) {
if ( 'ID' == $col )
$searches[] = "$col = '$string'";
else
$searches[] = "$col LIKE '$string%'";
}
return ' AND (' . implode(' OR ', $searches) . ')';
}