wp_localize_script() conflict
-
Hi there,
When you register your own scripts or styles within WordPress, it’s not a bad idea to use something more unique to your plugin. For instance, you register your fb.js script with a handle of “myownscript” – not very unique, nor describing of what it is. A better alternative would be something like “fb-pagelike-widget” or “milap-fb-pagelike-widget”. I don’t have an issue with this in particular, but it’s not impossible that someone else decided to name their script “myownscript”, which would make either your or their JS to not be loaded on the site.
The same thing goes for when using
wp_localize_script(). You’re assigning some values to an object calledvars(these objects are within the global JS scope, so can be overwritten), which again is not really unique. I have another plugin that does the same thing. The result is that the other plugin breaks.So, please with the next version just change at least the second parameter of
wp_localize_script()to try and prevent race conditions like this from happening.Thank you 🙂
The topic ‘wp_localize_script() conflict’ is closed to new replies.