Docs: Add missing documentation for WP_*_Query::get_search_sql() method parameters.

Includes renaming the `$cols` parameter to `$columns` for consistency across the classes.

Follow-up to [42876], [53272-53276].

See #54729.
Built from https://develop.svn.wordpress.org/trunk@53280


git-svn-id: http://core.svn.wordpress.org/trunk@52869 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
Sergey Biryukov 2022-04-26 14:04:10 +00:00
parent 5ac4bf5ec6
commit 69be4c73ff
4 changed files with 19 additions and 19 deletions

View File

@ -1126,24 +1126,24 @@ class WP_Comment_Query {
} }
/** /**
* Used internally to generate an SQL string for searching across multiple columns * Used internally to generate an SQL string for searching across multiple columns.
* *
* @since 3.1.0 * @since 3.1.0
* *
* @global wpdb $wpdb WordPress database abstraction object. * @global wpdb $wpdb WordPress database abstraction object.
* *
* @param string $search * @param string $search Search string.
* @param array $cols * @param string[] $columns Array of columns to search.
* @return string * @return string Search SQL.
*/ */
protected function get_search_sql( $search, $cols ) { protected function get_search_sql( $search, $columns ) {
global $wpdb; global $wpdb;
$like = '%' . $wpdb->esc_like( $search ) . '%'; $like = '%' . $wpdb->esc_like( $search ) . '%';
$searches = array(); $searches = array();
foreach ( $cols as $col ) { foreach ( $columns as $column ) {
$searches[] = $wpdb->prepare( "$col LIKE %s", $like ); $searches[] = $wpdb->prepare( "$column LIKE %s", $like );
} }
return ' AND (' . implode( ' OR ', $searches ) . ')'; return ' AND (' . implode( ' OR ', $searches ) . ')';

View File

@ -1068,8 +1068,8 @@ class WP_Term_Query {
* *
* @global wpdb $wpdb WordPress database abstraction object. * @global wpdb $wpdb WordPress database abstraction object.
* *
* @param string $search * @param string $search Search string.
* @return string * @return string Search SQL.
*/ */
protected function get_search_sql( $search ) { protected function get_search_sql( $search ) {
global $wpdb; global $wpdb;

View File

@ -868,13 +868,13 @@ class WP_User_Query {
* *
* @global wpdb $wpdb WordPress database abstraction object. * @global wpdb $wpdb WordPress database abstraction object.
* *
* @param string $search * @param string $search Search string.
* @param array $cols * @param string[] $columns Array of columns to search.
* @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for single site. * @param bool $wild Whether to allow wildcard searches. Default is false for Network Admin, true for single site.
* Single site allows leading and trailing wildcards, Network Admin only trailing. * Single site allows leading and trailing wildcards, Network Admin only trailing.
* @return string * @return string
*/ */
protected function get_search_sql( $search, $cols, $wild = false ) { protected function get_search_sql( $search, $columns, $wild = false ) {
global $wpdb; global $wpdb;
$searches = array(); $searches = array();
@ -882,11 +882,11 @@ class WP_User_Query {
$trailing_wild = ( 'trailing' === $wild || 'both' === $wild ) ? '%' : ''; $trailing_wild = ( 'trailing' === $wild || 'both' === $wild ) ? '%' : '';
$like = $leading_wild . $wpdb->esc_like( $search ) . $trailing_wild; $like = $leading_wild . $wpdb->esc_like( $search ) . $trailing_wild;
foreach ( $cols as $col ) { foreach ( $columns as $column ) {
if ( 'ID' === $col ) { if ( 'ID' === $column ) {
$searches[] = $wpdb->prepare( "$col = %s", $search ); $searches[] = $wpdb->prepare( "$column = %s", $search );
} else { } else {
$searches[] = $wpdb->prepare( "$col LIKE %s", $like ); $searches[] = $wpdb->prepare( "$column LIKE %s", $like );
} }
} }

View File

@ -16,7 +16,7 @@
* *
* @global string $wp_version * @global string $wp_version
*/ */
$wp_version = '6.0-beta2-53279'; $wp_version = '6.0-beta2-53280';
/** /**
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema. * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.