I'm using wp_enqueue_script
to enqueue the public-facing JS of my WP plugin:
wp_enqueue_script($this->PluginName, plugin_dir_url(__FILE__) . 'js/public.js', array(), $this->version, false);
And in the other side I have:
var data = { name: '' }
I would like, somehow, to set the name value to a value that I have access in the server side. Is this possible? Can someone point me to the documentation or an example of how to do that?
wp_localize_script()
function developer.wordpress.org/reference/functions/wp_localize_script