-
Notifications
You must be signed in to change notification settings - Fork 65
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
performance: add frontend variables only when there is a block that needs them #3019
Conversation
🤖 Pull request artifacts
|
Size Change: +193 B (0%) Total Size: 1.99 MB
ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do not perform the wp_localize_script
if $args
is empty. It still prints out in the frontend even if you pass an empty array
src/init.php
Outdated
public function init_stackable_vars() { | ||
$args = apply_filters( 'stackable_localize_frontend_script', array() ); | ||
if ( array_key_exists( 'restUrl', $args ) ) { | ||
echo '<script> stackable = {"restUrl": "' . $args["restUrl"] .'"} </script>'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
instead of writing the restUrl
manually, please convert $args
to JSON instead to print out the entire $args
if it has contents
fixes #3007