Raphael,

Since you are creating a WordPress plugin, I suggest looking at the
wp_enqueue_script() function[1].

Using your example, you'd include your scripts with something like:
<?php wp_enqueue_script('plugin1', '/wp-content/plugins/plugin1/js/
plugin1.js', array('jquery') ); ?>
<?php wp_enqueue_script('plugin2', '/wp-content/plugins/plugin2/js/
plugin2.js', array('jquery') ); ?>

And WordPress will handle the loading of jQuery and your plugin
scripts.

-Eric

[1] http://codex.wordpress.org/Function_Reference/wp_enqueue_script



On Nov 20, 4:16 pm, Raphael Jolivet <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I've developped several plugins for wordpress that require JQuery.
> As I have packaged and distributed these plugins separately, they come
> all with one version of JQuery.
>
> The problem is that if someone uses two of these plugins, the HTML
> header will look like :
> <script type="text/javascript" src="http://mysite/plugin1/jquery.js";></script>
>
> <script type="text/javascript" src="http://mysite/plugin1/
> jquery.plugin1.js" ></script>
> <script type="text/javascript" src="http://mysite/plugin2/jquery.js";></script>
>
> <script type="text/javascript" src="http://mysite/plugin2/
> jquery.plugin2.js" ></script>
>
> There are two issues here :
> * JQuery is loaded twice
> * The plugin declared by plugin1 will be erased by the second load of
> Jquery.js.
>
> Can I load Jquery dynamically by testing it is not already loaded ?
>
> I'm searching for a way to replace :
>
> <script type="text/javascript" src="http/mysite/plugin1/jquery.js" ></
> script>
>
> by
>
> <script type="text/javascript">
> if (!jquery_loaded) {
>     dynamic_load("http://mysite/plugin1/jquery.js";);}
>
> </script>
>
> Thanks in advance for your help.
>
> Raphael

Reply via email to