0

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' );
}
1
  • You have to wp_register_script() earlier. Split this between two functions.
    – kaiser
    May 14 '11 at 11:21
3

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' );
7
  • @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. 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. 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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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