WP 3.0 – Problems enqueueing javascript with specific target
-
My organization requires that I use WordPress 3.0 to create a new plugin. I’m having trouble getting one of my scripts to load to *only* my Options page (accessed as admin from the dashboard). When I enqueue it without a target page hook, the script successfully loads on every page, but I don’t want that. Here’s a few code snippets:
In my sidebar loader:
define( OPTIONS_PAGE, add_menu_page('EMS Forms Options', 'EMS Forms', 'manage_options', PATH.'/EMSF_Options.php') );
In my main file:
add_action('admin_print_scripts-'.OPTIONS_PAGE, 'Add_EMSF_Options_Scripts');
And here’s the function that the main file is assigning the action…
function Add_EMSF_Options_Scripts(){ wp_register_script('EMSF_Options, plugins_url('emsforms/js/EMSF_Options.js'), array('jquery','jquery-form'), '1.0'); wp_enqueue_script('EMSF_Options'); }
Any help with this would be greatly appreciated. I suppose I could just let it load the script on every page, but I’d rather not, since it uses jquery’s ajax functionality every time it loads.
Thanks in advance.
- The topic ‘WP 3.0 – Problems enqueueing javascript with specific target’ is closed to new replies.