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
给力!不错的文章