2014-6-2更新:近来谷歌的字体服务异常不稳定,WordPress也因为这个后台加载至少要20s。特殊时期特殊处理,刚开始以为是服务器问题,仔细分析,是载入字体的时候延时,于是就用开发者工具查看了一下,原来字体使用的是Google Fonts Open Sans,在国内访问不稳定所以会延时,解决方法很简单:
直接添加到主题的functions.php中即可禁用后台Open Sans:
//禁用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;
附官方Twenty系列主题去除代码:
class Disable_Google_Fonts { public function __construct() { add_filter( 'gettext_with_context', array( $this, 'disable_open_sans' ), 888, 4 ); add_action( 'after_setup_theme', array( $this, 'register_theme_fonts_disabler' ), 1 ); } public function disable_open_sans( $translations, $text, $context, $domain ) { if ( 'Open Sans font: on or off' == $context && 'on' == $text ) { $translations = 'off'; } return $translations; } public function disable_lato( $translations, $text, $context, $domain ) { if ( 'Lato font: on or off' == $context && 'on' == $text ) { $translations = 'off'; } return $translations; } public function disable_source_sans_pro( $translations, $text, $context, $domain ) { if ( 'Source Sans Pro font: on or off' == $context && 'on' == $text ) { $translations = 'off'; } return $translations; } public function disable_bitter( $translations, $text, $context, $domain ) { if ( 'Bitter font: on or off' == $context && 'on' == $text ) { $translations = 'off'; } return $translations; } public function register_theme_fonts_disabler() { $template = get_template(); switch ( $template ) { case 'twentyfourteen' : add_filter( 'gettext_with_context', array( $this, 'disable_lato' ), 888, 4 ); break; case 'twentythirteen' : add_filter( 'gettext_with_context', array( $this, 'disable_source_sans_pro' ), 888, 4 ); add_filter( 'gettext_with_context', array( $this, 'disable_bitter' ), 888, 4 ); break; } } } $disable_google_fonts = new Disable_Google_Fonts;
前台
使用360加速节点,将主题文件中出现的所有fonts.googleapis.com字样替换为fonts.useso.com
可不可以把他字体文件搬到七牛的。。。。。。。
@极雪 可以滴
@WP酷 好吗,来一发,不过我要上学了
@极雪 我研究下……还不知道怎么做
@WP酷 发现禁用之后打开字体好难看 有什么解决方案吗
@青互联 有一种就是在后台设置什么的CSS里加上* {font-family: Microsoft YaHei;}
@WP酷 style.css文件? 好像没什么用呢
@青互联 不不,比如说去/wp-content/languages/zh_CN-administration-screens.css这个文件添加
这个不错,我也感觉到慢了,要试试
后台每次都要等待刷新,当时第一时间去掉了。
七牛现在越来越出名了,到处都在说
前台应该没使用这个字体吧,禁用后会变难看吗
@Giuem 后台使用,确实会变难看,可以考虑转存字体
试试看
学习了!
昨天用这个代码没什么效果- -~ 后来还是用插件解决了···
@Uncle.E =-=||我这里一加上速度飞起
后台搜索安装这两个插件就好了 Remove Open Sans font from WP core | Disable Google Fonts
使用360加速节点,将主题文件中出现的所有fonts.useso.com字样替换为fonts.useso.com
是不是打错了。这句话
@Faris ……我的天……因为我也启用了自己做的批量替换插件,现在搞的连文章内出现的googleapis.com都会替换为useso.com