Pages

Friday, March 3, 2023

JQuery CDN breaking Wordpress Elementor Editor - Fixing Elementor Safe Mode

If you are getting the Elementor Safe Mode, appearing when you are editing in WordPress and you have jQuery using a CDN, they don't mix. It will break Elementor. 









Solution: 


The solution is load WordPress default jQuery libraries when you are logged in as admin. Otherwise for web users jQuery CDN links work fine. 

In script-loader.php


if (is_admin()) { //back-end
		
	$scripts->add( 'jquery-core', "/wp-includes/js/jquery/jquery$suffix.js", array(), '3.6.1' );
	$scripts->add( 'jquery-migrate', "/wp-includes/js/jquery/jquery-migrate$suffix.js", array(), '3.3.2' );
	$scripts->add( 'jquery-ui-core', "/wp-includes/js/jquery/ui/core$suffix.js", array( 'jquery' ), '1.13.2', 1 );

} else { //front-end

	$scripts->add( 'jquery-core', "https://ajax.googleapis.com/ajax/libs/jquery/3.6.1/jquery.min.js", array(), '3.6.1' );
	$scripts->add( 'jquery-migrate', "https://cdnjs.cloudflare.com/ajax/libs/jquery-migrate/3.3.2/jquery-migrate.min.js", array(), '3.3.2' );
	$scripts->add( 'jquery-ui-core', "https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.13.2/jquery-ui.min.js", array( 'jquery' ), '1.13.2', 1 );
}

No comments:

Post a Comment