Is my global set up?
As you can see from taking a look at the »Help«-panel, when you’re using my »Current Admin Screen Info« 1), there’re certain points/hooks/filters in code, that need to pass by before a global is set up.
1) Still searching for a better name.
When to hook?
Yesterday, while reading WPSE chat, I had a nice idea that was the base for above mentioned plugin. To give you an idea of how to check if a global is set up, simply read the following code:
function get_hook_for_global()
{
$global = $GLOBALS['some_global'];
if ( isset( $global ) )
{
remove_filter( current_filter(), __FUNCTION__ );
return print "Global: $global<br />Set on: ".current_filter();
}
}
add_action( 'all', 'get_hook_for_global' );
This prints out the contents of the global, as well as the filter where it was set.
Improving the check
If you want to have detailed output, you’ll have to add array/object
handling as well:
// Object/Array handling: Dump contents
if ( is_array( $global ) OR is_object( $global ) )
$global = var_export( $global, true );