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

Mike Schinkel mikeschinkel at newclarity.net
Wed Nov 30 09:27:22 UTC 2011

On Nov 30, 2011, at 12:38 AM, Frank Bueltge wrote:
> Yes, Mike, thats correct. Current it is an mix from different vars, But
> Franz search an function or var, that give back the value of all admin
> pages.

That's not really possible then. Plugins can add their own calls and it is not possible to know what those files do.  Besides plugins, WordPress core has not been consistent with such information, although I think Nacin has been pushing slowly in the direction of improving consistency with his work on the screen object.

I have run into a similar need for a long time. I created a "context" function that discovers information about the current page and returns it as an object. It's similar to get_current_screen() but it provides information that get_current_screen() does not provide.  But it does not attempt to provide a list of files as requested, though it could be extended to do so.

I think what would be helpful would be to create a community-developed extension to get_current_screen() via hooks, and code it in such a way that it could be inspected to return the list of available admin pages. Would you and Franz be interested in collaborating on that? We could take what I've done as a starting point after I convert to be a hook to get_current_screen() which is something I've been planning and should be able to get done very soon.

Also, this discussion is related to a potential front controller[1] for the WordPress admin like we have for themed pages. If someone reading this is not familiar with front controllers, it's a single .php file to route all URLs through, and it would allow for pretty URLs in the admin.  I've done enough proof-of-concept work to know that it can be done with a plugin and a few files copied to the /wp-admin directory, but I'd need help with testing and resolving edge cases. Would that interest you, or anyone else?  That could be something else to collaborate on.

[1] http://en.wikipedia.org/wiki/Front_Controller_pattern

More information about the wp-hackers mailing list