[wp-hackers] Adding JS to a Page based upon the used shortcodes
Otto
otto at ottodestruct.com
Fri May 2 13:29:58 GMT 2008
Yes, you could wait as long as the wp_print_scripts action before
enqueuing your script, but that's it. You'll have to manually search
the post content for the shortcodes.
On Fri, May 2, 2008 at 8:06 AM, Casey Bisson <casey.bisson at gmail.com> wrote:
>
> I haven't checked this in 2.5, but I believe you could hook into
> template_redirect. The posts have been queried, but nothing has been output
> to the browser at that point. You could sniff the content and add
> wp_enqueue_script hooks then.
>
> http://wphooks.flatearth.org/hooks/template_redirect/
>
>
>
>
> On May 2, 2008, at 7:13 AM, Alexander Beutl wrote:
>
>
> > Hi,
> >
> > I am working on an image gallerie plugin using the new shortcodes and I
> want
> > to add some options to define
> > a) how the gallerie should look
> > b) which JS is used (thickbox, lytebox, jQuery Lightbox, and some others,
> > which will do really different things like slideshows, flash like
> galleries,
> > carousels and stuff)
> >
> > While I could make this be defined consistantly between all pages when
> using
> > options, I want to make it costomizable per Post (or per Gallerie I should
> > say, since one could use more then one gallerie and one could use a
> gallerie
> > in template) using attributes in the shortcodes.
> >
> > I know about the wp_enqueue_script command but this doesn't work when
> called
> > inside the shortcode function since this is much to late (head is out
> > allready) - and I do not know about any functionality how to know about
> the
> > used shortcodes before I am in the shortcode function. Is there any way to
> > do this?
> >
> > Yes maybe it would work to write the JS directly into the body but this
> > isn't a good solution. Any ideas?
> >
> > Thanks
> > Alex
> > _______________________________________________
> > 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