WP-ReplaceGravatarMirror can helps your wordpress blog replace its default gravatar provider(gravatar.com) to a third-part gravatar mirror(duoshuo.com) which can be load faster in somewhere.
WP-ReplaceGravatarMirror通过将国内已屏蔽的gravatar.com的头像服务器替换到国内可以访问和使用的duoshuo.com上实现在中国大陆访问Wordpress博客时gravatar头像可以使用的功能。
Download the latest version of WP-ReplaceGravatarMirror plugin package and decompress it.
Upload wp-replace-gravatar-mirror folder to the /wp-content/plugins/ directory.
Activate the plugin through the 'Plugins' menu in WordPress
下载最新版本的WP-ReplaceGravatarMirror插件安装包,并在下载完成后解压。
将解压文件中的_wp-replace-gravatar-mirror_目录上传到_/wp-content/plugins/_目录下
在WordPress后台激活并启用WP-ReplaceGravatarMirror插件
v1.0, 2015-07-14 The first stable version released.
v1.1, 2015-09-01 supports both http:// add https://.
WP-ReplaceGravatarMirror is released under the GPL 2.0.
Version 1.1
/**
* Plugin Name: WP-ReplaceGravatarMirror
* Plugin URI: https://github.com/limccn/WP-ReplaceGravatarMirror
* Description: This plugin can helps your wordpress blog replace its default gravatar provider(gravatar.com) to a third-part gravatar mirror(duoshuo.com) which can be load faster in somewhere.
* Author: limc
* Author URI: http://www.lidaren.com/
* Version: 1.1
* License: GPL 2.0
*/
/**
* Silence is golden
*/
if (!defined('ABSPATH')) exit;
class WP_Replace_Gravatar_Mirror
{
/\*\*
\* init Hook
\*
\*/
public function \_\_construct()
{
if(isset($\_SERVER\['HTTPS'\]) && $\_SERVER\['HTTPS'\] == 'on')
{
add\_filter('get\_avatar', array($this,'replace\_gravatar\_to\_ssl'), 10, 3);
}else
{
add\_filter('get\_avatar', array($this,'replace\_gravatar\_to\_duoshuo'), 10, 3);
}
}
/\*\*
\* Use DuoShuo's gravatar mirror to replace Gravatar's.
\* Simplely replace from "\*.gravatar.com" to "gravatar.duoshuo.com".
\*
\* @param $avatar
\* @return mixed
\*/
public function replace\_gravatar\_to\_duoshuo($avatar)
{
$avatar = str\_replace(array('www.gravatar.com','0.gravatar.com','1.gravatar.com','2.gravatar.com','s.gravatar.com'),'gravatar.duoshuo.com',$avatar);
return $avatar;
}
/\*\*
\* Use https gravatar server to replace none-https.
\* Simplely replace from "http://\*.gravatar.com" to "https://secure.gravatar.com".
\*
\* @param $avatar
\* @return mixed
\*/
public function replace\_gravatar\_to\_ssl($avatar)
{
$avatar = preg\_replace('/.\*\\/avatar\\/(.\*)\\?s=(\[\\d\]+)&.\*/','![](https://secure.gravatar.com/avatar/$1?s=$2)',$avatar);
return $avatar;
}
}
/**
* bootstrap
*/
new WP_Replace_Gravatar_Mirror;
Version 1.0
/**
* Plugin Name: WP-ReplaceGravatarMirror
* Plugin URI: https://github.com/limccn/WP-ReplaceGravatarMirror
* Description: This plugin can helps your wordpress blog replace its default gravatar provider(gravatar.com) to a third-part gravatar mirror(duoshuo.com) which can be load faster in somewhere.
* Author: limc
* Author URI: http://www.lidaren.com/
* Version: 1.0
* License: GPL 2.0
*/
/**
* Silence is golden
*/
if (!defined('ABSPATH')) exit;
class WP_Replace_Gravatar_Mirror
{
/\*\*
\* init Hook
\*
\*/
public function \_\_construct()
{
add\_filter('get\_avatar', array($this,'replace\_gravatar\_to\_duoshuo'), 10, 3);
}
/\*\*
\* Use DuoShuo's gravatar mirror to replace Gravatar's.
\* Simplely replace from "\*.gravatar.com" to "gravatar.duoshuo.com".
\*
\* @param $avatar
\* @return mixed
\*/
public function replace\_gravatar\_to\_duoshuo($avatar)
{
$avatar = str\_replace(array('www.gravatar.com','0.gravatar.com','1.gravatar.com','2.gravatar.com','s.gravatar.com'),'gravatar.duoshuo.com',$avatar);
return $avatar;
}
}
/**
* bootstrap
*/
new WP_Replace_Gravatar_Mirror;