Add dynamic {aql:} placeholder tokens for query values - #180
Open
ryanwelcher wants to merge 17 commits into
Open
ryanwelcher wants to merge 17 commits into
ryanwelcher wants to merge 17 commits into
Conversation
ryanwelcher
added this pull request to stack #183
September 10, 2026 15:18
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
Adds dynamic placeholder tokens of the form
{aql:name}that can be used in any query value, most usefully as a meta query value. Tokens are resolved centrally on the raw block query params before any trait or theaql_query_varsfilter runs, so every control (built in or third party) supports them without per-control code.Placeholder_Resolver(includes/Placeholder_Resolver.php). A pure class that reads only the context array passed to it, never global WP state, so it is fully unit-testable. Tokens that resolve to nothing are left in the value verbatim. A logged-out{aql:user_id}therefore compares against a literal string that matches no real meta value, so the clause matches nothing rather than widening to match everything.query_loop_block_query_vars, and editor previews viarest_{post_type}_query. The editor sends the edited post ID with preview requests (aql_preview_post_id) via anapiFetchmiddleware so post-relative tokens resolve correctly in the block editor.current_date,current_date_compactfor ACFYmddates,current_datetime,current_time,current_timestamp, zero-padded date parts, anddate_minus_*/date_plus_*offsets). All use the site timezone.aql_resolve_placeholderresolves a custom token at query time andaql_placeholder_listlists it in the editor picker.PlaceholderTextControlis exported onwindow.aqlso custom SlotFill controls can reuse it.extending-aql.mdcovering the token table, recipes (upcoming ACF events, running events, relationship fields), custom registration, and a caching note. Readme entries added.Testing
npm run test:uniton this branch: 205 tests, 340 assertions, all passing.tests/unit/Placeholder_Resolver_Tests.phpcovers every built-in token, unresolved-token passthrough, nested arrays, and the filter hooks.tests/e2e/tests/dynamic-placeholders.spec.tscovers the picker in the Meta Value field. Not run in this session (needs a wp-env instance).Related
#179 (meta query modal) is stacked on this branch and should merge after it.