Make WordPress Core

Ticket #16014: 16014.diff

File 16014.diff, 1.7 KB (added by nacin, 13 years ago)
  • wp-includes/user.php

     
    465465
    466466                $search = trim( $qv['search'] );
    467467                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 {
    470475                                $wild = true;
    471                                 $search = trim($search, '*');
    472476                        }
    473477                        if ( false !== strpos( $search, '@') )
    474478                                $search_columns = array('user_email');
     
    564568         *
    565569         * @param string $string
    566570         * @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.
    568573         * @return string
    569574         */
    570         function get_search_sql( $string, $cols, $wild = false ) {
     575        function get_search_sql( $string, $cols, $wild = null ) {
    571576                $string = esc_sql( $string );
    572577
    573578                $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() ? '%' : '';
    575584                foreach ( $cols as $col ) {
    576585                        if ( 'ID' == $col )
    577586                                $searches[] = "$col = '$string'";
    578587                        else
    579                                 $searches[] = "$col LIKE '" . like_escape($string) . "$wild_char'";
     588                                $searches[] = "$col LIKE '$leading_wild" . like_escape($string) . "$trailing_wild'";
    580589                }
    581590
    582591                return ' AND (' . implode(' OR ', $searches) . ')';