笨方法解决Gravatar头像被河蟹

打开wordpress程序根目录的wp-includes文件夹,找到pluggable.php打开,将大约2150至2157行: if ( is_ssl() ) { $host = ‘https://secure.gravatar.com'; } else { if ( !emptyempty($email) ) $host = sprintf( “http://%d.gravatar.com”, ( hexdec( $email_hash[0] ) % 2 ) ); else $host = ‘http://0.gravatar.com'; } 替换为:

  1. $host = ‘https://secure.gravatar.com';

之所以说“笨”是因为下次更新程序,还需要再次修改,不过这个方法最实用。   最新版的wp上面的方法可能失效,采用多说缓存, 下面的代码加到functions.php

1

2

3

4

5

function duoshuo_avatar($avatar) {

$avatar = str_replace(array(“www.gravatar.com","0.gravatar.com","1.gravatar.com","2.gravatar.com"),"gravatar.duoshuo.com",$avatar);

return $avatar;

}

add_filter( ‘get_avatar’, ‘duoshuo_avatar’, 10, 3 );

文章目录