简体   繁体   English

WordPress插件jQuery冲突

[英]Wordpress Plugin jQuery Conflicts

I am developing a plugin, and i can not get rid of jquery conflicts in the website, i want to include my own jquery and custom script in the plugin even if the theme uses already jquery, it is possible completly using again jquery in a different way that will affect only the plugin? 我正在开发一个插件,但我无法摆脱网站中的jquery冲突,即使主题已使用jquery,我也想在插件中包含我自己的jquery和自定义脚本,有可能完全在另一种方法中再次使用jquery只影响插件的方式?

now i have this, but they get in conflicts with the theme jquery and scripts, how i cna separete the plugin jquery totally, i mean to be used only for the plugin? 现在我有了这个,但是它们与主题jquery和脚本冲突,我如何完全分离jquery插件,我的意思是仅用于该插件?

    function il_style() {

    wp_register_script( 'il_admin_jquery_script', plugins_url( '/il_js/jquery-1.11.0.min.js' , __FILE__, true));
    wp_register_script( 'il_admin_jquery_forms_styler_script', plugins_url( '/il_js/jquery.formstyler.min.js' , __FILE__, true));
    wp_register_script( 'il_admin_custom_jquery_script', plugins_url( '/il_js/il.jquery.custom.js' , __FILE__, true));
    wp_register_script( 'il_custom_jquery_forms', plugins_url( '/il_js/il.jquery.forms.js' , __FILE__, true));
    wp_register_script( 'il_custom_jquery_captcha', plugins_url( '/il_js/QapTcha.jquery.js' , __FILE__, true));
    wp_register_script( 'il_custom_jquery_captcha_touch', plugins_url( '/il_js/jquery.ui.touch.js' , __FILE__, true));

    wp_enqueue_scripts('il_admin_jquery_script');
    wp_enqueue_scripts('il_admin_jquery_forms_styler_script');
    wp_enqueue_scripts('il_admin_custom_jquery_script');
    wp_enqueue_scripts('il_custom_jquery_forms');
    wp_enqueue_scripts('il_custom_jquery_captcha');
    wp_enqueue_scripts('il_custom_jquery_captcha_touch');
}
add_action( 'init', 'il_style' );

So are you saying that you want to be able to remove the users copy of jquery and use your own in your plugin? 那么,您是说要删除用户的jquery副本并在插件中使用您自己的副本吗?

If so, surely you should be checking if the user has jquery running on their site already and using that? 如果是这样,您肯定应该检查用户是否已经在其站点上运行了jQuery,并正在使用它?

I'd be pretty pissed if a plugin was overriding my own copy. 如果插件覆盖了我自己的副本,我会很生气。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM