我正在为客户定制网站主题。当我去进行速度测试时, 我注意到这段代码
<script type='text/javascript' src='http://s7.addthis.com/js/250/addthis_widget.js?domready=1&ver=1'></script>
正在创建数十个重定向到垃圾邮件区域的重定向。它仅存在于主页上, 而不存在于其他任何页面上。 Addthis插件似乎已内置到主题中, 我无法找到将其删除的位置。我不想为不需要的插件牺牲速度。
我检查了footer.php文件, 然后检查functions.php, 然后依次检查了主题中可以调用此文件的每个文件。我使用Dreamweaver在主题的整个文件夹中搜索包含该代码的任何文档, 而Dreamweaver却一无所获。如果我激活一个不同的主题, 代码就会消失, 所以我知道它就是主题。我就是不知道怎么做!
有人知道我应该在哪里/寻找什么吗?我到处都在寻找答案, 却一直找不到。可能是由javascript文件引起的吗?还是加密的PHP?
希望对你有帮助:
主题是Mercor, 它是WooCommerce就绪的主题。这是演示页面:http://mercor.premiumcoding.com/。你可以在1369行附近看到有问题的代码段。
functions.php中的页脚:
function footer(){
function pmc_recent_footer_excerpt_length( $length ) {
return 40;
}
function pmc_recent_footer_title($title) { return substr($title, 0, 40). '';}
add_filter( 'excerpt_length', 'pmc_recent_footer_excerpt_length', 999 );
add_filter('the_title', 'pmc_recent_footer_title') ;
}
如果我删除了整个代码段, 那么有害的代码和整个页脚就会消失。我试图删除括号内的所有内容, 例如:
function footer(){
}
但是仍然显示出令人反感的代码。
同样在functions.php中-但删除无济于事
function socialLinkCat($link, $title, $email) {
$social = '';
$social .='<div class="addthis_toolbox"><div class="custom_images">';
global $data;
if($data['facebook_show'] == 1)
$social .= '<a class="addthis_button_facebook" addthis:url="'.$link.'" addthis:title="'.$title.'" title="'.$data['translation_facebook'].'"><img src="'. get_template_directory_uri() .'/images/facebookIcon.png" width="64" height="64" border="0" alt="'.$data['translation_facebook'].'" /></a>';
if($data['twitter_show'] == 1)
$social .= '<a class="addthis_button_twitter" addthis:url="'.$link.'" addthis:title="A'.$title.'" title="'.$data['translation_twitter'].'"><img src="'. get_template_directory_uri() .'/images/twitterIcon.png" width="64" height="64" border="0" alt="'.$data['translation_twitter'].'" /></a>';
if($data['digg_show'] == 1)
$social .= '<a class="addthis_button_digg" addthis:url="'.$link.'" addthis:title="'.$title.'" title="'.$data['translation_digg'].'"><img src="'. get_template_directory_uri() .'/images/diggIcon.png" width="64" height="64" border="0" alt="'.$data['translation_digg'].'" /></a>';
if($data['stumble_show'] == 1)
$social .= '<a class="addthis_button_stumble" addthis:url="'.$link.'" addthis:title="'.$title.'" title="'.$data['translation_stumble'].'"><img src="'. get_template_directory_uri() .'/images/stumbleUponIcon.png" width="64" height="64" border="0" alt="Share to Stumble Upon" /></a>';
$social .='<a class="addthis_button" addthis:url="'.$link.'" addthis:title="'.$title.'" ><img src="'. get_template_directory_uri() .'/images/socialIconShareMore.png" width="64" height="64" border="0" alt="More..." /></a></div><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f3049381724ac5b"></script>';
if($data['email_show'] == 1 && $email)
$social .= '<a class="emaillink" href="mailto:'.$data['email'].'" title="'.$data['translation_email'].'"></a></div>';
$social .= '</div>';
echo $social;
}
function socialLinkProduct() {
$social = '';
$social ='<div class="addthis_toolbox"><div class="custom_images">';
global $data;
if($data['facebook_show'] == 1)
$social .= '<a class="addthis_button_facebook" title="'.$data['translation_facebook'].'"><img src="'. get_template_directory_uri() .'/images/icon-facebook-product-single.png" width="16" height="16" border="0" alt="'.$data['translation_facebook'].'" /></a>';
if($data['twitter_show'] == 1)
$social .= '<a class="addthis_button_twitter" title="'.$data['translation_twitter'].'"><img src="'. get_template_directory_uri() .'/images/icon-twitter-product-single.png" width="16" height="16" border="0" alt="'.$data['translation_twitter'].'" /></a>';
//if($data['digg_show'] == 1)
//$social .= '<a class="addthis_button_digg" title="'.$data['translation_digg'].'"><img src="'. get_template_directory_uri() .'/images/diggIcon.png" width="64" height="64" border="0" alt="'.$data['translation_digg'].'" /></a>';
//if($data['youtube_show'] == 1)
//$social .= '<div><a class="addthis_button_youtube"><img src="'. get_template_directory_uri() .'/images/diggIcon.png" width="64" height="64" border="0" alt="Share to Twitter" /></div></a></div>';
$social .='<a class="addthis_button_more"><img src="'. get_template_directory_uri() .'/images/icon-more-product-single.png" width="16" height="16" border="0" alt="More..." /></a></div><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f3049381724ac5b"></script>';
if($data['email_show'] == 1)
$social .= '<a class="emaillink" href="mailto:'.$data['email'].'" title="'.$data['translation_email'].'"></a></div>';
echo $social;
}
function socialLinkSingle() {
$social = '';
$social ='<div class="addthis_toolbox"><div class="custom_images">';
global $data;
if($data['facebook_show'] == 1)
$social .= '<a class="addthis_button_facebook" title="'.$data['translation_facebook'].'"><img src="'. get_template_directory_uri() .'/images/facebookIcon.png" width="64" height="64" border="0" alt="'.$data['translation_facebook'].'" /></a>';
if($data['twitter_show'] == 1)
$social .= '<a class="addthis_button_twitter" title="'.$data['translation_twitter'].'"><img src="'. get_template_directory_uri() .'/images/twitterIcon.png" width="64" height="64" border="0" alt="'.$data['translation_twitter'].'" /></a>';
//if($data['digg_show'] == 1)
//$social .= '<a class="addthis_button_digg" title="'.$data['translation_digg'].'"><img src="'. get_template_directory_uri() .'/images/diggIcon.png" width="64" height="64" border="0" alt="'.$data['translation_digg'].'" /></a>';
//if($data['youtube_show'] == 1)
//$social .= '<div><a class="addthis_button_youtube"><img src="'. get_template_directory_uri() .'/images/diggIcon.png" width="64" height="64" border="0" alt="Share to Twitter" /></div></a></div>';
$social .='<a class="addthis_button_more"><img src="'. get_template_directory_uri() .'/images/socialIconShareMore.png" width="64" height="64" border="0" alt="More..." /></a></div><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#pubid=xa-4f3049381724ac5b"></script>';
if($data['email_show'] == 1)
$social .= '<a class="emaillink" href="mailto:'.$data['email'].'" title="'.$data['translation_email'].'"></a></div>';
echo $social;
}
footer.php文件
<!-- footerwhat -->
<?php wp_footer(); ?>
<!-- footerwhat -->
主页上生成的额外代码行(” …”指的是wp_footer()添加的预期代码)
</footer>
<!-- footer what?! END -->
...
<script type='text/javascript' src='http://s7.addthis.com/js/250/addthis_widget.js?domready=1&ver=1'></script>
...
<!-- footer what?! END -->
#1
OP在评论中回答:
通过更改固定
<?php wp_footer()?>
to
<?php
if (is_home() || is_front_page() ) {
remove_action('wp_footer', 'output_inline_js');
wp_admin_bar_render();
echo "<script type='text/javascript' src='http://yoursite.com/wp-content/themes/mercor/js/gistfile_pmc.js?ver=3.5.1'></script>
<script type='text/javascript' src='http://yoursite.com/wp-content/plugins/woocommerce/assets/js/jquery-plugins.min.js?ver=1.6.6'></script>
<script type='text/javascript' src='http://yoursite.com/wp-content/plugins/woocommerce/assets/js/frontend/woocommerce.min.js?ver=1.6.6'></script>";
}
else {
wp_footer();
}
?>
– mulysasasylum
评论前必须登录!
注册