Used internally to generate an SQL string for searching across multiple columns.
Parameters
$search
stringrequired- Search string.
$columns
string[]required- Array of columns to search.
Source
protected function get_search_sql( $search, $columns ) {
global $wpdb;
$like = '%' . $wpdb->esc_like( $search ) . '%';
$searches = array();
foreach ( $columns as $column ) {
$searches[] = $wpdb->prepare( "$column LIKE %s", $like );
}
return '(' . implode( ' OR ', $searches ) . ')';
}
Changelog
Version | Description |
---|---|
4.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.