最近由于众所周知的问题,国内访问 Google Open Fonts 资源不通畅,导致主题中引用了这个资源的 WordPress 网站普遍出现了访问极其缓存的情况。
写了一个插件,使用奇虎 360 的开放字体服务来替换 Google 的开放字体服务。
如果你在使用插件过程中遇到任何问题,欢迎反馈。
插件信息
=== Replace Google Fonts ===
Contributors: soulteary
Tags: Qihu Fonts, Qihu Web Fonts, 360 Fonts, 360 Web Fonts, Google Fonts, Google Web Fonts
Requires at least: 3.5
Tested up to: 3.8
Stable tag: 1.0
Use Qihoo 360 Open Fonts Service to replace Google’s.
== Description ==
Plugin homepage | Plugin author
There are some problem with Google in china, the Google Fonts make the website too slow to open, so we can use Qihoo 360’s Web Fonts replace the Google’s. Project GitHub.
== Installation ==
1. Upload
replace-google-fonts
folder to the/wp-content/plugins/
directory2. Activate the plugin through the ‘Plugins’ menu in WordPress
插件代码
/**
* Plugin Name: Replace Google Fonts
* Plugin URI: http://www.soulteary.com/2014/06/08/replace-google-fonts.html
* Description: Use Qihoo 360 Open Fonts Service to replace Google's.
* Author: soulteary
* Author URI: http://www.soulteary.com/
* Version: 1.0
* License: GPL
*/
/**
* Silence is golden
*/
if (!defined('ABSPATH')) exit;
class Replace_Google_Fonts
{
/**
* init Hook
*
*/
public function __construct()
{
add_filter('style_loader_tag', array($this, 'ohMyFont'), 888, 4);
}
/**
* Use Qihoo 360 Open Fonts Service to replace Google's.
*
* @param $text
* @return mixed
*/
public function ohMyFont($text)
{
return str_replace('//fonts.googleapis.com/', '//fonts.useso.com/', $text);
}
}
/**
* bootstrap
*/
new Replace_Google_Fonts;