views:

16

answers:

1

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.

+1  A: 

Use is_admin() to detect when the Dashboard or the administration panels are being displayed.

More conditional tags documented here: http://codex.wordpress.org/Conditional_Tags

Amry