Automattic\WooCommerce\Internal\ProductFilters

QueryClauses::get_chosen_taxonomiesprivateWC 1.0

Get an array of taxonomies and terms selected from query arguments.

Method of the class: QueryClauses{}

No Hooks.

Returns

Array.

Usage

// private - for code of main (parent) class only
$result = $this->get_chosen_taxonomies( $query_vars ): array;
$query_vars(array) (required)
The WP_Query arguments.

QueryClauses::get_chosen_taxonomies() code WC 10.3.3

private function get_chosen_taxonomies( array $query_vars ): array {
	$chosen_taxonomies = array();

	if ( empty( $query_vars ) ) {
		return $chosen_taxonomies;
	}

	foreach ( $this->params->get_param( 'taxonomy' ) as $taxonomy => $param ) {
		if ( isset( $query_vars[ $param ] ) && ! empty( trim( $query_vars[ $param ] ) ) ) {
			$chosen_taxonomies[ $taxonomy ] = array_filter( array_map( 'sanitize_title', explode( ',', $query_vars[ $param ] ) ) );
		}
	}

	return $chosen_taxonomies;
}