[wp-hackers] wp _ enqueue _ script() not working while in the Loop
wp-hackers at tobias.baethge.com
Thu Dec 17 09:49:19 UTC 2009
thanks for the clarification on how the scripts adding works.
> The reason has to do with the way the print_scripts calls work. The
> first one called from wp_head processes all the enqueued scripts. If
> it see a footer one, it saves it in an array called "in_footer". The
> print_footer_scripts then prints those out later.
If there is such an array "in_footer", wouldn't it be possible to simply add an entry to that for my script? I'm aware that I would lose things like dependency checks, but actually I don't need those.
> If you want to determine whether a shortcode is used or not to include
> a script, you have to scan ahead to the content. Write your own Loop
> to look for the shortcode, then do a rewind to reset the loop for
> another go-through by the main page.
That's a suggestion that I will look into, but it will probably only solve the issue half, as I'm not only wanting to enqueue the script if a Shortcode is found, but also if my template tag function is executed (which obviously also happens after wp_head).
More information about the wp-hackers