Every version of WordPress comes packaged with a version of jQuery. Because WordPress is a modular framework, and resources like jQuery are shared between all plugins and themes, all plugins and themes need to assume that the default version of jQuery for a particular version of WordPress is present.
It is possible to programmatically change the version of jQuery used, however no theme or plugin should ever change the version of jQuery from the version packaged in WordPress Core. Only the site administrator/developer should ever change the version of jQuery – and in that case, it becomes their responsibility to ensure all plugins and themes they use are compatible. See Why loading your own jQuery is irresponsible
For example, WordPress 4.0 is packaged with jQuery 1.11.1. If the theme enqueues jQuery 1.6 instead, this creates major conflicts.
Identifying the issue
In UberMenu 3, you can also use the UberMenu Diagnostics functionality to test for this.
Here are some common incorrect scripts:
And here is what the default, correct inclusion would look like
Look at the URL, or open the jQuery file itself and check the header to determine the version.
Here’s a table of appropriate versions of jQuery for each version of WordPress:
|WordPress Version||jQuery Version|
(Note that UberMenu 3.0 requires WordPress 3.9+ and jQuery 1.11.1+)
If your version of jQuery is less than 1.11.1, either:
1. You are using WordPress < 3.9, in which case you need to upgrade (WordPress 3.9+ is an UberMenu requirement). 2. Your theme or another plugin is loading an incorrect version of jQuery. You also may have multiple versions of jQuery loaded - for instance, if a plugin/theme didn't deregister the default jQuery library before loading their own, or if jQuery was inserted through any method other than the proper wp_enqueue_script. Having a duplicate version of jQuery loaded can cause major issues; unless you are 100% sure of what you’re doing, you should only load one version (make sure it’s the right one!)
You need to make sure the version of jQuery being used in your site is the proper version. As of WordPress 3.4, that version is jQuery 1.7.2. You will need to remove any improper versions of jQuery.
While this will vary widely from theme to theme, here’s what you should look for in your theme (a good place to start is the functions.php file, but a global search is often very useful) or plugin files.
What to look for
A common pattern is to dequeue the version of jQuery included with WordPress, and load the Google CDN version instead. This works nicely for the current version, but when you upgrade WordPress and the theme isn’t upgraded, you’re now loading an old version.
Look for these functions:
wp_dequeue_script( 'jquery' ); wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js'); wp_enqueue_script( 'jquery' );
If you’ve found multiple versions of jQuery in your site source, either the theme/plugin enqueued the jQuery library using a different tag than ‘jquery’, or they dumped it into the header without enqueuing properly. The easiest way to find these is to do a global search on the path/URL to the script that you found in the source.
Once you find the problem, remove or comment out the code. You may wish to alert the developer of the theme/plugin, so they can update their code to use WordPress best practices. All that is required to use jQuery is to call:
wp_enqueue_script( 'jquery' );
with the appropriate action hook. More information can be found here: wp_enqueue_script.
It’s important to note that this should only be done on plugins or themes used on sites that you will be personally maintaining. Any plugins or themes that you release for public use should use the libraries included with WordPress.