In "wp-config.php" file you can set defines. They will be accesible everywhere without needing to use globals. Define something:
define('MY_DEFINE_NAME', 'THE_VALUE');
Then in your templates you can show the value like this:
echo MY_DEFINE_NAME;
Or create new variable and set to it a value:
$var = 'THE_VALUE';
But then need use "global
" identifier in functions for point to certain variable (purely PHP feature, not WP).
This touch only themes. These custom defines and variables, what contain in config file, don't will accessible in plugins, from config will accesible only native WP defines and variables, such as "ABSPATH
", and other. For plugins better use "functions.php" file for define custom variables and constants. I.e., do define own custom variables and constants, as shown above, but in "functions.php" file.
For check accessibility "functions.php" file in plugin you can use any function from "functions.php" file, e.g., function "current_time
" so:
echo current_time('timestamp');
Also you can check accessibility native WP constants from "wp-config.php" file in plugin so:
echo ABSPATH;