Automattic\WooCommerce\Blocks\BlockTypes

ProductQuery::get_filter_by_keyword_query()privateWC 1.0

Returns the keyword filter from the given query.

Метод класса: ProductQuery{}

Хуков нет.

Возвращает

Массив. The keyword filter, or an empty array if none is found.

Использование

// private - только в коде основоного (родительского) класса
$result = $this->get_filter_by_keyword_query( $query ): array;
$query(WP_Query) (обязательный)
The query to extract the keyword filter from.

Код ProductQuery::get_filter_by_keyword_query() WC 8.7.0

private function get_filter_by_keyword_query( $query ): array {
	if ( ! is_array( $query ) ) {
		return [];
	}

	if ( isset( $query['s'] ) ) {
		return [ 's' => $query['s'] ];
	}

	return [];
}