WordPress Plugin Development - How to use JQuery / JavaScript?

后端 未结 2 1695
孤独总比滥情好
孤独总比滥情好 2021-02-13 18:59

Just started developing a plugin for WordPress, wanted to use some JQuery in the Plugin Admin interface.

How do I properly include and call JQuery?

For instance,

2条回答
  •  南旧
    南旧 (楼主)
    2021-02-13 19:34

    It is not recommended to be using your own jquery version.

    WordPress includes its own version of jquery and many other similar JS files, which have all been rigorously tested with WP and many of the most common plugins. In order to provide the best compatibility and experience for our users, we ask that you not package your own (especially not an older version) and instead use wp_enqueue_script() to pull in WordPress's version.

    So you should use this instead:

    wp_enqueue_script('jquery')
    

提交回复
热议问题