Skip to content

Commit 42bb2be

Browse files
committed
Conditionally render the controls based on the aql_allowed_controls filter.
1 parent 91fbda6 commit 42bb2be

File tree

1 file changed

+26
-9
lines changed

1 file changed

+26
-9
lines changed

src/variations/controls.js

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,9 @@ const isAdvancedQueryLoop = ( props ) => {
4646
const withAdvancedQueryControls = ( BlockEdit ) => ( props ) => {
4747
// If the is the correct variation, add the custom controls.
4848
if ( isAdvancedQueryLoop( props ) ) {
49-
// If the inherit prop is false or undefined, add all the controls.
49+
const { controls } = window?.aql;
5050
const { attributes } = props;
51+
// If the inherit prop is false or undefined, add all the controls.
5152
if ( ! attributes.query.inherit ) {
5253
return (
5354
<>
@@ -62,15 +63,31 @@ const withAdvancedQueryControls = ( BlockEdit ) => ( props ) => {
6263
<AQLLegacyControls.Slot
6364
fillProps={ { ...props } }
6465
/>
65-
<MultiplePostSelect { ...props } />
66-
<TaxonomyQueryControl { ...props } />
67-
<PostMetaQueryControls { ...props } />
66+
{ controls?.multiple_posts && (
67+
<MultiplePostSelect { ...props } />
68+
) }
69+
{ controls?.tax_query && (
70+
<TaxonomyQueryControl { ...props } />
71+
) }
72+
{ controls?.meta_query && (
73+
<PostMetaQueryControls { ...props } />
74+
) }
6875
<PostOrderControls { ...props } />
69-
<PostExcludeControls { ...props } />
70-
<PostIncludeControls { ...props } />
71-
<ChildItemsToggle { ...props } />
72-
<PostDateQueryControls { ...props } />
73-
<PaginationToggle { ...props } />
76+
{ controls?.exclude_current && (
77+
<PostExcludeControls { ...props } />
78+
) }
79+
{ controls?.include_posts && (
80+
<PostIncludeControls { ...props } />
81+
) }
82+
{ controls?.post_parent && (
83+
<ChildItemsToggle { ...props } />
84+
) }
85+
{ controls?.date_query && (
86+
<PostDateQueryControls { ...props } />
87+
) }
88+
{ controls?.disable_pagination && (
89+
<PaginationToggle { ...props } />
90+
) }
7491
<AQLControls.Slot fillProps={ { ...props } } />
7592
</PanelBody>
7693
</InspectorControls>

0 commit comments

Comments
 (0)