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.

Does anyone know how to enqueue the script "Jquery UI Tabs" in admin area? I want to use it inside my theme options page. Already read the related wordpress documentation but with no results... I have added UI Tabs to the front-end and works fine but I cant add it in the admin area... Thanks in advance.

share|improve this question
add comment

1 Answer 1

up vote 3 down vote accepted

I normally load it as a dependancy of my plugin's js file like so:

if ( is_admin() ) {
    //load my plugin's js
    add_action('admin_print_scripts', 'my_plugin_load_js' );

}

function my_plugin_load_js() {
    $plugin_js = WP_PLUGIN_URL . '/' . plugin_basename( dirname(__FILE__) ) . '/my-plugin.js';
    wp_enqueue_script('my-plugin-js', $plugin_js, array('jquery-ui-tabs'), '1.0');

}
share|improve this answer
    
kalengi thank you very very much. works fine! Should I use admin_print_scripts or admin_enqueue_scripts? –  Arg Geo Jul 23 '12 at 22:26
    
Ah, and how could I enqueue UI Tabs without any other custom js file? –  Arg Geo Jul 23 '12 at 22:29
    
re: admin_print_scripts vs admin_enqueue_scripts - seems there aren't any strict rules on which to use. In my case I just went with the one that worked and stuck with it. –  KalenGi Jul 23 '12 at 23:00
    
re: enqueue UI Tabs other custom js - You could achieve this by using wp_enqueue_script('jquery-ui-tabs', PATH_TO_JQUERY_UI_TABS_JS, array('jquery'), JQUERY_UI_TABS_VERSION);. I stay away from this aproach due to 1) You have to know the path to the ui-tabs js file. 2) You have to keep track of the ui-tabs version information. I'd much rather leave those tasks to WP. –  KalenGi Jul 23 '12 at 23:08
    
more on the admin_print_scripts vs admin_enqueue_scripts... here's a pretty good explanation of the difference: wordpress.stackexchange.com/questions/21561/… –  KalenGi Jul 23 '12 at 23:15
show 1 more comment

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.