J. Doe
J. Doe

Reputation: 515

Plugin jQuery conflicting with WordPress jquery

I have created a WordPress plugin but it's conflicting with the WordPress jquery.

function maintenance_scripts() {
    wp_register_style('style', plugins_url('scripts/jquery-ui.css',__FILE__ ));
    wp_enqueue_style('style');

    wp_register_script( 'jquery-1.10.2', plugins_url('scripts/jquery-1.10.2.js',__FILE__ ));
    wp_enqueue_script('jquery-1.10.2');

    wp_register_script( 'jquery-ui', plugins_url('scripts/jquery-ui.js',__FILE__ ));
    wp_enqueue_script('jquery-ui');

    wp_register_script( 'jquery-settings', plugins_url('scripts/jquery-settings.js',__FILE__ ));
    wp_enqueue_script('jquery-settings');
}
add_action( 'admin_init','maintenance_scripts');

I have tried to remove my own jQuery and let it run on the WordPress jQuery but that did not work. I have also tried to deregister the WordPress jquery but without any luck.

Any experts out there know the solution?

Upvotes: 1

Views: 28

Answers (1)

J. Doe
J. Doe

Reputation: 515

I have fixed it by placing all the scripts inside the jquery-settings.js inside the footer of the admin area like so:

function maintenance_fjquery() {
?>
<script type="text/javascript">
jQuery(document).ready(function($) {
    ...
});
</script>
<?php
}
add_action( 'in_admin_footer', 'maintenance_fjquery' );

... and remove the jquery-1.10.2.js and jquery-ui.js.

Upvotes: 1

Related Questions