I want to know the correct way to load existing scripts in wp-includes/js/jquery/
Example I want to load jQuery UI Tabs
What I have done for now
function sample_exists_code() {
echo '<script type="text/javascript" src="'. CONSTANTS_JS .'/jquery.js"></script>'."\n";
echo '<script type="text/javascript" src="'. CONSTANTS_JS .'/jquery-ui.js"></script>'."\n";
}
add_action('admin_head', 'sample_exists_code');
and this code working fine to load the UI tabs.
But when I try use this code and it’s not working
function sample_exists_code() {
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-tabs');
}
add_action('admin_head', 'sample_exists_code');
Let me know the correct way to call the existing scripts.
Update :
// load existings js and template css.
function sample_admin_js_head()
{
wp_enqueue_script('jquery-ui-tabs', null, array('jquery-ui-core','jquery'), null, false);
echo '<link rel="stylesheet" type="text/css" href="' . CONSTANTS_STYLES . '/style.css" />' . "\n";
}
// load up the menu page
function sample_add_page()
{
$optionpage = add_theme_page(__('Theme Options'), __('Theme Options'), 'edit_theme_options', 'sample', 'sample_do_template');
add_action( "admin_print_scripts-$optionpage", 'sample_admin_js_head' );
}
add_action('admin_menu', 'sample_add_page');