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

WordPress 一些主题使用了 Google 字体,导致 WordPress 加载非常慢,所以我们需要在 WordPress 中禁用 Google Fonts,将下面的代码铁入到当前主题的 functions.php 文件:

add_filter('gettext_with_context', function ($translations, $text, $context){
	if($text == 'on' && in_array($context, [
		'Open Sans font: on or off',
		'Lato font: on or off',
		'Source Sans Pro font: on or off',
		'Bitter font: on or off'
	])){
		$translations = 'off';
	}

	return $translations;
}, 999, 3);

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


©我爱水煮鱼,本站推荐使用的主机:阿里云,国外主机建议使用BlueHost

本站长期承接 WordPress 优化建站业务,请联系微信:「chenduopapa」。