Make WordPress Core


Ignore:
Timestamp:
11/03/2010 07:31:11 PM (15 years ago)
Author:
ryan
Message:

Allow trailing wildcard user searches by appending *. see #15170

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/class-wp-object-query.php

    r16168 r16170  
    228228     * @param string $string
    229229     * @param array $cols
     230     * @param bool $wild Whether to allow trailing wildcard searches. Default is false.
    230231     * @return string
    231232     */
    232     function get_search_sql( $string, $cols ) {
     233    function get_search_sql( $string, $cols, $wild = false ) {
    233234        $string = esc_sql( $string );
    234235
    235236        $searches = array();
     237        $wild_char = ( $wild ) ? '%' : '';
    236238        foreach ( $cols as $col ) {
    237239            if ( 'ID' == $col )
    238240                $searches[] = "$col = '$string'";
    239241            else
    240                 $searches[] = "$col LIKE '$string%'";
     242                $searches[] = "$col LIKE '$string$wild_char'";
    241243        }
    242244
Note: See TracChangeset for help on using the changeset viewer.