![]() |
wordpress 优化wp_head()
所谓优化wp_head()就是把从wp_head中移除不需要元素,同时也可以加快速度。
步骤: 加入到function.php remove_action('wp_head', 'wp_generator'); //wp-generator移除wordpress的版本号,本身blog的版本号没什么意义,但是如果让恶意玩家看到,可能会用官网公布的漏洞攻击blog remove_action('wp_head', 'wlwmanifest_link'); //wlwmanifest_link移除wlwmanifest相关信息 remove_action('wp_head','rsd_link'); //rsd_link移除XML-RPC 说明:wlwmanifest_link和rsd_link是为了去除这两行代码: <link rel="EditURI" type="application/rsd+xml" title="RSD" href="http://www.x.com/xmlrpc.php?rsd" /> <link rel="wlwmanifest" type="application/wlwmanifest+xml" href="http://www.x.com/wp-includes/wlwmanifest.xml" /> 这两行标记都是针对Blog的离线编辑器开放接口所使用的。其中RSD是一个广义的接口,wlwmanifest是针对微软Live Writer编辑器的。有了这两个接口,在使用离线编辑器撰写博客的时候,就可以直接在软件中选择分类,标签等等内容了。如果你不需要离线编辑,却又认为开放的两个接口不够安全,那么就可以禁用掉RSD和wlwmanifest: 加入到header.php的wp_head();上一行(上面的也可以直接放在这个地方) wp_deregister_script('jquery'); 在wp_head();前边加上wp_deregister_script主要作用是去除默认调用的jquery,这个只能在头部文件使用注销默认的调用js文件。去除之后,可以用google的jquery库,减少自身服务器的负担。 方法:在head.php或footer.php文件中(本博在footer.php中)加入 <script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js” type=”text/javascript”></script> |
| All times are GMT +8. The time now is 07:25 AM. |
Powered by vBulletin Version 3.8.7
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.