WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm adding an action witht he following line:

add_action( 'admin_init', 'fb_init_scripts');

And my function looks like this:

  function fb_init_scripts() {
    //Only use these scripts in admin interface
    if (is_admin() ) {

In this instance, is it pointless to use is_admin() to controll if I'm in admin panel, since I'm running this function in admin_init ?

share|improve this question
up vote 6 down vote accepted

Yep, pointless.

admin_init only fires in admin area (and couple more files related to AJAX functionality) so additional is_admin() check is not necessary.

It often comes up in examples for hooks that fire both on front-end and admin area.

share|improve this answer

As Rarst said it's redundant. The ajax interface happens to be in the admin area for reasons related to authentication, and WP considers it to be part of the admin area -- including when it technically isn't.

A good "trick", that said, is to wrap applicable add_action() calls in an if block:

if ( is_admin() ) {
  add_action('admin_init', 'foo');

Doing so avoids polluting the $wp_filter global on the front end.

Better yet, create a separate file with admin-related code, and only include it in the admin area (or when needed, using the 'load-$pagehook' action). You can see an example of how this is done here:


share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.