删除内置于购买的WordPress主题中的不需要的Addthis插件?

时间:2013-02-21 22:36:46

标签: javascript php wordpress wordpress-theming

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

<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;
    }

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

1 个答案:

答案 0 :(得分:0)

OP在评论中回答:

通过更改

修复

<?php wp_footer() ?>

<?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