Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filters for specific keys are string templated incorrectly #10

Open
raikasdev opened this issue Jul 10, 2024 · 1 comment
Open

Filters for specific keys are string templated incorrectly #10

raikasdev opened this issue Jul 10, 2024 · 1 comment

Comments

@raikasdev
Copy link
Member

Because we use backslashes and not normal slashes, this escapes the complex string templating and results in the wrong filter name:

$strings[ $key ] = apply_filters( "air_cookie\strings\{$key}", $string );

with key consent_modal_title results in a filter "air_cookie\strings\{consent_modal_title}" being applied.

Proper usage would be

$strings[ $key ] = apply_filters( "air_cookie\strings\\{$key}", $string );

As seen on PHP String docs "Complex (curly) syntax" in the last 5 lines of the first code example.

// Won't work, outputs: C:\folder\{fantastic}.txt
echo "C:\folder\{$great}.txt"
// Works, outputs: C:\folder\fantastic.txt
echo "C:\\folder\\{$great}.txt"
@raikasdev
Copy link
Member Author

Noticed first by @rahkapetteri here.

Seems like I just scanned the message without reading it with thought 😵‍💫, but thanks for pointing this out! Noticed it today when setupping air-cookie for a site.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant