随身笔记
随身笔记

wordpress教程优化加速禁用一些无用的功能

WordPress程序功能齐全已经深入人心,但是一些我们用不到的功能可以禁用掉以免数据库过于臃肿,导致网站访问和进入后台过慢,我们这里将以下代码增加到functions.php文件中:

[code]//禁用l10n.js
wp_deregister_script(‘l10n’);
//移除管理员工具条(或:后台也有设置项)
remove_action(‘init’,’wp_admin_bar_init’);
//禁用自动保存草稿
wp_deregister_script(‘autosave’);
//禁用修改历史记录
remove_action(‘pre_post_update’,’wp_save_post_revision’);
//禁止在head泄露wordpress版本号
remove_action(‘wp_head’,’wp_generator’);
//移除head中的rel=”EditURI”
remove_action(‘wp_head’,’rsd_link’);
//移除head中的rel=”wlwmanifest”
remove_action(‘wp_head’,’wlwmanifest_link’);
//禁止半角符号自动变全角
foreach(array(‘comment_text’,’the_content’,’the_excerpt’,’the_title’) as $xx)
remove_filter($xx,’wptexturize’);
//禁止自动给文章段落添加<p>标签
remove_filter(‘the_content’,’wpautop’);
remove_filter(‘the_excerpt’,’wpautop’);
//禁止自动把’Wordpress’之类的变成’WordPress’
remove_filter(‘comment_text’,’capital_P_dangit’,31);
remove_filter(‘the_content’,’capital_P_dangit’,11);
remove_filter(‘the_title’,’capital_P_dangit’,11);
//评论跳转链接添加nofollow
function nofollow_compopup_link(){
return’ rel=”nofollow”‘;
}
add_filter(‘comments_popup_link_attributes’,’nofollow_compopup_link’);
/*回复某人链接添加nofollow
这个理应是原生的, 可是在wp某次改版后被改动了,
现在是仅当开启注册回复时才有nofollow,否则需要自己手动了*/
function nofollow_comreply_link($link){
return str_replace(‘<a’,'<a rel=”nofollow”‘,$link);
}
get_option(‘comment_registration’)||
add_filter(‘comment_reply_link’,’nofollow_comreply_link’);[/code]
以上禁用你不需的即可。

没有标签
首页      前端资源      wordpress教程      wordpress教程优化加速禁用一些无用的功能

随身笔记

wordpress教程优化加速禁用一些无用的功能
Wordpress程序功能齐全已经深入人心,但是一些我们用不到的功能可以禁用掉以免数据库过于臃肿,导致网站访问和进入后台过慢,我们这里将以下代码增加到functions.php文件中: [code]//…
扫描二维码继续阅读
2013-03-26