Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Is it possible to enqueue scripts and css only to the Network Admin Dashboard?

To edit the network admin menu, you have this hook: network_admin_menu, so I also tried network_admin_enqueue_scripts, but this didn't work.

Thanks! Roc.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

You can use the global variable $current_screen. It has the property is_network, with a boolean value, that indicates if we are in /wp-admin/network/ or not.

add_action( 'admin_print_scripts', 'network_scripts_wpse_91699' );

function network_scripts_wpse_91699() 
{
    global $current_screen;
    if( !$current_screen->is_network )
        return;

    wp_register_script( 'test', plugins_url( 'test.js', __FILE__) );
    wp_enqueue_script( 'test' );
}

This action hook can also be used like

add_action( 'admin_print_scripts-site-new.php', 'callback' );`

and it will only print in the screen /wp-admin/network/site-new.php, so there's no need to check if the current screen is a network one or not.

share|improve this answer
    
Thank You. Just quickly tried w/ your suggestion, and it works perfectly! –  Roc Mar 22 '13 at 16:22

Your Answer

 
discard

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.