Last active
March 1, 2016 22:33
-
-
Save soderlind/51e892680996c5e410e9 to your computer and use it in GitHub Desktop.
Dequeue old script and style loaded by the Divi theme
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function load_divi_fix() { | |
global $wp_scripts; | |
wp_enqueue_script( 'jquery-ui-core' ); | |
// get registered script object for jquery-ui | |
$ui = $wp_scripts->query( 'jquery-ui-core' ); | |
// dequeue old style and scripts loaded by the Divi theme | |
wp_dequeue_style( 'et_pb_admin_date_css' ); | |
wp_deregister_script( 'et_pb_admin_date_js' ); // loades old jquery.ui.core.js, jquery.ui.widget.js, jquery.ui.mouse.js, jquery.ui.datepicker.js, jquery.ui.slider.js | |
wp_dequeue_script( 'et_pb_admin_date_addon_js' ); // old jquery timepicker | |
// load wp native scripts and latest jquery-ui-timepicker | |
wp_enqueue_script( | |
'jquery-ui-timepicker', | |
'https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-timepicker-addon/1.6.1/jquery-ui-timepicker-addon.min.js', | |
array( | |
'jquery', | |
'jquery-ui-widget', | |
'jquery-ui-mouse', | |
'jquery-ui-datepicker', | |
'jquery-ui-slider' | |
), | |
'1.6,1', true); | |
// load a jquery ui theme matching current jquery ui version | |
$protocol = is_ssl() ? 'https' : 'http'; | |
$url = "$protocol://ajax.googleapis.com/ajax/libs/jqueryui/{$ui->ver}/themes/smoothness/jquery-ui.min.css"; | |
wp_enqueue_style( 'jquery-ui-smoothness', $url, false, null ); | |
wp_enqueue_style( | |
'jquery-ui-timepicker', | |
'https://cdnjs.cloudflare.com/ajax/libs/jquery-ui-timepicker-addon/1.6.1/jquery-ui-timepicker-addon.min.css', | |
array('jquery-ui-smoothness'), | |
'1.6.1' | |
); | |
} | |
add_action( 'admin_enqueue_scripts', 'load_divi_fix', 99 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The code for for adding jquery-ui-smoothness is from http://snippets.webaware.com.au/snippets/load-a-nice-jquery-ui-theme-in-wordpress/