Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
Utils::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: Utils{}
No Hooks.
Returns
Array.
Usage
$result = Utils::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.
Utils::remove_query_array() Utils::remove query array code WC 10.4.3
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 );
}