Jquery conflict issue in multiple wordpress plugins

I have written 2 wordpress plugins and both use jquery 1.6. I load the plugin using the following code.

Plugin 1

function sheader() {
$plugin_dir = WP_PLUGIN_URL . "/";
?>
       <script type="text/javascript" src="<?php echo $plugin_dir; ?>isearch/js/jquery-1-6.js" ></script>
<?php
}

add_action('wp_head', 'sheader');

Plugin 2

function nheader() {
$plugin_dir = WP_PLUGIN_URL . "/";
?>
       <script type="text/javascript" src="<?php echo $plugin_dir; ?>isearch/js/jquery-1-6.js" ></script>
<?php
}

add_action('wp_head', 'nheader');

Since i am using the same file in both plugins, plgin 1 does not work. when i deactivate plugin 2 it works properly.

Read More

How can i solve this issue ??

Related posts

Leave a Reply

1 comment

  1. The way you include jquery, it includes the possibility to load it twice! Since most other plugins use the enque api. Make sure to use wp_enqueueto include any jquery dependency. It will check if it is allready loaded.

    <?php class arevico_facebook{
    function __construct(){
        add_action('wp_enqueue_scripts', array(&$this,'append_javascript'));
    }
    
    function append_javascript(){
         wp_enqueue_script("jquery");
     }}
    ?>
    

    Code is taken from my plugin:
    http://wordpress.org/extend/plugins/facebook-page-promoter-lightbox/