[wp-hackers] wp _ enqueue _ script() not working while in the Loop
wp-hackers at tobias.baethge.com
Thu Dec 17 10:00:58 UTC 2009
thanks for your code example. That's pretty close to what I'm currently doing (except for using a global variable I use a class variable).
Given the existence of wp_enqueue_script, I thought I could do that a little bit more elegant and robust.
Robust in terms of:
I have two plugins (with different functionality and purpose) that both happen to want to use a JS script (i.e. a jQuery plugin, not included in core, so each plugin ships a copy of the same JS file) in the footer (triggered by a Shortcode or a template tag function).
Now I thought I could circumvent that by using wp_enqueue_script, with the same "handle" parameter. Because then WP would take care of the actual printing and the script would only be included once.
(Does my explanation sound understandable?)
Of course both plugins could use the same global variable to cross-check, but that's cheep somehow and not really good practice, I guess.
Something similar that would also help: A function to check if a script (i.e. handle) has been printed. Then I could use that to check if printing is required...
More information about the wp-hackers