The function wp_localize_script( $handle, $name, $data );
does not work when trying to overwrite the same variable, that is when calling the function second time with the same $handle and $name but with other $data value.
How can this problem be solved?
after_setup_theme
action theme settings are retrieved usingget_option()
2. on 'wp_head', scripts are enqueued usingwp_enqueue_script
and JS vars are initialized usingwp_localize_script
. On Customizer preview againwp_head
filter is used.get_option()
is again called and frontend is reinitialized. Nowwp_localize_script
have to be called again.