修复:G家头像替换功能的潜在问题

1. 其他插件或主题接管头像时无法替换
 2. 使用get_gravatar_url情况下无法成功替换
This commit is contained in:
孙锡源 2021-07-06 14:06:14 +08:00 committed by GitHub
parent f53413d8e7
commit 421890785a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -4,7 +4,7 @@
* Description: 将你的WordPress接入本土生态体系中这将为你提供一个更贴近中国人使用习惯的WordPress
* Author: WP中国本土化社区
* Author URI:https://wp-china.org/
* Version: 3.3.4
* Version: 3.3.5
* Network: True
* License: GPLv3 or later
* License URI: http://www.gnu.org/licenses/gpl-3.0.html
@ -218,16 +218,13 @@ if (!class_exists('WP_CHINA_YES')) {
* 替换G家头像为WP-China.org维护的大陆加速节点
*/
if (get_option('super_gravatar') == 1) {
add_filter('get_avatar', function ($avatar) {
return str_replace([
'www.gravatar.com',
'0.gravatar.com',
'1.gravatar.com',
'2.gravatar.com',
'secure.gravatar.com',
'cn.gravatar.com'
], 'gravatar.wp-china-yes.net', $avatar);
}, 1);
add_filter( 'get_avatar_data', function ( $args ) {
if ( ! empty( $args ) && is_array( $args ) && isset( $args['url'] ) ) {
$args['url'] = preg_replace( '/[^\.\/]+\.[^\.\/]+$/', 'gravatar.wp-china-yes.net', $args['url'] );
}
return $args;
}, 9999 );
}
}
@ -349,4 +346,4 @@ if (!class_exists('WP_CHINA_YES')) {
}
(new WP_CHINA_YES)->init();
}
}