WordPress is awesome! The team there keeps on top of fixes, security holes and is always pushing forward making things (mostly) better. But sometimes, upgrades present new invisible challenges to conquer.
I run a lot of WordPress sites and a few days ago, updated to 4.5. Smooth sailing! Well, almost.
I found that on the site I was working on, many of the jQuery related actions were busted. Non-functional. Kaput. After scratching my head for a while and checking production servers and whatnot, I found that the problem only existed for me locally and not out there on the web, though some have reported similar issues there too.
When loading my local project, the one where many of the cool jQuery features weren’t showing up to work, I see this in the debugger window:
JQMIGRATE: Migrate is installed, version 1.4.0
Error: Syntax error, unrecognized expression: a[href*=#]:not([href=#]), area[href*=#]
...value:null},fa.error=function(a){throw new Error("Syntax error, unrecognized exp...
I tried disabling a plugin or two… nothing changed. I turned them all off…still nothing. Ok, time to go mine Google for an answer.
I found a post here for another theme that suggest this answer to a similar problem:
“Add this code to your theme’s functions.php file”
if (!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', ("https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"), false, '1.11.3');
wp_enqueue_script('jquery');
}
Voila! This fixed the problems! But why?
This essentially is de-registering the existing *newer* version of jQuery (v1.12.3) that comes with WordPress 4.5 and re-registers the last full version down (v1.11.3). So apparently, there are some compatibility issues with v1.12.3 that don’t play well with others. This fix isn’t meant to be a solution, but more a work-around for the time being. We’ll all stay tuned for another round of fixes that may just deal with this one, but in the mean time, this worked for me and some others.
Happy coding!