WordPress中禁用谷歌远程字体,防止在国内访问加载缓慢
1、把/usr/local/nginx/html/http/blog/wp-includes/script-loader.php文件中与https://fonts.googleapis.com在关的部分注释
if ( 'off' !== _x( 'on', 'Open Sans font: on or off' ) ) {
$subsets = 'latin,latin-ext';
/*
* translators: To add an additional Open Sans character subset specific to your language,
* translate this to 'greek', 'cyrillic' or 'vietnamese'. Do not translate into your own language.
*/
$subset = _x( 'no-subset', 'Open Sans font: add new subset (greek, cyrillic, vietnamese)' );
if ( 'cyrillic' === $subset ) {
$subsets .= ',cyrillic,cyrillic-ext';
} elseif ( 'greek' === $subset ) {
$subsets .= ',greek,greek-ext';
} elseif ( 'vietnamese' === $subset ) {
$subsets .= ',vietnamese';
}
// Hotlink Open Sans, for now.
$open_sans_font_url = "https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,300,400,600&subset=$subsets&display=fallback";
}
2、在/usr/local/nginx/html/http/blog/wp-content/themes/honeypress/inc/script/scripts.php文件中把以下代码段注释:
wp_enqueue_style('honeypress-font','https://fonts.googleapis.com/css?family=Open+Sans:300,300i,400,400i,600,600i,700,700i,800,800i');
3、这样就可以了,当访问wordpress时前端会自动加载默认字体,而不会再加载远程google字体了。
1 COMMENT