Since WordPress 3.5 – my whizzy website thingys are broken… help!?

In the last few days, I’ve been contacted by 2 of my clients saying that things such as tabs, scrollers, slideshows, accordions on their website are broken. The issue occurred when they upgraded their website to WordPress 3.5. So what’s going on?

Basically, WordPress 3.5 and up uses a new script that removes functionality that some of your whizzy features rely on. The plugins and aspects of your theme that use this functionality need updating to cope. However, doing this does require some technical ability.

WP Logo

From this point on, it gets technical, and is provided to help your web developer sort it out for you.

Techie Bits

If you take a closer look at your javascript errors in the javascript console (Firefox and Chrome are good for this), you’ll probably see this error:

Uncaught TypeError: Cannot read property 'msie' of undefined

The new version of WordPress now uses the latest version of jQuery, i.e. v1.9, which removes functionality that checks the browser type. Very annoying indeed. jQuery V1.9 came out on 15th Jan 2013, which is when problems started appearing.

The Hard Fix (but ideal)

Upgrade the plugins or javascript that relies on this old code. Since many plugin developers take a while to catch up, you might be waiting a while. However, you’ll probably have to update the theme code if tabs or sliders are hard-coded into the theme.

The Easy Fix

You can put back the code that those plugins need, by using this code that you put into functions.php. I’ve tested this code on 2 different websites, and it fixes the jQuery legacy issue.

// Fixes jQuery 1.9 legacy code issue
function jquery_legacy_code() {
    if (!is_admin()) {
        wp_enqueue_script(
           'jquery_legacy_code', 
           'http://code.jquery.com/jquery-migrate-1.0.0.min.js', 
           array('jquery')
        );
    }
}    
add_action('init', 'jquery_legacy_code'); 

If there’s a better fix, please let me know. This is a working solution, so hopefully it saves you a few hours of headaches!

Your First Name * Your Email Address *

Written by Dan Harrison

Dan Harrison is the lead developer and director of WP Doctors Ltd, a web development agency specialising in writing bespoke tools for WordPress-based websites that save time, hassle and money. You can follow Dan on Twitter here: @DanJHarrison and WP Doctors here: @wpdoctors.