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