Skip to main content
9 events
when toggle format what by license comment
Feb 17, 2020 at 10:36 comment added Mel Macaluso @JacobPeattie ehm, where do you think you will store the object from the wp_localize_script()? hint: window, anyways as you are so attached to wp_localize_script() feel free to keep your opinion about using it for declaring variables not related to localising instead of using the vanilla function made to do so, to each his own.
Feb 17, 2020 at 10:27 comment added Jacob Peattie What are you talking about? wp_localize_script forces you to namespace your variables inside an object. Your own answer is adding a variable to the global scope without any sort of namespace.
Feb 17, 2020 at 10:06 comment added Mel Macaluso @JacobPeattie exactly, and what was wp_localize_script() string added for? Polluting the global scope with global variables? Or to actually localize as the name suggests?
Feb 17, 2020 at 9:28 comment added Jacob Peattie That's not what it was added for. It was added to support adding small bits of executable code before or after a script, to support things like font loaders. make.wordpress.org/core/2016/03/08/…
Feb 17, 2020 at 9:24 comment added Mel Macaluso @JacobPeattie Yes, the reason why they created wp_add_inline_script() is to avoid people using the localize script function to declare global variables. As the name suggests this is a better fit, why using something else which in the beginning wasn't intended for that purpose if we have a good alternative?
Feb 17, 2020 at 0:51 comment added Jacob Peattie This is just what wp_localize_script() does.
Feb 16, 2020 at 16:30 review Late answers
Feb 16, 2020 at 17:10
Feb 16, 2020 at 16:15 review First posts
Feb 17, 2020 at 4:39
Feb 16, 2020 at 16:10 history answered Mel Macaluso CC BY-SA 4.0