Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

The latest version of jquery ui core fixes a bug that's on my site. The problem is that Wordpress comes with an earlier version.

How do I override the default jquery ui core? One solution I've found is to edit the script-loader.php file in wordpress includes folder but I don't want to touch the WordPress core unless I have to.

Below is the core change that worked that I want to avoid.

$scripts->add( 'jquery-ui-core', '/wp-content/themes/themefolder/jquery.ui.core.min.js', array('jquery'), '1.9.2', 1 );
share|improve this question
    
is it on the frontend or admin parts of your site? –  Mark Kaplun Mar 7 '13 at 6:51
    
the frontend of my site –  Julian Mar 7 '13 at 7:10
    
Then you should contact the author of your theme before trying to solve it yourself –  Mark Kaplun Mar 7 '13 at 7:35
add comment

1 Answer

up vote 1 down vote accepted

Add the following code in functions.php file of your theme that will remove default jquery ui core and will add your provided latest jquery ui core file from your theme.

function my_scripts_method() {  
 if(!is_admin()){     
    wp_deregister_script( 'jquery-ui-core' );
wp_enqueue_script('jquery-ui-core', get_stylesheet_directory_uri().'/jquery.ui.core.min.js', array('jquery'), '1.9.2', 1 );
}
}     
add_action('wp_enqueue_scripts', 'my_scripts_method');

Tell me if it works for you or i provide you another solution...

share|improve this answer
    
didn't work when I try to replace two jquery ui scripts. function add_new_jquery_ui_core() { wp_deregister_script( 'jquery-ui-core' ); wp_enqueue_script('jquery-ui-core', '/wp-content/themes/lastwell/jquery.ui.core.min.js', array('jquery'), '1.9.2', 1 ); wp_deregister_script( 'jquery-ui-dialog' ); wp_enqueue_script('jquery-ui-dialog', '/wp-content/themes/lastwell/jquery.ui.dialog.min.js', array('jquery'), '1.9.2', 1 ); } add_action('wp_enqueue_scripts', 'add_new_jquery_ui_core'); –  Julian Mar 7 '13 at 7:06
    
got these two errors (1) Uncaught TypeError: Object function (e,t){return new v.fn.init(e,t,n)} has no method 'widget' jquery.ui.dialog.min.js:5 (2) Uncaught TypeError: Object [object Object] has no method 'dialog' –  Julian Mar 7 '13 at 7:07
    
Is it working if you only enqueue jquery-ui-core js and not jquery-ui-dialog. –  Vinod Dalvi Mar 7 '13 at 7:12
    
Dont use relative path instead use get_stylesheet_directory_uri() function. –  Vinod Dalvi Mar 7 '13 at 7:14
    
I fixed it by added the correct dependencies for the dialog script. function add_new_jquery_ui_dialog() { wp_deregister_script( 'jquery-ui-dialog' ); wp_enqueue_script('jquery-ui-dialog', get_stylesheet_directory_uri() . '/jquery.ui.dialog.min.js', array('jquery-ui-resizable', 'jquery-ui-draggable', 'jquery-ui-button', 'jquery-ui-position'), '1.9.2', 1 ); } –  Julian Mar 7 '13 at 7:28
show 3 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.