How to add scripts and styles for EXACT page in WordPress admin panel

I am well aware of the WP hooks admin_print_scripts-$mypage, admin_print_styles-$mypage but they seem to trigger only for pages registered with $mypage = add_management_page( ... ), add_options_page(), etc. It’s quite clear you won’t be able to use these for sub-generated pages with totally different markup unless you keep the URL intact (pass data using POST).
As it’s my first encounter, i came up with solution which is quite simple – conditions for $_GET['page'],$_GET['action'](for ex.) and $_SERVER['PHP_SELF'] then hook admin_print_scripts/styles with wp_enqueue_script/style () . It works just well but is it the way to go?

Related posts

Leave a Reply

1 comment