Scope for PHP Variables Assigned in functions.php or a plugin
I’m a web developer who works on WordPress sites and want to ensure I keep PHP variables out of the global scope. I have questions about this:
-
If I created a
$new_title = "test seo title";
variable in an active theme’s functions.php file, is that$new_title
variable accessible (not undefined) in the active theme’s PHP files? Is that variable also accessible in the active plugin files? -
Also, if I created a
$new_title2 = "test seo title2";
variable inside an active plugin, is that$new_title2
variable accessible (not undefined) in active theme’s functions.php file and other theme PHP files?
Leave an answer