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.

Tried them both and they don't seem to be working, am I missing something?

add_action('admin_footer', 'jupload_scripts');
    wp_register_script('jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js', array('jquery'), '1.8.6');
    wp_enqueue_script( 'jquery-ui' );
}
share|improve this question
    
You have to wp_register_script() earlier. Split this between two functions. –  kaiser May 14 '11 at 11:21
add comment

1 Answer

up vote 2 down vote accepted

As per Wordpress Codex its best to register and queue your scripts with the hook dedicated for them, even if you want your script to be added to footer.

So the correct way of doing it will be:

function jupload_scripts() {
    wp_enqueue_script( 'jquery-ui', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js', array('jquery'), '1.8.6', true );
}
add_action( 'admin_print_scripts', 'jupload_scripts' );
share|improve this answer
    
@Hameedullah So admin_print_scripts is ok but admin_print_footer_scripts is not? I don't understand. –  INT May 14 '11 at 16:33
    
Yes, for some reason the scripts that you queue in admin_print_footer_scripts hook are not printed by wp. So you have to queue them in the admin_print_scripts hook, just make sure if you want them to be printed in footer set the last $in_footer argument to true as in the above example. –  Hameedullah Khan May 14 '11 at 17:06
    
@Hameedullah Ah, sorry, didn't see that first. Thanks alot, works like a charm! –  INT May 14 '11 at 21:19
1  
Also: WordPress already bundles a version of jQuery-UI. It is imperative, especially in the backend, that you first deregister the core-bundled jQuery-UI, by calling wp_deregister_script( 'jquery-ui' ), before registering/enqueueing your own version. Also, if you are going to do this, do it judiciously. The specific jQuery/jQuery-UI version combination is used in WordPress due to extensive bug testing. If you change versions of one or the other, you are highly likely to encounter version-conflict issues. –  Chip Bennett May 14 '11 at 21:42
    
Thanks for pointing this out @Chip. I wasn't entirely sure, since in WP they call it jquery-ui-core. I thought there were some difference. Anyway, do I neeed to include jquery-ui.css on my own, or is that taken care of aswell? –  INT May 15 '11 at 10:23
show 2 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.