[wp-hackers] Accessing jQuery in Core for a plugin
Viper007Bond
viper at viper007bond.com
Tue Nov 11 14:09:25 GMT 2008
http://codex.wordpress.org/Function_Reference/wp_enqueue_script
1. Once per new script.
2. WordPress will handle outputting. Don't do anything with the head, etc.
3. Call the wp_enqueue_script() at the very, very top of the page template.
On Tue, Nov 11, 2008 at 4:55 AM, ade <ade at studiograsshopper.ch> wrote:
> Jason,
>
> Thank for the tip!
>
> To all,
>
> Some more questions, if I may:
>
> 1. If I want to load two js files that need jQuery, do I simply call
> wp_enqueue_script twice?
>
> 2. In terms of action hooks, should I be using wp_print_scripts? It seems
> to me that using 'init' or 'template_redirect' loads the scripts before the
> HEAD html tag. (testing on 2.7 beta2) and (as I've read elsewhere) wp_head
> is too late.
>
> 3. The javascript files generate a gallery in a page template. What is the
> cleanest way of only loading these scripts on pages that contain the gallery
> - ie avoid loading the scripts on every page? The gallery will be triggered
> by a do_action call in the template page.
>
> Again, thanks in advance.
>
> Ade.
>
>
>
> > Jason Webster wrote on
> > Tue Nov 11 05:50:06 GMT 2008
> >
> > It is worthwhile to note that only WP
> > 2.6 includes jQuery 1.2.6+. For
> > example, 2.5 shipped with 1.2.3, so if backwards compatibility is a
> > priority of yours, make sure not to utilize any > 1.2.3 specific
> > features. The only big change to note was that the dimensions plugin
> > (which was included with WP < 2.6, so you'd have to enqueue it >
> separately) was integrated with the jQuery core.
>
>
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>
--
Viper007Bond | http://www.viper007bond.com/ | http://www.finalgear.com/
More information about the wp-hackers
mailing list