When working out what is going on in WordPress

 

it is sometimes useful to be able to see what globals exist.

This snippet of code shows globals and excludes a couple of the big wordpress objects that probably are not of any use

[php]

foreach ($GLOBALS as $key => $value) {
if (($key!=’GLOBALS’) && ($key!=’wp_object_cache’) && ($key!=’wp_filter’)){
if ((!is_object($value)) && (!is_array($value))) {
echo "key= ".$key. " value= ".$value."<br>";
} else {
echo "key= ".$key." .. array/object <br>";
print_r($value);
echo "<br>… end array/object <br>";
}
}
}

[/php]
The code displays objects and arrays too. just add $ to the key to get the global and use it in your wordpress theme code.
This is advanced investigation into what WordPress is doing, when examining complex plugins and themes. This is not for beginners, but for wordpress developers.


Posted

in

, ,

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *