'http://twitter.com/parisholley',
'title' => 'Folow me on Twitter',
'img' => NHP_OPTIONS_URL.'img/glyphicons/glyphicons_322_twitter.png'
);
$args['share_icons']['linked_in'] = array(
'link' => 'http://www.linkedin.com/in/parisholley',
'title' => 'Find me on LinkedIn',
'img' => NHP_OPTIONS_URL.'img/glyphicons/glyphicons_337_linked_in.png'
);
$args['opt_name'] = 'asyncjs';
$args['menu_title'] = 'Async JS';
$args['page_title'] = 'Asynchronous Javascript';
$args['page_slug'] = 'asyncjs';
$args['show_import_export'] = false;
$args['page_position'] = 102419882;
$args['dev_mode'] = false;
$sections = array(array(
'icon' => NHP_OPTIONS_URL.'img/glyphicons/glyphicons_280_settings.png',
'title' => 'Settings',
'fields' => array(
'exclude_name' => array(
'id' => 'exclude_name',
'type' => 'textarea',
'title' => 'Exclude by Name',
'desc' => 'Enter a comma delimited list (ie: "jquery,jqueryui").',
'sub_desc' => 'The name is the key used to queue the javascript file within wordpress.'
),
'exclude_js' => array(
'id' => 'exclude_js',
'type' => 'textarea',
'title' => 'Exclude by File',
'desc' => 'Enter a comma delimited list (ie: "file1.js,file2.js").',
'sub_desc' => 'If you do not know the script key, you exclude based on the file name.'
),
'head_file' => array(
'id' => 'head_file',
'type' => 'text',
'title' => 'Select Head.js File',
'desc' => 'Enter the filename of the head.js file in the js folder.',
'sub_desc' => 'This is an advanced setting, leave it as default if you are unsure of what it does.',
'std' => self::$default_head_file
)
)
));
new NHP_Options($sections, $args);
}
/**
* Prevent wordpress from outputing scripts to page
**/
static function action_prevent_script_output() {
global $wp_scripts, $concatenate_scripts;
$concatenate_scripts = true;
$wp_scripts->do_concat = true;
}
/**
* Wordpress has no ability to hook into script queuing, so this is a work around
**/
static function filter_queue_script($src, $handle) {
global $wp_scripts;
self::$depends[$handle] = array(
'src' => $src,
'deps' => $wp_scripts->registered[$handle]->deps
);
}
/**
* Outputs headjs code in header or footer
**/
static function filter_headjs(){
$options = get_option('asyncjs');
$names = explode(',', $options['exclude_name']);
$files = explode(',', $options['exclude_js']);
if (empty($options['head_file'])){
$options['head_file'] = self::$default_head_file;
}
if(count(self::$depends) > 0){
$handles = array();
foreach(self::$depends as $handle => $depend){
$exclude = false;
foreach($files as $file){
if(!empty($file) && strpos($depend['src'], $file) !== false){
$exclude = true;
break;
}
}
$src = apply_filters('async_js_src', $depend['src']);
if(!in_array($handle, $names) && !$exclude){
$handles[] = '{"' . $handle . '": "' . $src . '"}';
}else{
echo '';
}
}
if(count($handles) > 0){
if(!self::$head_loaded){
echo '';
self::$head_loaded = true;
}
echo '';
}
self::$depends = array();
}
return false; // prevent printing of javascript
}
}
AsynchronousJS::init();
?>