[wp-hackers] proper action to hook into for styles and scripts
Heiko Rabe
heiko.rabe at code-styling.de
Mon May 28 17:02:28 UTC 2012
Enqueue styles and scripts is he right way doing I also would prefere.
But the most common mistake made at attaching additional scripts and style
is:
- polluting all admin pages with scripts only intended for frontend
- polluting all admin pages with admin intended script but only for few
plugin based pages
So you should also write conditional tests, wether you are producing a front
page output and skip enqueue of admin scripts. You should also test, if your
are at admin pages and avoid frontend enqueue.
Furthermore you should also separate by conditional tests, if your
plugin/theme page is about to be shown at backend and enqueue your admin
scripts only, if your page is about to be rendered!
Most incompatibilities of plugins are forced by polluting the entired admin
pages with scripts never intended for all admin pages.
Regards
Heiko
(www.code-styling.de)
-----Ursprüngliche Nachricht-----
Von: wp-hackers-bounces at lists.automattic.com
[mailto:wp-hackers-bounces at lists.automattic.com] Im Auftrag von Bill
Erickson
Gesendet: Montag, 28. Mai 2012 18:10
An: wp-hackers at lists.automattic.com
Betreff: Re: [wp-hackers] proper action to hook into for styles and scripts
http://wpdevel.wordpress.com/2011/12/12/use-wp_enqueue_scripts-not-wp_print_
styles-to-enqueue-scripts-and-styles-for-the-frontend/
Use wp_enqueue_scripts to enqueue both scripts and styles on the frontend.
Use admin_enqueue_scripts to enqueue both scripts and styles on the backend.
---
Bill Erickson
WordPress Consultant
http://www.billerickson.net
NOTE: To better serve my clients, partners, and most importantly my family,
I've begun checking email only three times per day.
For phone calls, please schedule here: http://tungle.me/billerickson . If
it's an emergency, please call now and leave a voicemail
On Mon, May 28, 2012 at 11:05 AM, Chris McCoy <chris at lod.com> wrote:
> Ive seen people use these
>
> admin_print_styles
> admin_print_scripts
>
> and
>
> wp_print_styles
> wp_print_scripts
>
> and just
>
> init
>
> and just
>
> wp_enqueue_scripts
>
> which is the best way to go about it?
>
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
_______________________________________________
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