wordpress是国外开源项目,由于众所周知的原因,wordpress源码里面加载的google字体无法访问google服务器,导致网站打开非常慢,wordpress如何禁用google字体提高加载速度呢?
最简单的一种禁用方法,就是安装插件Disable Google Fonts
如果不喜欢安装插件,以下代码添加到当前主题functions.php中。
1 2 3 4 5 6 7 8 9 10 11 12 | 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; |