WP_Network_Query::get_search_sql( string $string, array $columns )

Used internally to generate an SQL string for searching across multiple columns.


Parameters

$string

(Required) Search string.

$columns

(Required) Columns to search.


Return

(string) Search SQL.


Source

File: wp-includes/class-wp-network-query.php

	protected function get_search_sql( $string, $columns ) {
		global $wpdb;

		$like = '%' . $wpdb->esc_like( $string ) . '%';

		$searches = array();
		foreach ( $columns as $column ) {
			$searches[] = $wpdb->prepare( "$column LIKE %s", $like );
		}

		return '(' . implode( ' OR ', $searches ) . ')';
	}


Changelog

Changelog
Version Description
WP-4.6.0 Introduced.