Ticket #16014: 16014.diff
File 16014.diff, 1.7 KB (added by , 13 years ago) |
---|
-
wp-includes/user.php
465 465 466 466 $search = trim( $qv['search'] ); 467 467 if ( $search ) { 468 $wild = false; 469 if ( false !== strpos($search, '*') ) { 468 if ( is_multisite() ) { 469 $wild = false; 470 if ( false !== strpos($search, '*') ) { 471 $wild = true; 472 $search = trim($search, '*'); 473 } 474 } else { 470 475 $wild = true; 471 $search = trim($search, '*');472 476 } 473 477 if ( false !== strpos( $search, '@') ) 474 478 $search_columns = array('user_email'); … … 564 568 * 565 569 * @param string $string 566 570 * @param array $cols 567 * @param bool $wild Whether to allow trailing wildcard searches. Default is false. 571 * @param bool $wild Whether to allow wildcard searches. Default is false for multisite, true for 572 * single site. Single site allows leading and trailing wildcards, multisite only trailing. 568 573 * @return string 569 574 */ 570 function get_search_sql( $string, $cols, $wild = false) {575 function get_search_sql( $string, $cols, $wild = null ) { 571 576 $string = esc_sql( $string ); 572 577 573 578 $searches = array(); 574 $wild_char = ( $wild ) ? '%' : ''; 579 if ( null === $wild ) 580 $wild = ! is_multisite(); 581 582 $trailing_wild = ( $wild ) ? '%' : ''; 583 $leading_wild = $wild && ! is_multisite() ? '%' : ''; 575 584 foreach ( $cols as $col ) { 576 585 if ( 'ID' == $col ) 577 586 $searches[] = "$col = '$string'"; 578 587 else 579 $searches[] = "$col LIKE ' " . like_escape($string) . "$wild_char'";588 $searches[] = "$col LIKE '$leading_wild" . like_escape($string) . "$trailing_wild'"; 580 589 } 581 590 582 591 return ' AND (' . implode(' OR ', $searches) . ')';