今天发现变态的自动把'Wordpress'之类的变成'WordPress'。
我发布了一个连接开头是一个大写的'Wordpress'实际发布出来Press的P也变化成大写了。
这个其实是一个连接。PHP区分大小写 所以有的连接不成功。
前天天需要移除在head泄露wordpress版本号。
大前天需要禁用自动保存草稿。

<?php
  //禁用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');
?>

以上, 拣你需要的, 丢入functions.php头部即可.

» 版权所有:YaoLei's Blog » 禁用 WordPress 一些也许无用的功能函数
» 本文链接:https://www.yaolei.info/archives/41