移除WordPress头部冗余无用的代码

网站APP 5 年前 2条评论

, ,

感谢: 皇家元林 投稿 。

代码来自于网络收集。

/*********************************************移除WordPress头部无用代码 开始***********************************************/
//移除WordPress Emoji 开始

remove_action( 'admin_print_scripts' , 'print_emoji_detection_script');

remove_action( 'admin_print_styles' , 'print_emoji_styles');

remove_action( 'wp_head' , 'print_emoji_detection_script', 7);

remove_action( 'wp_print_styles' , 'print_emoji_styles');

remove_filter( 'the_content_feed' , 'wp_staticize_emoji');

remove_filter( 'comment_text_rss' , 'wp_staticize_emoji');

remove_filter( 'wp_mail' , 'wp_staticize_emoji_for_email');

add_filter( 'emoji_svg_url', function(){ return false; } );                         //禁用emoji预解析

//移除WordPress Emoji 结束

remove_action('wp_head','wp_generator');                                          //禁止在head泄露WordPress版本号

remove_action('wp_head', 'rsd_link');                                            //removes EditURI/RSD (Really Simple Discovery) link.

remove_action('wp_head', 'wlwmanifest_link');                                   //removes wlwmanifest (Windows Live Writer) link.

remove_action('wp_head', 'wp_shortlink_wp_head');                              //removes shortlink.

remove_action( 'wp_head', 'feed_links', 2 );                                  //removes feed links.

remove_action('wp_head', 'feed_links_extra', 3 );                            //removes comments feed.

add_filter('rest_enabled', '__return_false');                               //禁用REST API功能代码

add_filter('rest_jsonp_enabled', '__return_false');                        //禁用REST API功能代码

remove_action('wp_head', 'adjacent_posts_rel_link_wp_head');              //移除头部Previous 和 Next 文章链接

remove_action( 'wp_head', 'rel_canonical' );                             //移除本页页面链接URL

remove_action( 'wp_head', 'wp_resource_hints', 2 );                     //去除头部的<link rel=’dns-prefetch’ href=’//s.w.org’ />

remove_action( 'wp_head', 'rest_output_link_wp_head', 10 );            //移除wp-json链接的代码

remove_action( 'wp_head', 'wp_oembed_add_discovery_links', 10 );      //移除wp-json链接的代码

/*********************************************移除WordPress头部无用代码 结束***********************************************/
支付宝打赏微信打赏

如果此文对你有帮助,欢迎打赏作者。

2条评论

  1. #1
    YiPlus

    YiPlus

    3年前 Google Chrome 88 Windows 10 -@

    你好 看到你们网站有关于WordPress的内容,我这边有一篇关于WordPress服务器加速的文章,可以放到你们网站吗
    https://shimo.im/docs/Dp6V3yCKjygRHttq/ 《wordpress国内网速慢加速及防DDOS攻击快速CF切换教程》

    来自VolumeDrive股份有限公司
    • 皇家元林

      皇家元林

      3年前 Firefox 86 Windows 10 -@

      @YiPlus 抱歉 很久没登录这个网站了,才看到你的评论
      本站欢迎投稿!你可以点导航上的投稿进行投稿!,或者把文章发我邮箱!注意注明版权来源!

      来自安徽

发表评论

欢迎回来 (打开)

(必填)