因为好多人在问我WordPress头像能不能用QQ头像替代,答案是可以对于没有Gravatar的人,用QQ头像代替Gravatar的,今天就发布在盒子萌博客上!具体代码是这样的
user_email;
} elseif ( is_object($id_or_email) ) {
if ( !empty($id_or_email->user_id) ) {
$id = (int) $id_or_email->user_id;
$user = get_userdata($id);
if ( $user)
$email = $user->user_email;
} elseif ( !empty($id_or_email->comment_author_email) ) {
$email = $id_or_email->comment_author_email;
}
} else {
$email = $id_or_email;
}
// Get the url of avatar
$pattern = '/(?=http)[-w:/.?=]+/';
$url_count = preg_match_all($pattern, $avatar, $original_avatar_url);
$avatar_size = array();
$avatar_url = array();
$pattern = '/(? $lifetime) {
// If the file doesn't exist or it has been out of date, then update it.
// It's necessary to use "-N --no-use-server-timestamps".
exec("wget -N --no-use-server-timestamps -O '" . $file_path . "' '" . $avatar_url[$i] . "' > /dev/null &");
}
else $avatar = str_replace($original_avatar_url[0][$i], $wp_url . '/avatar/' . $hashkey . '-' . $avatar_size[$i] . '.jpg', $avatar);
if ( filesize($file_path)
文章来源于互联网:WordPress用QQ头像代替没有Gravatar头像




