collection_active_filters_data filter-hookWC 11.7.0

Filters the active filter data provided by filter blocks.

$data = array(

<id> => array(
	'type' => string,
	'items' => array(
		array(
			'title' => string,
			'attributes' => array(
				<key> => string
			)
		)
	)
),

);

Usage

add_filter( 'collection_active_filters_data', 'wp_kama_collection_active_filters_data_filter', 10, 2 );

/**
 * Function for `collection_active_filters_data` filter-hook.
 * 
 * @param array $data   The active filters data
 * @param array $params The query param parsed from the URL.
 *
 * @return array
 */
function wp_kama_collection_active_filters_data_filter( $data, $params ){

	// filter...
	return $data;
}
$data(array)
The active filters data
$params(array)
The query param parsed from the URL.

Changelog

Since 11.7.0 Introduced.

Where the hook is called

ProductFilterActive::render()
collection_active_filters_data
woocommerce/src/Blocks/BlockTypes/ProductFilterActive.php 49
$active_filters = apply_filters( 'collection_active_filters_data', array(), $this->get_filter_query_params( $query_id ) );

Where the hook is used in WooCommerce

woocommerce/src/Blocks/BlockTypes/ProductFilterAttribute.php 32
add_filter( 'collection_active_filters_data', array( $this, 'register_active_filters_data' ), 10, 2 );
woocommerce/src/Blocks/BlockTypes/ProductFilterPrice.php 33
add_filter( 'collection_active_filters_data', array( $this, 'register_active_filters_data' ), 10, 2 );
woocommerce/src/Blocks/BlockTypes/ProductFilterRating.php 36
add_filter( 'collection_active_filters_data', array( $this, 'register_active_filters_data' ), 10, 2 );
woocommerce/src/Blocks/BlockTypes/ProductFilterStockStatus.php 34
add_filter( 'collection_active_filters_data', array( $this, 'register_active_filters_data' ), 10, 2 );