1

The administration part for my plugin is divided into several pages and for some pages I would like to enqueue a JS source which would add jQuery functionality to various elements.

Right now this is my approach:

function admin_register_init() {

 if ($_GET['page'] == 'worldexplorer_admin_location_hub')
  wp_enqueue_script('worldexplorer_admin_hub', WP_PLUGIN_URL.'/worldexplorer/admin/admin_hub.js');
}
add_action('admin_init', 'admin_register_init');

However, this requires me to check the page index of the $_GET array. Is there another way to achieve what I wish to do?

3

I believe there is a hook admin_print_scripts-{$page} which might fit.

See this Load scripts only on plugin pages

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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