之前WordPress博客后台加载太慢,并且如果操作太频繁就会出现502,如下图:

后来经过网上搜索,结果是因为谷歌的字体访问不了导致的前端、后台加载太慢。有什么方法可以去除呢?
这有两种方法:
一、插件:
Disable Google Fonts:
看名字就知道了,这是一个关闭Google字体的插件,使用非常简单,只需要启用就行了,不需要设置。

二、代码修改
这里,需要两个步骤解决Google字体的问题。
第一步:
在当前使用的主题的function.php中添加一个函数禁用:
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;
第二步:
打开/wp-includes/script-loader.php搜索fonts.googleapis.com找到代码位置,直接把//fonts.googleapis.com/…这个链接所在的这行整个删掉即可。
评论