0

我正在为客户定制网站主题。当我去运行速度测试时,我注意到这段代码

<script type='text/javascript' src='http://s7.addthis.com/js/250/addthis_widget.js?domready=1&#038;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;
    }

页脚.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&#038;ver=1'></script>
    ...
    <!-- footer what?! END -->
4

1 回答 1

0

Answered by OP in comments:

Fixed by changing

<?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'>‌​&lt;/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

于 2013-02-22T21:08:49.690 回答