WP_Site_Query::get_search_sql( string $string, string[] $columns )
Used internally to generate an SQL string for searching across multiple columns.
Description Description
Parameters Parameters
- $string
-
(string) (Required) Search string.
- $columns
-
(string[]) (Required) Array of columns to search.
Return Return
(string) Search SQL.
Source Source
File: wp-includes/class-wp-site-query.php
protected function get_search_sql( $string, $columns ) { global $wpdb; if ( false !== strpos( $string, '*' ) ) { $like = '%' . implode( '%', array_map( array( $wpdb, 'esc_like' ), explode( '*', $string ) ) ) . '%'; } else { $like = '%' . $wpdb->esc_like( $string ) . '%'; } $searches = array(); foreach ( $columns as $column ) { $searches[] = $wpdb->prepare( "$column LIKE %s", $like ); } return '(' . implode( ' OR ', $searches ) . ')'; }
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
4.6.0 | Introduced. |