Merge pull request 'fix(user): accept core avatar hook payload' (#327) from worktree-fix-avatar-hook-user-type into main

Reviewed-on: CYL/wordpress-theme-aksrt#327
This commit is contained in:
2026-07-30 11:06:20 +08:00
+2 -2
View File
@@ -182,7 +182,7 @@ if (!function_exists('aksrt_render_admin_avatar_field')) {
} }
} }
add_filter('user_profile_update_errors', static function (WP_Error $errors, bool $update, WP_User $user): void { add_filter('user_profile_update_errors', static function (WP_Error $errors, bool $update): void {
if (empty($_FILES['aksrt_avatar_file']['name']) || !aksrt_is_avatar_upload_enabled()) { if (empty($_FILES['aksrt_avatar_file']['name']) || !aksrt_is_avatar_upload_enabled()) {
return; return;
} }
@@ -207,7 +207,7 @@ add_filter('user_profile_update_errors', static function (WP_Error $errors, bool
if (empty($checked['type']) || empty($checked['ext']) || !wp_match_mime_types('image', $checked['type']) || !$image_size || ((int) $image_size[0] * (int) $image_size[1]) > 40000000) { if (empty($checked['type']) || empty($checked['ext']) || !wp_match_mime_types('image', $checked['type']) || !$image_size || ((int) $image_size[0] * (int) $image_size[1]) > 40000000) {
$errors->add('aksrt_avatar_type', __('头像必须是有效的 JPG、PNG、GIF 或 WebP 图片,且总像素不能超过 4000 万。', 'aksrt')); $errors->add('aksrt_avatar_type', __('头像必须是有效的 JPG、PNG、GIF 或 WebP 图片,且总像素不能超过 4000 万。', 'aksrt'));
} }
}, 10, 3); }, 10, 2);
add_action('personal_options_update', 'aksrt_save_admin_avatar_field'); add_action('personal_options_update', 'aksrt_save_admin_avatar_field');
add_action('edit_user_profile_update', 'aksrt_save_admin_avatar_field'); add_action('edit_user_profile_update', 'aksrt_save_admin_avatar_field');