@@ -39,13 +39,6 @@ class ProductQuery extends AbstractBlock {
39
39
*/
40
40
protected $ attributes_filter_query_args = array ();
41
41
42
- /**
43
- * All query args from WP_Query.
44
- *
45
- * @var array
46
- */
47
- protected $ valid_query_vars ;
48
-
49
42
/**
50
43
* Initialize this block type.
51
44
*
@@ -187,8 +180,8 @@ function( $acc, $query ) {
187
180
if ( ! is_array ( $ query ) ) {
188
181
return $ acc ;
189
182
}
190
- // If the $query doesn't contain any valid query keys, we unpack/destructure it then merge.
191
- if ( empty ( array_intersect ( $ this ->get_valid_query_vars (), array_keys ( $ query ) ) ) ) {
183
+ // If the $query doesn't contain any keys, we unpack/destructure it then merge.
184
+ if ( ! $ this ->array_has_string_keys ( $ query ) ) {
192
185
return $ this ->merge_queries ( $ acc , ...array_values ( $ query ) );
193
186
}
194
187
return $ this ->array_merge_recursive_replace_non_array_properties ( $ acc , $ query );
@@ -517,42 +510,13 @@ function( $stock_status ) {
517
510
}
518
511
519
512
/**
520
- * Return or initialize $valid_query_vars .
513
+ * Check if array has string key .
521
514
*
522
- * @return array
515
+ * @param array $array Input array.
516
+ * @return bool
523
517
*/
524
- private function get_valid_query_vars () {
525
- if ( ! empty ( $ this ->valid_query_vars ) ) {
526
- return $ this ->valid_query_vars ;
527
- }
528
-
529
- $ valid_query_vars = array_keys ( ( new WP_Query () )->fill_query_vars ( array () ) );
530
- $ this ->valid_query_vars = array_merge (
531
- $ valid_query_vars ,
532
- // fill_query_vars doesn't include these vars so we need to add them manually.
533
- array (
534
- 'date_query ' ,
535
- 'exact ' ,
536
- 'ignore_sticky_posts ' ,
537
- 'lazy_load_term_meta ' ,
538
- 'meta_compare_key ' ,
539
- 'meta_compare ' ,
540
- 'meta_query ' ,
541
- 'meta_type_key ' ,
542
- 'meta_type ' ,
543
- 'nopaging ' ,
544
- 'offset ' ,
545
- 'order ' ,
546
- 'orderby ' ,
547
- 'page ' ,
548
- 'post_type ' ,
549
- 'posts_per_page ' ,
550
- 'suppress_filters ' ,
551
- 'tax_query ' ,
552
- )
553
- );
554
-
555
- return $ this ->valid_query_vars ;
518
+ private function array_has_string_keys ( $ array ) {
519
+ return count ( array_filter ( array_keys ( $ array ), 'is_string ' ) ) > 0 ;
556
520
}
557
521
558
522
/**
0 commit comments