WordPress 5.2.1 deactivated my jQuery

I’ve been using the code below to use Google’s jQuery but the latest WordPress version deactivated it. How can I use jQuery from Google?

//* Use Google’s jQuery
add_action(‘init’, ‘use_jquery_from_google’);

function use_jquery_from_google () {
if (is_admin()) {
return;
}

global $wp_scripts;
if (isset($wp_scripts->registered[‘jquery’]->ver)) {
$ver = $wp_scripts->registered[‘jquery’]->ver;
} else {
$ver = ‘3.4.0’;
}

wp_deregister_script(‘jquery’);
wp_register_script(‘jquery’, “//ajax.googleapis.com/ajax/libs/jquery/$ver/jquery.min.js”, false, $ver);
}

Read more here:: WordPress 5.2.1 deactivated my jQuery

Leave a Reply

Your email address will not be published. Required fields are marked *