admin管理员组文章数量:1319023
I'm building a plugin and I want to use jQuery Knob but it seems like using this method:
plugins_url( '/assets/js/jquery.knob.min.js, . . . . .
Have conflicts with other plugins?
How to convert it like this?
wp_enqueue_script( 'jquery-ui-widget' );
wp_enqueue_script( 'jquery-ui-mouse' );
wp_enqueue_script( 'jquery-ui-accordion' );
wp_enqueue_script( 'jquery-ui-autocomplete' );
wp_enqueue_script( 'jquery-ui-slider' );
I'm building a plugin and I want to use jQuery Knob but it seems like using this method:
plugins_url( '/assets/js/jquery.knob.min.js, . . . . .
Have conflicts with other plugins?
How to convert it like this?
wp_enqueue_script( 'jquery-ui-widget' );
wp_enqueue_script( 'jquery-ui-mouse' );
wp_enqueue_script( 'jquery-ui-accordion' );
wp_enqueue_script( 'jquery-ui-autocomplete' );
wp_enqueue_script( 'jquery-ui-slider' );
Share
Improve this question
asked Oct 19, 2020 at 7:53
MarlonMarlon
318 bronze badges
1
- What are the conflicts specifically please? Just a missing jQuery declaration because o the load order, or is that not finding the file, or something else? – Rup Commented Oct 19, 2020 at 8:50
1 Answer
Reset to default 0If you want to just enqueue a script by name then you have to register it first with wp_register_script:
wp_register_script( 'jquery-knob',
plugins_url( 'assets/js/jquery.knob.min.js', __FILE__ ),
array( 'jquery' ), '1.2.11' );
:
wp_enqueue_script( 'jquery-knob' );
However that's only really useful when you're registering a script to be available as a dependency for other scripts, which I don't think you are here. Instead it's easier to register and enqueue it in one go, which you should do from a wp_enqueue_scripts hook:
function enqueue_jquery_knob() {
wp_enqueue_script( 'jquery-knob',
plugins_url( 'assets/js/jquery.knob.min.js', __FILE__ ),
array( 'jquery' ), '1.2.11' );
}
add_action( 'wp_enqueue_scripts', 'enqueue_jquery_knob', 10, 0 );
本文标签: pluginsHow to properly enqueue jQuery knob on Wordpress without conflict
版权声明:本文标题:plugins - How to properly enqueue jQuery knob on Wordpress without conflict? 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742051043a2418064.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论