百度 | 神马 | 搜狗 | 技术文档 | 学习资料分享 - 记录帝国CMS及运维技术的点点滴滴
你的位置:首页 > 实用IT技术 » 正文

【Wordpress相关】禁用 Google Fonts,加快 WordPress 后台打开速度

发布时间:2020-09-17

作品分类:Wordpress相关  后台  禁用  你可以  禁用  后台  加快  速度  打开

WordPress 技巧:禁用 Google Fonts,加快 WordPress 后台打开速度,

最近 Google 又非常慢,并且有时无法打开,而 WordPress 后台又使用了 Google 字体,导致 WordPress 加载非常慢,所以我们需要在 WordPress 中禁用 Google Fonts,将下面的代码铁入到当前主题的 functions.php 文件:

add_filter( 'gettext_with_context', 'wpjam_disable_google_fonts', 888, 4);
function wpjam_disable_google_fonts($translations, $text, $context, $domain ) {
	$google_fonts_contexts = array('Open Sans font: on or off','Lato font: on or off','Source Sans Pro font: on or off','Bitter font: on or off');
	if( $text == 'on' && in_array($context, $google_fonts_contexts ) ){
		$translations = 'off';
	}

	return $translations;
}

并且该功能已经整合到 插件中,并且你可以在后台随时开启或者关闭。

 

Top