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_mana开发者_运维百科gement_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?
I am a little confused as to why you have any pages which are not registered using the WordPress functions. If the plugin/theme is complicated enough to need several distinct pages (not just one page with some tabs) then I suggest you add a standalone page using: http://codex.wordpress.org/Function_Reference/add_menu_page and then have several sub pages using: http://codex.wordpress.org/Function_Reference/add_submenu_page
精彩评论