Hey Guys,
My little theme options page is coming along nicely and really happy with it so far but I want to make it more efficient and not have my JavaScripts being included on every admin page.
My code is
if(is_admin())
{
add_action('init', 'eirestudio_scripts');
}
How would I go about including these JavaScripts just on my theme options page.
I suppose I could query the url and check for a certain string but this method seems “hacky”... Must be a better solution?
you can do it in “wordpress” way 
you can create global variable to make your theme settings page hookable..
add_action( 'admin_menu', 'prima_theme_settings_init' );
function prima_theme_settings_init() {
global $primathemes_pagehook;
$primathemes_pagehook = add_theme_page( 'Theme Settings', 'Theme Settings', 'edit_theme_options', 'primathemes', 'prima_theme_settings_page' );
add_action( "load-{$primathemes_pagehook}", 'prima_theme_settings_enqueue_script' );
}
function prima_theme_settings_page() {
// your theme settings page content here
}
function prima_theme_settings_enqueue_script() {
wp_enqueue_script('prima-admin', get_template_directory_uri() . '/js/admin.js', array('jquery'), '0.1', FALSE);
}
note: for example, we use add_theme_page function to create the theme settings page… you can also use add_menu_page or add_submenu_page in similar way… 
You could forgo the wp_enqueue and just add the script tag in the source of the theme options. Enqueue is used so that multiple versions of scripts aren’t loaded, with a custom script it shouldn’t really matter
Thanks PrimaThemes, much much appreciated 
nice read about this topic – had it bookmarked a while ago – maybe it helps:
http://www.studiograsshopper.ch/code-snippets/wordpress-current_screen-variable-admin-screens/
