wordpress屏蔽google字体加载

最近google貌似被和谐了,国内好多wordpress的站都卡在了google字体那里(fonts.goo…)进不去了,有的要等好久,下面就教大家一个方法来屏蔽google字体。

在你主题的文件中加上下面函数

//禁用Open Sans
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;

刷新看看是不是不用再等待了。

发表回复