禁止/移除 WordPress 4.2 中前台自动加载的 emjo 脚本

禁止/移除 WordPress 4.2 中前台自动加载的 emjo 脚本

假如你升级了WordPress 最新版的4.2 版本号,查询网页源码你就会发现WordPress 会自行在载入一段用以适用emjo 神情的脚本制作(JS CSS),针对绝大多数人而言,这个是十分可有可无的作用,反倒危害载入速率。

根本原因:

脚本制作便是相近下边的编码:

  1. <script type=“text/javascript”>
  2. window._wpemojiSettings = {“baseUrl”:“http://s.w.org/images/core/emoji/72×72/”,“ext”:“.png”,“source”:{“concatemoji”:“http://devework.com/wp-includes/js/wp-emoji-release.min.js?ver=4.2”}};
  3. !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);
  4. </script>
  5. <style type=“text/css”>
  6. img.wp-smiley,
  7. img.emoji {
  8. display: inline !important;
  9. border: none !important;
  10. box-shadow: none !important;
  11. height: 1em !important;
  12. width: 1em !important;
  13. margin: 0 .07em !important;
  14. vertical-align: -0.1em !important;
  15. background: none !important;
  16. padding: 0 !important;
  17. }
  18. </style>

编码就但是多讲解了。由于WordPress 升级4.2 的一个增加作用便是适用emjo 神情,但看一部分载入源竟然是wp.org的js 文档(wp.org 有网站被封否?)针对绝大多数人而言,这个是十分可有可无的作用。

除去/删掉/严禁方式:

要严禁WordPress 在前台接待全自动载入这一段脚本制作,可以用下列方式:

1)软件法

安裝 Disable Emojis 软件:https://wordpress.org/plugins/disable-emojis/

2)编码法

立即加上下边的源码到主题风格的functions.php 文档,编码实际上便是来源于上边的软件:

  1. /**
  2. * Disable the emoji’s
  3. */
  4. function disable_emojis() {
  5. remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
  6. remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
  7. remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
  8. remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
  9. remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ );
  10. remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ );
  11. remove_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ );
  12. add_filter( ‘tiny_mce_plugins’, ‘disable_emojis_tinymce’ );
  13. }
  14. add_action( ‘init’, ‘disable_emojis’ );
  15. /**
  16. * Filter function used to remove the tinymce emoji plugin.
  17. */
  18. function disable_emojis_tinymce( $plugins ) {
  19. return array_diff$pluginsarray( ‘wpemoji’ ) );
  20. }

申明:

本文章内容转自:DeveWork (转截此文章内容仅为交流学习仅用,若有质疑请联络本网站删掉,感谢!)

本文由网友投稿或「聚码源码网」整理自网络,如转载请注明出处:https://www.jumaniu.com/915/

本站发布的内容若侵犯到您的权益,请邮件联系 zhangqy2022#yeah.net 删除,我们将及时处理!

从您进入本站开始,已表示您已同意接受本站【免责声明】中的一切条款!

本站大部分下载资源收集于网络,不保证其完整性以及安全性,请下载后自行研究。

本站资源仅供学习和交流使用,版权归原作者所有,请在下载后24小时之内自觉删除。

若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,使用者自行承担,概与本站无关。

常见问题
  • 本站所有资源解压密码为:www.jumaniu.com 或 www.tdji.cn
查看详情

相关文章

评论
暂无评论