How do I prevent NextGen from deregistering my version of jQuery?

I have a site running on WordPress 3.6 and recently upgraded to NextGen Gallery 2.

I’m loading jQuery from the Google CDN with a fallback to a local version. Like so…

Read More
if (!is_admin()) {
    wp_deregister_script('jquery');
    wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', false, null, false);
    add_filter('script_loader_src', 'jquery_local_fallback', 10, 2);
}
function jquery_local_fallback($src, $handle) {
    ....
}

When the NextGen plugin is disabled the jQuery loads up properly. If I activate the plugin it is overriding my version of jquery and instead using a local copy from /wp-includes/js/jquery/jquery.js.

I tried preventing NextGen from loading scripts by adding the define('NGG_SKIP_LOAD_SCRIPTS', TRUE); constant but nothing changed.

I want to keep the plugin upgrade safe so I don’t want to edit the files.

Related posts

Leave a Reply

1 comment

  1. After looking through the plugin code I found the function that was deregistering my version of jQuery. I noticed that it was comparing the versions to see if it was newer than 1.8.

    My call to register the script didn’t have a version number so it was being overwritten by this function.

    After adding the version number to my jQuery register call it all worked out.

    if (!is_admin()) {
        ....
        wp_register_script('jquery', '//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js', false, '1.10.2', false);
        ...
    }