WP_Comment_Query::get_search_sql() WordPress Method
The WP_Comment_Query::get_search_sql() method is used to generate the SQL code that will be used to search for comments based on the specified search terms. This is useful for plugins that want to search through comments for specific data.
WP_Comment_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-comment-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 ' AND (' . implode( ' OR ', $searches ) . ')'; }
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
3.1.0 | Introduced. |