Worepress模板引用了google字体,由于google被墙,一直显示fonts.googleapis.com加载中,导致站点打开速度特别慢,下面讲解如何快速禁用谷歌的字体。
在主题的functions.php里面加入下面的代码:
————代码区begin—————-
//禁用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;
————代码区end—————-