@@ -45,6 +45,25 @@ const isAdvancedQueryLoop = ( props ) => {
4545 return namespace && namespace === AQL ;
4646} ;
4747
48+ /**
49+ * Fallback list of all control identifiers, used when window.aql.allowedControls
50+ * is not available (e.g. due to script loading order issues from caching plugins).
51+ */
52+ const ALL_CONTROLS = [
53+ 'additional_post_types' ,
54+ 'taxonomy_query_builder' ,
55+ 'post_meta_query' ,
56+ 'post_order' ,
57+ 'exclude_current_post' ,
58+ 'include_posts' ,
59+ 'child_items_only' ,
60+ 'date_query_dynamic_range' ,
61+ 'date_query_relationship' ,
62+ 'pagination' ,
63+ 'exclude_posts' ,
64+ 'enable_caching' ,
65+ ] ;
66+
4867/**
4968 * Custom controls
5069 *
@@ -71,9 +90,10 @@ const withAdvancedQueryControls = ( BlockEdit ) => ( props ) => {
7190
7291 // If the is the correct variation, add the custom controls.
7392 if ( isAdvancedQueryLoop ( props ) ) {
74- const { allowedControls } = window ?. aql ;
93+ const { allowedControls } = window ?. aql ?? { } ;
7594 const { attributes } = props ;
76- const allowedControlsArray = allowedControls . split ( ',' ) ;
95+ const allowedControlsArray =
96+ allowedControls ?. split ( ',' ) ?? ALL_CONTROLS ;
7797 const propsWithControls = {
7898 ...props ,
7999 allowedControls : allowedControlsArray ,
0 commit comments