Fix TypeError crash when window.aql.allowedControls is undefined#156
Merged
ryanwelcher merged 1 commit intotrunkfrom Feb 25, 2026
Merged
Fix TypeError crash when window.aql.allowedControls is undefined#156ryanwelcher merged 1 commit intotrunkfrom
ryanwelcher merged 1 commit intotrunkfrom
Conversation
Guards against script loading order issues (e.g. from caching/optimization plugins) that can cause the inline script setting allowedControls to run before or after window.aql is initialized. - PHP: Initialize window.aql safely before setting allowedControls - JS: Use optional chaining with ALL_CONTROLS fallback so controls still render when allowedControls is unavailable instead of crashing Fixes #144, #138
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a
TypeError: Cannot read properties of undefined (reading 'split')crash reported in #144 and #138.window.aql.allowedControlsisundefinedwhencontrols.jstries to call.split(',')on it. Most likely triggered by caching/optimization plugins (e.g. WP Rocket, W3 Total Cache) that reorder script loading, causing the PHP inline script to execute beforewindow.aqlis initialized by the main bundle.window.aqlbefore settingallowedControls, preventing a ReferenceError if the inline script runs out of orderALL_CONTROLSfallback so controls still render whenallowedControlsis unavailable, rather than crashing or silently hiding all controlsChanges
includes/enqueues.php— Changedaql.allowedControls = "..."towindow.aql = window.aql || {}; window.aql.allowedControls = "..."sowindow.aqlis safely initialized regardless of script load ordersrc/variations/controls.js— Added?? {}to thewindow?.aqldestructure and?? ALL_CONTROLSfallback on.split()so the editor never crashes even if the inline script fails to runTest plan
aql_allowed_controlsPHP filter still correctly restricts visible controlsCloses #144
Closes #138