Integrate cravatar for WordPress

Original link: https://zburu.com/archives/241.html

Original link: https://ift.tt/L0263uE

 if ( ! function_exists( 'get_cravatar_url' ) ) { /** * 替换Gravatar 头像为Cravatar 头像* * Cravatar 是Gravatar 在中国的完美替代方案,你可以在https://cravatar.cn 更新你的头像*/ function get_cravatar_url( $url ) { $sources = array( 'www.gravatar.com', '0.gravatar.com', '1.gravatar.com', '2.gravatar.com', 'secure.gravatar.com', 'cn.gravatar.com', 'gravatar.com', ); return str_replace( $sources, 'cravatar.cn', $url ); } add_filter( 'um_user_avatar_url_filter', 'get_cravatar_url', 1 ); add_filter( 'bp_gravatar_url', 'get_cravatar_url', 1 ); add_filter( 'get_avatar_url', 'get_cravatar_url', 1 ); } if ( ! function_exists( 'set_defaults_for_cravatar' ) ) { /** * 替换WordPress 讨论设置中的默认头像*/ function set_defaults_for_cravatar( $avatar_defaults ) { $avatar_defaults['gravatar_default'] = 'Cravatar 标志'; return $avatar_defaults; } add_filter( 'avatar_defaults', 'set_defaults_for_cravatar', 1 ); } if ( ! function_exists( 'set_user_profile_picture_for_cravatar' ) ) { /** * 替换个人资料卡中的头像上传地址*/ function set_user_profile_picture_for_cravatar() { return '<a href="https://cravatar.cn" target="_blank">您可以在Cravatar 修改您的资料图片</a>'; } add_filter( 'user_profile_picture_description', 'set_user_profile_picture_for_cravatar', 1 ); }

This article is reproduced from: https://zburu.com/archives/241.html
This site is for inclusion only, and the copyright belongs to the original author.

Leave a Comment