WordPress 如何屏蔽国外字体
wordpress吧
全部回复
仅看楼主
level 14
2014年06月01日 03点06分 1
level 14
  WordPress新版本有时会出现这个问题,就是后台操作的时候变慢了,刚开始以为是服务器问题,仔细分析,是载入字体的时候延时,于是就用开发者工具查看了一下,原来3.9版本的字体使用的是Google FontsOpen 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;
2014年06月01日 03点06分 2
回复 lang5535 :不会的
2014年06月03日 10点06分
level 14
官方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;
2014年06月01日 03点06分 3
level 14
前排
2014年06月01日 03点06分 4
level 14
禁用倒不如把字体放CDN再把它链过来
2014年06月01日 03点06分 5
后台我直接JHenghei……=-=||赶脚有了opensans好像没区别
2014年06月01日 03点06分
发一下“把字体放CDN再把它链过来”的教程~~我把它丢到七牛里面~~
2014年06月01日 03点06分
回复 PC丶爱好者 :发一下“把字体放CDN再把它链过来”的教程~~我把它丢到七牛里面~~
2014年06月01日 03点06分
回复 q807070178 :把字体另存为上传到七牛,再去css里改下地址就行
2014年06月01日 03点06分
level 3
貌似没有css
2014年06月01日 04点06分 6
level 11
yahei
2014年06月05日 00点06分 8
1