Set a variable for like-escaped string before looping in WP_User_Query::get_search_sql().

Props miqrogroove.
Fixes #10041.

Built from https://develop.svn.wordpress.org/trunk@28722


git-svn-id: http://core.svn.wordpress.org/trunk@28536 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Scott Taylor 2014-06-10 02:45:16 +00:00
parent f8b03aa528
commit 6a61826660

View File

@ -802,11 +802,14 @@ class WP_User_Query {
$searches = array();
$leading_wild = ( 'leading' == $wild || 'both' == $wild ) ? '%' : '';
$trailing_wild = ( 'trailing' == $wild || 'both' == $wild ) ? '%' : '';
$like = $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild;
foreach ( $cols as $col ) {
if ( 'ID' == $col )
if ( 'ID' == $col ) {
$searches[] = $wpdb->prepare( "$col = %s", $string );
else
$searches[] = $wpdb->prepare( "$col LIKE %s", $leading_wild . $wpdb->esc_like( $string ) . $trailing_wild );
} else {
$searches[] = $wpdb->prepare( "$col LIKE %s", $like );
}
}
return ' AND (' . implode(' OR ', $searches) . ')';