我目前正在将HTML模板重写为Wordpress主题。它有很多代码依赖性,我想知道这是否是添加它的正确、最有效的方法。此代码列在“我的函数”中。php文件。
//Load Javascript
if (!is_admin()) add_action("wp_enqueue_scripts", "my_scripts");
function my_scripts() {
wp_register_script(\'easytabs\', get_template_directory_uri() . \'/js/jquery.easytabs.min.js\', array(\'jquery\'), null, true);
wp_register_script(\'respond\', get_template_directory_uri() . \'/js/respond.min.js\', false, null, true);
wp_register_script(\'adipoli\', get_template_directory_uri() . \'/js/jquery.adipoli.min.js\', array(\'jquery\'), null, true);
wp_register_script(\'fancybox\', get_template_directory_uri() . \'/js/jquery.fancybox-1.3.4.pack.js\', array(\'jquery\'), null, true);
wp_register_script(\'isotope\', get_template_directory_uri() . \'/js/jquery.isotope.min.js\', array(\'jquery\'), null, true);
wp_register_script(\'gmaps_google\', "http" . ($_SERVER[\'SERVER_PORT\'] == 443 ? "s" : "") . "://maps.google.com/maps/api/js?sensor=false", false, null, true);
wp_register_script(\'gmap\', get_template_directory_uri() . \'/js/jquery.gmap.min.js\', array(\'gmaps_google\'), null, true);
wp_register_script(\'custom\', get_template_directory_uri() . \'/js/custom.js\', array(\'gmap\'), null, true);
wp_enqueue_script(\'jquery\');
wp_enqueue_script(\'easytabs\');
wp_enqueue_script(\'respond\');
wp_enqueue_script(\'adipoli\');
wp_enqueue_script(\'fancybox\');
wp_enqueue_script(\'isotope\');
wp_enqueue_script(\'gmaps_google\');
wp_enqueue_script(\'gmap\');
wp_enqueue_script(\'custom\');
}