Looking at the code of Gravity Forms, I found that for some scripts, it uses
wp_localize_script function to add their own definitions inline page source. The question I asked myself is is it possible for me to override their code, and how can I override their code without editing plugin source? Let’s see 👀 ~~
I get used to override the scripts from Gravity Forms by
gform_enqueue_scripts, it’s their own hook to add the assets to our site. For example, in my case, I need to override the variable
gf_global, I can begin by adding some extra code in this hook.
When researching, there is no options from WordPress to do something like de-localize the scripts (just like we have wp_dequeue_script), so I’m thinking to adding the same variable after the scripts localize. There will be 2 variables displayed so the scripts will get the latest variable.
That’s my example code to override the Spinner URL from Gravity Forms by
wp_localize_script, there is another way simpler by using PHP but it’s my first try to use