Outdated Version of jQuery in Wordpress

南笙酒味 提交于 2019-12-13 23:26:09

问题


I have a plugin in wordpress (easy-fancy-box), which I think is adding this in my wp header. <script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js?ver=1.6.4'></script>

This version is outdated and is preventing me from using newer versions of jquery, (if i add version 1.8 of jquery, then the fancy box plugin fails. Is there a way to update the version which easy-fancy-box uses?

I have tried searching for this in all the plugin files, but cannot locate where it is on order to change it to the newer version


回答1:


Are you sure that it is not you or another plugin that is adding the jQuery?

I just had a look at the plugin you linked to, and it just calls the jQuery you registered to in WordPress.

Example line 402 in easy-fancybox.php:

wp_enqueue_script('jquery.fancybox', plugins_url(FANCYBOX_SUBDIR.'/fancybox/jquery.fancybox-'.FANCYBOX_VERSION.'.pack.js', __FILE__), array('jquery'), FANCYBOX_VERSION);

jQuery is loaded as a dependency in that.

Look in your theme if you deregistered jQuery (using wp_deregister_script('jquery') )and registered it again to use Google's CDN.




回答2:


Firstly, Wordpress will load the latest version of JQuery anyway, so you will probably be better of just removing the outdated version completely, rather than updating.

Secondly, providing that JQuery was enqueued in the recommend fashion, you can dequeue it using WP's wp_dequeue_script function, which you can read about here. You will need to know the handle that was assigned the script when it was originally enqueued in order to remove it.

The catch here is I'm not sure if Easy Fancy box is the plugin you should be looking at; I've had a quick scan through its files and I couldn't spot any instances of it enqueueing JQuery. So your suspect may be a different plugin. Look through your other plugins and keep an eye out for any instances of wp_register_script that point to V1.6.4 of JQuery. Once you have located the culprit, you can either comment out the relevant wp_register_script and wp_enqueue_script lines, which I wouldn't recommend, or you can use the wp_dequeue_script and wp_deregister_script functions in your own functions.php file.



来源:https://stackoverflow.com/questions/16078231/outdated-version-of-jquery-in-wordpress

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!