//is there a $param here?
None, the hook you’re using does not pass any parameters to the callback.
But you can instead use the admin_enqueue_scripts
hook which passes the hook name for the current menu page — the hook name is also saved in the global $hook_suffix
variable. You can then use get_plugin_page_hookname()
to get the hook name for a specific menu page and then conditionally enqueue the scripts for your menu pages.
function my_admin_enqueue_scripts( $hook_suffix ) {
switch ( $hook_suffix ) {
// Enqueue scripts for the "Audio Player -> Settings" page.
case get_plugin_page_hookname( 'my_settings', '' ) :
//wp_enqueue_script( ... );
break;
// Enqueue scripts for the "Audio Player -> Player manager" page.
case get_plugin_page_hookname( 'my_player_manager', 'my_settings' ) :
//wp_enqueue_script( ... );
break;
}
}
add_action( 'admin_enqueue_scripts', 'my_admin_enqueue_scripts' );
And actually, you should use the admin_enqueue_scripts
hook for enqueueing admin scripts. 🙂
Additionally, in your first add_submenu_page()
call, you should just omit the sixth parameter (i.e. the callback) than setting it to my_settings_page
, to prevent the function from being called twice on the same page.