[wp-hackers] Re: Plugin interference

Andrew Ozz admin at laptoptips.ca
Thu Apr 10 19:45:08 GMT 2008


Alexander Beutl wrote:
> jep sure this is nearly as I did it
> function my_head() {
> if( $_GET['page'] = 'mypage' {
> // doit
> }
> }
> 
> but what I wanted to know is how to use the hooks which are especially
> designed for not needing this:
> 
> admin_head-(page_hook) or admin_head-(plugin_page)
> Runs in the HTML <head> section of the admin panel of a plugin-generated
> page.
> 
> and
> 
> admin_print_scripts-(page_hook) or admin_print_scripts-(plugin_page)
> Runs to print JavaScript scripts in the HTML head section of a specific
> plugin-generated admin page.
> 
> 
> (you will find them here:
> http://codex.wordpress.org/Plugin_API/Action_Reference#Administrative_Actions)
> 
> This ones were my prefered way to do that - if I just could figure out, what
> that stuff to add after the normal hookname is - everything I tried just
> didn't do anything...

I've always used this:

function myplugin_menu() {
   if ( function_exists('add_management_page') ) {
     $page = add_management_page( 'myplugin', 'myplugin', 9, __FILE__, 
'myplugin_admin_page' );
     add_action( "admin_print_scripts-$page", 'myplugin_admin_head' );
   }
}


More information about the wp-hackers mailing list