WordPress Pass PHP Variable and Values to JS Theme or Plugin

The beautiful function wp_localize_script() was built for l11n, however its found as a method for carrying over server-side values into client-side JS.

Your values are now available in your .jsο»ΏΒ file:

console.dir(my_theme_data);

Currently using this in a React theme I’m building for WordPress.

This can also be done with something like: