Automattic\WooCommerce\Blocks\BlockTypes

ProductQuery::get_filter_by_keyword_query()privateWC 1.0

Returns the keyword filter from the given query.

Method of the class: ProductQuery{}

No Hooks.

Return

Array. The keyword filter, or an empty array if none is found.

Usage

// private - for code of main (parent) class only
$result = $this->get_filter_by_keyword_query( $query ): array;
$query(WP_Query) (required)
The query to extract the keyword filter from.

ProductQuery::get_filter_by_keyword_query() code WC 8.9.0

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

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

	return [];
}