..start..fly..

扫一扫
Guestbook

Home / PHP & Wordpress / wordpress升级后加载缓慢s.w.org

<< SQL数据库替换命令普外科医师之元宵灯谜 看你能猜对几个 >>

更新wordpress4.4后,网站首页加载速度明显减慢,在浏览器的加载项里发现总是在加载s.w.org而导致网站打开缓慢。百度了一下发现是因为4.2的版本中添加了表情功能后加载的脚本。这个表情功能对多数人来说基本上没有用,反而拖累了网站速度。于是乎,百度到了一段代码就简单的解决了这个问题,需要的朋友们不妨试试。

将以下代码直接添加到主题的functions.php文件中即可去除该脚本!(后台——外观——编辑——functions.php),保持后首页明显提速。

  1. function disable_emoji9s_tinymce( $plugins ) {
  2.  if ( is_array( $plugins ) ) {
  3.  return array_diff( $plugins, array( ‘wpemoji’ ) );
  4.  } else {
  5.  return array();
  6.  }
  7. }
  8. function remove_emoji9s() {
  9.  remove_action( ‘wp_head’, ‘print_emoji_detection_script’, 7 );
  10.  remove_action( ‘admin_print_scripts’, ‘print_emoji_detection_script’ );
  11.  remove_action( ‘wp_print_styles’, ‘print_emoji_styles’ );
  12.  remove_action( ‘admin_print_styles’, ‘print_emoji_styles’ );
  13.  remove_filter( ‘the_content_feed’, ‘wp_staticize_emoji’ );
  14.  remove_filter( ‘comment_text_rss’, ‘wp_staticize_emoji’ );
  15.  remove_filter( ‘wp_mail’, ‘wp_staticize_emoji_for_email’ );
  16.  add_filter( ‘tiny_mce_plugins’, ‘disable_emoji9s_tinymce’ );
  17. }
  18. add_action( ‘init’, ‘remove_emoji9s’ );
  19. function custom_smilie9s_src( $old, $img ) {
  20.     return get_stylesheet_directory_uri().’/images/smilies/’.$img;
  21. }
  22. function init_smilie9s(){
  23.  global $wpsmiliestrans;
  24.  //默认表情文本与表情图片的对应关系(可自定义修改)
  25.  $wpsmiliestrans = array(
  26.  ‘:mrgreen:’ => ‘icon_mrgreen.gif’,
  27.  ‘:neutral:’ => ‘icon_neutral.gif’,
  28.  ‘:twisted:’ => ‘icon_twisted.gif’,
  29.    ‘:arrow:’ => ‘icon_arrow.gif’,
  30.    ‘:shock:’ => ‘icon_eek.gif’,
  31.    ‘:smile:’ => ‘icon_smile.gif’,
  32.      ‘:???:’ => ‘icon_confused.gif’,
  33.     ‘:cool:’ => ‘icon_cool.gif’,
  34.     ‘:evil:’ => ‘icon_evil.gif’,
  35.     ‘:grin:’ => ‘icon_biggrin.gif’,
  36.     ‘:idea:’ => ‘icon_idea.gif’,
  37.     ‘:oops:’ => ‘icon_redface.gif’,
  38.     ‘:razz:’ => ‘icon_razz.gif’,
  39.     ‘:roll:’ => ‘icon_rolleyes.gif’,
  40.     ‘:wink:’ => ‘icon_wink.gif’,
  41.      ‘:cry:’ => ‘icon_cry.gif’,
  42.      ‘:eek:’ => ‘icon_surprised.gif’,
  43.      ‘:lol:’ => ‘icon_lol.gif’,
  44.      ‘:mad:’ => ‘icon_mad.gif’,
  45.      ‘:sad:’ => ‘icon_sad.gif’,
  46.        ‘8-)’ => ‘icon_cool.gif’,
  47.        ‘8-O’ => ‘icon_eek.gif’,
  48.        ‘:-(‘ => ‘icon_sad.gif’,
  49.        ‘:-)’ => ‘icon_smile.gif’,
  50.        ‘:-?’ => ‘icon_confused.gif’,
  51.        ‘:-D’ => ‘icon_biggrin.gif’,
  52.        ‘:-P’ => ‘icon_razz.gif’,
  53.        ‘:-o’ => ‘icon_surprised.gif’,
  54.        ‘:-x’ => ‘icon_mad.gif’,
  55.        ‘:-|’ => ‘icon_neutral.gif’,
  56.        ‘;-)’ => ‘icon_wink.gif’,
  57.         ‘8O’ => ‘icon_eek.gif’,
  58.         ‘:(‘ => ‘icon_sad.gif’,
  59.         ‘:)’ => ‘icon_smile.gif’,
  60.         ‘:?’ => ‘icon_confused.gif’,
  61.         ‘:D’ => ‘icon_biggrin.gif’,
  62.         ‘:P’ => ‘icon_razz.gif’,
  63.         ‘:o’ => ‘icon_surprised.gif’,
  64.         ‘:x’ => ‘icon_mad.gif’,
  65.         ‘:|’ => ‘icon_neutral.gif’,
  66.         ‘;)’ => ‘icon_wink.gif’,
  67.        ‘:!:’ => ‘icon_exclaim.gif’,
  68.        ‘:?:’ => ‘icon_question.gif’,
  69.  );
  70.  //移除WordPress4.2版本更新所带来的Emoji前后台钩子同时挂上主题自带的表情路径
  71.  remove_action( ‘wp_head’ , ‘print_emoji_detection_script’, 7 );
  72.  remove_action( ‘admin_print_scripts’ , ‘print_emoji_detection_script’ );
  73.  remove_action( ‘wp_print_styles’ , ‘print_emoji_styles’ );
  74.  remove_action( ‘admin_print_styles’ , ‘print_emoji_styles’ );
  75.  remove_filter( ‘the_content_feed’ , ‘wp_staticize_emoji’ );
  76.  remove_filter( ‘comment_text_rss’ , ‘wp_staticize_emoji’ );
  77.  remove_filter( ‘wp_mail’ , ‘wp_staticize_emoji_for_email’ );
  78.  add_filter( ‘tiny_mce_plugins’ , ‘disable_emoji9s_tinymce’ );
  79.  add_filter( ‘smilies_src’ , ‘custom_smilie9s_src’ , 10 , 2 );
  80. }
  81. add_action( ‘init’, ‘init_smilie9s’, 5 );
  82. //取消添加表情样式
  83. function disable_emojis_tinymce( $plugins ) {
  84.     return array_diff( $plugins, array( ‘wpemoji’ ) );
  85. }

Related Posts

转载原创文章请注明,转载自:SKY..fly..[www.sky.gs]

本文链接: https://www.sky.gs/websites/phpwordpress/wordpress-s-w-org.html

QR:  wordpress升级后加载缓慢s.w.org

Leave a Reply

Code (☆)7+10=?


Websites powered by Wordpress6.4.3 Copyright © 2009-2024 - All Rights Reserved   SKY..fly..