拿到群晖的synology 214play,装上package center自带的wordpress,访问速度奇慢无比,据说是因为加载了Google fonts的关系,你懂的!
下面提供wordpress不加载Google fonts的几种办法,希望能够对站长朋友们有所帮助。
第一种方法:安装Disable Google Font插件,但经过测试之后,没有明显效果。(不推荐)
第二种方法:注释或删除掉style.css和function.php有关加载Google字体的代码fonts.googleapis.com即可。
第三种方法:将以下代码添加到主题目录下的functions.php中,小z博客亲测有效。(推荐)
如果在更改style.css或function.php文件之后,wordpress网站报错,无法打开,或者新建文章时上传图片失败。一定是将wordpress文件的编码保存为非ANSI编码,用记事本打开,保存时选择编码ANSI替换掉原来的文件即可。
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;