[wp-hackers] Re: Plugin interference

Otto otto at ottodestruct.com
Fri Apr 11 14:47:42 GMT 2008


That's fine if you want to insert something into the header manually,
but what if you want to use the right functions to actually enqueue a
script instead? admin_head and admin_print_scripts are too late to add
enqueue_script calls.

Should one hang that off load-$page_hook instead?


On Thu, Apr 10, 2008 at 2:45 PM, Andrew Ozz <admin at laptoptips.ca> wrote:
> 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' );
>
>
>   }
>  }
>  _______________________________________________
>  wp-hackers mailing list
>  wp-hackers at lists.automattic.com
>  http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list