I’m trying to create a plugin in wordpress and want to include a JS script in the tags area only when i’m viewing the menu page.
add_action('admin_menu', 'register_custom_menu_page');
function register_custom_menu_page() {
add_menu_page('Home', 'PCPAL', 'manage_options', 'pcpalmain', 'da_controller', '', 99);
}
function DA_controller()
{
add_action('admin_head', 'da_admin_head');
}
function da_admin_head()
{
echo "<script type='text/javascript' src='".plugins_url('js/pcpal.js', __FILE__)."'></script>";
}
This script work if i move the add_action(‘admin_head’, ‘da_admin_head’); outside the DA_function function.
enqueueit ->http://codex.wordpress.org/Function_Reference/wp_enqueue_scriptadmin_headyou need to useadmin_inittutorial about enqueue-ing
http://halfelf.org/2012/jquery-why-u-no-enqueued/