Global variable in wp_localize_script, help needed.
-
It’s got me crazy! ?? What is wrong with my piece of code? wp_localize_script doesn’t recognize my variable, even I declare it global in my function…
Thanks!$phpvariable = "This is from PHP"; function js_enqueue_scripts() { global $phpvariable; wp_register_script( "hendlerskripte", "/mojaskriptax.js" ); wp_enqueue_script( "hendlerskripte" ); wp_localize_script( "hendlerskripte", "JS_object_php_var", $phpvariable); } add_action( "wp_enqueue_scripts", "js_enqueue_scripts" );
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
- The topic ‘Global variable in wp_localize_script, help needed.’ is closed to new replies.