[wp-hackers] How to determine which admin screen I'm currently viewing

24/7 24-7 at gmx.net
Tue Nov 29 20:00:54 UTC 2011


After inspecting core for about a day, I now had to come here to ask this 
Q, because I'm completely at the end with my ideas.

I'm trying to write a plugin that needs to trigger on every admin UI page. 
Therefore I need to find out, where I exactly am. 
$GLOBALS['current_screen']; gives me some basic data, but when building the 
array I compare against, I have no clue where to get consistent data from. 
I use the globals $menu, $submenu; to build a multidimensional array 
containing the admin menu items as shown in this paste [1]. 

Point is that already tried to compare against global $self, 
$current_screen, $parent_file, $submenu_file, $plugin_page, 
$admin_page_hooks, $_registered_pages, $_parent_pages; but none 
was consistent across all admin pages. I also couldn't get behind the logic 
what exactly is used where.

I hope someone can give me a bit of an insight into this.

Thanks a lot!
Best wishes,
Kaiser.

[1] Pastebin w exemplary admin menu items http://pastebin.com/hssR1E16


More information about the wp-hackers mailing list