我试图在wordpress子主题中重新声明父主题已经在使用的函数。但是,在尝试执行此操作时,我收到一条“致命错误:无法重新声明”消息。
此外,我尝试使用以下方法,但没有成功:
if (!function_exists(\'jr_load_scripts\')) {
// do fancy things here...
}
这是
the link 如果您想快速查看。。。
EDIT: 以下是完整代码:
if (!function_exists(\'jr_load_scripts\')) {
function jr_load_scripts() {
global $app_abbr;
$http = (is_ssl()) ? \'https\' : \'http\';
// load google cdn hosted scripts if enabled
if (get_option($app_abbr.\'_google_jquery\') == \'yes\') :
wp_deregister_script(\'jquery\');
wp_register_script(\'jquery\', (\'\'.$http.\'://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js\'), false, \'1.4.2\');
wp_register_script(\'jquery-ui-custom\', \'\'.$http.\'://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js\', false, \'1.8\');
else :
wp_register_script(\'jquery-ui-custom\', get_bloginfo(\'template_directory\').\'/includes/js/jquery-ui-1.8.custom.min.js\', false, \'1.8\');
endif;
wp_enqueue_script(\'jquery\');
wp_enqueue_script(\'jquery-ui-custom\');
wp_enqueue_script(\'jquery-tag\', get_bloginfo(\'template_directory\').\'/includes/js/jquery.tag.js\', array(\'jquery\'), \'\');
wp_enqueue_script(\'smoothscroll\', get_bloginfo(\'template_directory\').\'/includes/js/smoothscroll.js\', array(\'jquery\'), \'\');
wp_enqueue_script(\'lazyload\', get_bloginfo(\'template_directory\').\'/includes/js/jquery.lazyload.mini.js\', array(\'jquery\'), \'1.5.0\');
wp_enqueue_script(\'elastic\', get_bloginfo(\'template_directory\').\'/includes/js/jquery.elastic.js\', array(\'jquery\'), \'1.0\');
wp_enqueue_script(\'fancybox\', get_bloginfo(\'template_directory\').\'/includes/js/jquery.fancybox-1.3.4.pack.js\', array(\'jquery\'), \'1.3.4\');
wp_enqueue_script(\'qtip\', get_bloginfo(\'template_directory\').\'/includes/js/jquery.qtip.min.js\', array(\'jquery\'), \'1.0.0-rc3\');
wp_enqueue_script(\'general\', get_bloginfo(\'template_directory\').\'/includes/js/theme-scripts.js\', array(\'jquery\'), \'3.0\');
$jr_enable_indeed_feeds = get_option(\'jr_enable_indeed_feeds\');
if ($jr_enable_indeed_feeds==\'yes\') :
wp_enqueue_script(\'indeed-api\', \'\'.$http.\'://www.indeed.com/ads/apiresults.js\');
endif;
}