How Do I Detect A WordPress Admin Panel in my Plugin?

Posted by Volomike on Stack Overflow See other posts from Stack Overflow or by Volomike
Published on 2010-04-23T03:21:03Z Indexed on 2010/04/23 3:23 UTC
Read the original article Hit count: 429

I've got two events in my plugin. One is run for the front-end. The other is run for the admin panel. Both call the same function in one particular situation, and this echoes stuff to the screen. How do I make it such that the function is smart, calls something in WordPress, and detects whether it's being loaded in the front-end versus the admin panel? I don't want it to echo stuff to the screen on the front-end, but do want it to do so on the admin panel. Right now, it's echoing on both, which is not what I want.

Background

For the front end (the side of the site that the visitor sees), I'm intercepting the 'wp' event and checking for:

( is_single() || is_page() || is_home() || is_archive() || is_category() || is_tag())

For the admin panel, I'm intercepting the 'admin_menu' event. I tried intercepting the is_*() stuff above, but it seems to somehow answer TRUE or something, not giving me a difference between front-end and admin panel.

© Stack Overflow or respective owner

Related posts about Wordpress

Related posts about wordpress-plugin