久青草国产观看在线视频,在线观看欧美日女,777毛片,亚洲国产精品99久久久久久久

禁止/移除 WordPress 4.2 中前臺自動加載的 emjo 腳本

2015-08-02 wordpress教程
  • 文章介紹
  • 快速入門
  • 評價&建議
emojiscreenshot

如果你更新了WordPress 最新版本的4.2 版本,查看網頁源代碼你會發現WordPress 會自動在加載一段用于支持emjo 表情的腳本(JS+CSS),對于大部分人來說,這個是十分雞肋的功能,反而影響加載速度。

原因分析:

腳本就是類似下面的代碼:

  1. <script?type="text/javascript">
  2. window._wpemojiSettings?=?{"baseUrl":"http://s.w.org/images/core/emoji/72x72/","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(?$plugins,?array(?'wpemoji'?)?);
  20. }

聲明:

本文章轉自:DeveWork (轉載此文章僅為學習交流只用,如有異議請聯系本站刪除,謝謝!)

0 0

企業建站推薦正版商業主題,國內專業團隊開發,完善售后,是您不二選擇。

正版主題商店

主題貓WP建站,累計幫助1300+客戶成功建站,為站長提供支持!

立刻開啟你的建站之旅
QQ在線客服

服務熱線

wordpress建站咨詢