WordPress4.2头部代码精简
升级到WordPress最新版本4.2,可能是自己做的主题比较简单,调用的功能少,占时还没有出现网上说的漏洞,不过网页头部多了好多代码,
<script type="text/javascript">
window._wpemojiSettings = {"baseUrl":"http:\/\/s.w.org\/images\/core\/emoji\/72x72\/","ext":".png","source":{"concatemoji":"http:\/\/localhost\/wordpress\/wp-includes\/js\/wp-emoji-release.min.js?ver=4.2.1"}};
!function(a,b,c){function d(a){var c=b.createElement("canvas"),d=c.getContext&&c.getContext("2d");return d&&d.fillText?(d.textBaseline="top",d.font="600 32px Arial","flag"===a?(d.fillText(String.fromCharCode(55356,56812,55356,56807),0,0),c.toDataURL().length>3e3):(d.fillText(String.fromCharCode(55357,56835),0,0),0!==d.getImageData(16,16,1,1).data[0])):!1}function e(a){var c=b.createElement("script");c.src=a,c.type="text/javascript",b.getElementsByTagName("head")[0].appendChild(c)}var f;c.supports={simple:d("simple"),flag:d("flag")},c.supports.simple&&c.supports.flag||(f=c.source||{},f.concatemoji?e(f.concatemoji):f.wpemoji&&f.twemoji&&(e(f.twemoji),e(f.wpemoji)))}(window,document,window._wpemojiSettings);
</script>
<style type="text/css">
img.wp-smiley,
img.emoji {
display: inline !important;
border: none !important;
box-shadow: none !important;
height: 1em !important;
width: 1em !important;
margin: 0 .07em !important;
vertical-align: -0.1em !important;
background: none !important;
padding: 0 !important;
}
</style>
据说这些是定义表情的。占时不知道怎么用,也不想用,屏蔽之。在functions.php中添加如下两行代码
remove_action( 'wp_head','print_emoji_detection_script',7); //解决4.2版本部分主题大量404请求 remove_action( 'wp_print_styles', 'print_emoji_styles' ); //移除4.2版本前台表情样式钩子
移除头部其他代码方法:删除WordPress标签中的多余代码
本文要感谢张戈博客的分享http://zhangge.net/5034.html,收藏备用。
