wordpress很慢很慢(Google Font & avatar)解决方法
wordpress博客访问很慢,查看网络请求,有三个请求超时,一个是google字体,二个是gravatar头像连接,判断可能和“墙”有关,网上找到如下可行的解决办法。
在主题下functions.php(wwwroot/wp-content/themes/主题/functions.php)中最后加入下面代码:
特别提醒,最好先把文件做备份
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | class Disable_Google_Fonts{ public function __construct(){ add_filter('gettext_with_context',array($this,'disable_open_sans'),888,4); } public function disable_open_sans($translations,$text,$context,$domain ){ if ('Open Sans font: on or off' == $context && 'on' == $text){ $translations = 'off'; } return $translations; } } $disable_google_fonts = new Disable_Google_Fonts; function get_ssl_avatar($avatar) { $avatar = preg_replace('/.*\/avatar\/(.*)\?s=([\d]+)&.*/','<img src="https://secure.gravatar.com/avatar/$1?s=$2" class="avatar avatar-$2" height="$2" width="$2">',$avatar); return $avatar; } add_filter('get_avatar', 'get_ssl_avatar'); |
Comments are currently closed.