替换Gravatar连接服务器,解决Gravatar头像无法显示

添加到自己的WordPress主题functions.php文件中

/**
* 替换 WP 的Gravatar 头像源
* https://www.ilxtx.com/replace-gravatar-server.html
*/
if ( ! function_exists( ‘dr_filter_get_avatar’ ) ) {
function dr_filter_get_avatar( $avatar ) {
// 新 Gravatar 头像源,可自行修改
$new_gravatar_sever = ‘cravatar.cn’;

$sources = array(
‘www.gravatar.com/avatar/’,
‘0.gravatar.com/avatar/’,
‘1.gravatar.com/avatar/’,
‘2.gravatar.com/avatar/’,
‘secure.gravatar.com/avatar/’,
‘cn.gravatar.com/avatar/’
);

return str_replace( $sources, $new_gravatar_sever.’/avatar/’, $avatar );
}
add_filter( ‘get_avatar’, ‘dr_filter_get_avatar’ );
}

 

原创文章,作者:易优笔记,如若转载,请注明出处:https://www.eluseo.com/archives/297.html

发表评论

登录后才能评论