禁用Google字体解决WordPress后台访问速度慢的问题

WordPress

大家都提到新版本的WordPress的后台访问速度非常慢,使用开发工具最后发现元凶是后台加入了Google字体的原因,由于Google被GFW的拦截导致WordPress一直加载Google导致后台访问速度奇慢!

解决方法也非常解决,我们只需要在当前主题的文件夹下编辑functions.php文件,加入一下代码即可完成对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;

未经允许不得转载:王超博客 » 禁用Google字体解决WordPress后台访问速度慢的问题

赞 (0)

评论 0

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址