. */ $js_folder = ''; $js_index = false; $js_category = false; $js_single = false; $js_page = false; function am_sjl_javascript_loader(){ global $js_folder, $js_index, $js_category, $js_single, $js_page, $wp_version; $js_folder = get_option( 'am_sjl_jsdir' ); if (empty($js_folder)) $js_folder = '/'; $js_index = get_option('am_sjl_jsindex'); $js_category = get_option('am_sjl_jscategory'); $js_single = get_option('am_sjl_jssingle'); $js_page = get_option('am_sjl_jspage'); $js_loadinfooter = false; if (!is_admin()){ if ( version_compare($wp_version,'2.8','>') ){ $js_loadinfooter = get_option('am_sjl_jsloadinfooter'); if (empty($js_loadinfooter) || $js_loadinfooter == 'false') $js_loadinfooter = false; else $js_loadinfooter = true; } if ( $js_index && is_home() ){ am_sjl_registerJsFile('index',$js_loadinfooter); } if ( $js_single && is_single() ){ am_sjl_registerJsFile('single',$js_loadinfooter); } if ( $js_category && is_category() ){ $cat_id = get_cat_id( single_cat_title("",false) ); $cat_query_var = get_query_var('cat'); $category = get_category($cat_query_var); am_sjl_registerJsFile('category',$js_loadinfooter,$category->slug); } if( $js_page && is_page() ){ global $post; am_sjl_registerJsFile('page',$js_loadinfooter,$post->post_name); } } } function am_sjl_registerJsFile( $root, $loadinfooter, $id = null){ global $js_folder, $wp_version; $rel_template_dir = get_bloginfo('template_directory'); $js_file = ""; if ( empty($id) ){ if (file_exists( TEMPLATEPATH . $js_folder . $root . '.js' )){ $js_file = $rel_template_dir . $js_folder . $root . '.js'; } } else { if (file_exists( TEMPLATEPATH . $js_folder . $root . '-' . $id . '.js' )){ $js_file = $rel_template_dir . $js_folder . $root . '-' . $id . '.js'; } else { if (file_exists( TEMPLATEPATH . $js_folder . $root . '.js' )){ $js_file = $rel_template_dir . $js_folder . $root . '.js'; } } } if ( version_compare($wp_version,'2.8','>') ) wp_enqueue_script('am_sjl_' . $root, $js_file, false, false, $loadinfooter); else wp_enqueue_script('am_sjl_' . $root, $js_file, false, false); } function am_sjl_menu() { add_options_page('Selective Javascript Loader setting', 'Selective Javascript Loader', 8, 'selective-javascript-loader', 'am_sjl_options'); } function am_sjl_options() { global $js_folder, $js_index, $js_category, $js_single,$wp_version; ?>

Selective Javascript Loader

Settings saved

') ){ ?>
Use this page to define Selective Javascript Loader settings.
OPTIONAL - Specify the theme subdir where javascript files are stored (with leading and trailing slashes).
Specify is the Javascript file should be loaded in header or footer. This will only function if your theme correctly uses wp_head() and wp_footer()
/> Load the 'index.js' JavaScript file when viewing the index page.
/> When viewing a category page the plugin will try to load the 'category-cat_slug.js' JavaScript file. If it doesn't exists the plugin will try to load the 'category.js' JavaScript file.
/> When viewing single posts, the plugin will try to load the 'single.js' JavaScript file.
/> When viewing pages, the plugin will try to load the 'page-page_slug.js' JavaScript file. If it doesn't exists the plugin will try to load the 'page.js' JavaScript file.