-
Notifications
You must be signed in to change notification settings - Fork 423
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
Multiple wp_localize_script #850
Comments
@funkedgeek Please fix this. |
Just looked at this and I think it might be the same as @ma3ie4 said about the default implementation of |
…or all cases because we can use wp_localize_script() multiple times to add more than one localized strings with 1 handle. But in Meta Box, each fields requires only 1 localized string, so we can check if that exists and enqueue only once.
Added a fix for this. Better than the way WC does :). The logic is checking if the script already has localized string: if no -> add localized string, if yes -> ignore. Because each field requires only 1 localized string, this works nicely :) |
Hi,
great plugin! I use it in all of my projects.
I've noticed that wp_localize_script is adding multiple i18nRwmbMedia arrays to HTML.
Line 18 - \meta-box\inc\fields\media.php
It looks like for every: field 'type' => 'image_advanced' - there is separate array.
As I understand it's wordpress default implementation of 'wp_localize_script'.
Maybe it will be possible to call it like 'Woocommerce plugin' did in function 'private static function localize_script' (only once):
https://github.com/woothemes/woocommerce/blob/master/includes/class-wc-frontend-scripts.php
The text was updated successfully, but these errors were encountered: