I have the following code inside one of my template files (NOT functions.php)
$datatoBePassed = array(
'pageTitle' => get_the_title()
);
wp_localize_script( 'main-js', 'php_vars', $datatoBePassed );
I am wondering if there are any inherent security issues when doing something like this outside of functions.php. My goal here is very simple- I'm just passing the page title into JavaScript so that way it can highlight matching text red within an existing list. I know there are probably better ways to accomplish this, but this is the best solution at the moment. If this is insecure, I can just echo it out into a display:none
div, and read that instead.