我正在为客户定制网站主题。当我去进行速度测试时, 我注意到这段代码
<
script type='text/javascript' src='/uploads/allimg/220531/1049443U5-0.jpg
#038;
ver=1'>
<
/script>
【删除购买的WordPress主题内置的不需要的Addthis插件()】正在创建数十个重定向到垃圾邮件区域的重定向。它仅存在于主页上, 而不存在于其他任何页面上。 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) { returnsubstr($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://img.readke.com/220531/1049441D9-6.jpg">
<
/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://img.readke.com/220531/1049441D9-6.jpg">
<
/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://img.readke.com/220531/1049441D9-6.jpg">
<
/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='/uploads/allimg/220531/1049443U5-0.jpg
#038;
ver=1'>
<
/script>
...
<
!-- footer what?! END -->
#1OP在评论中回答:
通过更改固定
< ?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/wooco??mmerce.min.js?ver=1.6.6'>
<
/script>
";
}
else {
wp_footer();
}?>
– mulysasasylum
推荐阅读
- 从自定义帖子类型中删除”密码保护”选项
- 在单个页面上删除WordPress管理栏
- 从wordpress网站中删除type=”text/javascript”
- 删除WordPress中的Post a标签
- 从buddypress个人资料页面中删除”Activity”标签
- WordPress主题中的相对图像链接
- 重新安装WordPress主题以修复错误
- 从wordpress管理员中删除仪表盘访问
- Java关键字