WP_Network_Query::get_search_sql() WordPress Method
The WP_Network_Query::get_search_sql() method is used to generate the SQL code for searching a WordPress network. This is a powerful method that can be used to search for networks by name, description, or other criteria.
WP_Network_Query::get_search_sql( string $search, string[] $columns ) #
Used internally to generate an SQL string for searching across multiple columns.
Parameters
- $search
(string)(Required)Search string.
- $columns
(string[])(Required)Array of columns to search.
Return
(string) Search SQL.
Source
File: wp-includes/class-wp-network-query.php
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 ) . ')'; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.6.0 | Introduced. |