Refer documentation Link Scripts Only on a Plugin Administration Screen
add_action( 'admin_menu', 'my_plugin_admin_menu' );
function my_plugin_admin_menu() {
/* Add our plugin submenu and administration screen */
$page_hook_suffix = add_submenu_page( 'edit.php', // The parent page of this submenu
__( 'My Plugin', 'myPlugin' ), // The submenu title
__( 'My Plugin', 'myPlugin' ), // The screen title
'manage_options', // The capability required for access to this submenu
'my_plugin-options', // The slug to use in the URL of the screen
'my_plugin_manage_menu' // The function to call to display the screen
);
/*
* Use the retrieved $page_hook_suffix to hook the function that links our script.
* This hook invokes the function only on our plugin administration screen,
* see: http://codex.wordpress.org/Administration_Menus#Page_Hook_Suffix
*/
add_action('admin_print_scripts-' . $page_hook_suffix, 'my_plugin_admin_scripts');
}
function my_plugin_admin_scripts() {
/* Link our already registered script to a page */
wp_enqueue_script( 'my-plugin-script' );
}
function my_plugin_manage_menu() {
/* Display our administration screen */
}