Automattic\WooCommerce\Blocks\Utils
ProductCollectionUtils::remove_query_array()
Remove query array from tax or meta query by searching for arrays that contain exact key => value pair.
Method of the class: ProductCollectionUtils{}
No Hooks.
Return
Array
.
Usage
$result = ProductCollectionUtils::remove_query_array( $queries, $key, $value );
- $queries(array) (required)
- tax_query or meta_query.
- $key(string) (required)
- Array key to search for.
- $value(mixed) (required)
- Value to compare with search result.
ProductCollectionUtils::remove_query_array() ProductCollectionUtils::remove query array code WC 9.4.2
public static function remove_query_array( $queries, $key, $value ) { if ( ! is_array( $queries ) || empty( $queries ) ) { return $queries; } foreach ( $queries as $query_key => $query ) { if ( isset( $query[ $key ] ) && $query[ $key ] === $value ) { unset( $queries[ $query_key ] ); } if ( isset( $query['relation'] ) || ! isset( $query[ $key ] ) ) { $queries[ $query_key ] = self::remove_query_array( $query, $key, $value ); } } return self::remove_empty_array_recursive( $queries ); }