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

WordPress 教程:WordPress 4.2后 頭部多出的Emoji表情的處理方法

2018-07-21 wordpress經驗
  • 文章介紹
  • 快速入門
  • 評價&建議

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

我們有兩種解決方法:啟用或禁用。

原因分析

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

  1. <script?type=“text/javascript”>
  2. “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. ?<style?type=“text/css”>
  5. ?img.emoji?{
  6. ?border:?none?!important;
  7. ?height:?1em?!important;
  8. ?margin:?0?.07em?!important;
  9. ?background:?none?!important;
  10. ?}
  11. functions.php 文件中:
    1. function?disable_emojis()?{
    2. ?remove_action(?‘wp_head’,?‘print_emoji_detection_script’,?7?);
  12. ?remove_action(?‘wp_print_styles’,?‘print_emoji_styles’?);
  13. ?remove_filter(?‘the_content_feed’,?‘wp_staticize_emoji’?);
  14. ?remove_filter(?‘wp_mail’,?‘wp_staticize_emoji_for_email’?);
  15. ?}
  16. function?disable_emojis_tinymce(?$plugins?)?{
  17. ?if?(?is_array(?$plugins?)?)?{
  18. return?array_diff(?$plugins,?array(?‘wpemoji’?)?);
  19. ?}?else?{
  20. return?array();
  21. ?}
  22. Twitter Emoji 表情包下載,下載后直接解壓至主題目錄,文件夾名不變。將以下代碼放在主題目錄下的 functions.php 文件中:
    1. function?smilies_reset()?{
    2. ?global?$wpsmiliestrans,?$wp_smiliessearch;
    3. ?if?(!get_option(‘use_smilies’))?{
    4. return;
    5. ?}
    6. $wpsmiliestrans_fixed?=?array(
    7. ?‘:mrgreen:’?=>?“xf0x9fx98xa2”,
    8. “xf0x9fx98xa3”,

  23. ?‘:roll:’?=>?“xf0x9fx98xa4”,
  24. “xf0x9fx98xa6”,

  25. ?‘:arrow:’?=>?“xf0x9fx98x83”,
  26. “xf0x9fx98x82”,

  27. ?‘:-)’?=>?“xf0x9fx98x81”,
  28. “xf0x9fx98xa7”,

  29. ?‘:)’?=>?“xf0x9fx98xa8”,
  30. “xf0x9fx98x84”,

  31. ?‘:!:’?=>?“xf0x9fx98x85”,
  32. ?$wpsmiliestrans?=?array_merge($wpsmiliestrans,?$wpsmiliestrans_fixed);
  33. ?
  34. function?static_emoji_url()?{
  35. ?return?get_bloginfo(‘template_directory’).’/72×72/’;
  36. ?
  37. function?reset_emojis()?{
  38. ?remove_action(‘wp_head’,?‘print_emoji_detection_script’,?7);
  39. ?remove_action(‘wp_print_styles’,?‘print_emoji_styles’);
  40. ?add_filter(‘the_content’,?‘wp_staticize_emoji’);
  41. ?smilies_reset();
  42. ?}
  43. ?
  44. function?fa_get_wpsmiliestrans(){
  45. ?global?$wpsmiliestrans;
  46. $wpsmilies?=?array_unique($wpsmiliestrans);
  47. ?foreach($wpsmilies?as?$alt?=>?$src_path){
  48. $emoji?=?str_replace(array(‘&#x’,?‘;’),?,?wp_encode_emoji($src_path));
  49. ?$output?.=?‘<a?class=“add-smily”?data-smilies=“‘.$alt.'”><img?class=“wp-smiley”?src=“‘.get_bloginfo(‘template_directory’).’/72×72/’.?$emoji?.’png”?/></a>’;
  50. ?return?$output;
  51. ?}

0 0

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

正版主題商店

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

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

服務熱線

wordpress建站咨詢