优化Google字体 全面加速WordPress

从5月27号起,由于某些原因,Google服务在大陆的崩溃影响了数百万的站长,因为很多wordpress主题都在使用Google的在线字体方案-google fonts包括新版的WordPress 后台也有加载谷歌的JS。Google服务一不稳定,就影响独立博客的字体加载,使wordpress站点加载速度很慢。

为此,特整理部分修改方案。

一、将原Google地址替换为360的CDN(推荐)

利用360网站卫士提供的前端公共库CDN服务(http://libs.useso.com/)替换原有Wordpress的Google JS即可.

[步骤]:

1.打开Wordpress文件: 根/wp-includes/script-loader.php

2.搜索关键字 fonts.googleapis.com

3.替换fonts.googleapis.com为fonts.useso.com

4.保存文件,即可。

二、去除google字体

1.用notepad++打开主题的 functions.php文件,在末尾添加以下代码:

//禁用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;

2.保存,上传覆盖到主题目录,即可.(可使用其他编辑器但要注意编码格式)

三、使用插件(未经实验,不推荐)

可使用Auto Remove Google’s URL插件来替换Google的地址.

源于青互联博客:http://www.qing.es/2014/06/150.html

原文地址:https://www.cnblogs.com/momi/p/3791150.html