进行了一些小优化

This commit is contained in:
2026-08-25 06:41:57 +08:00
parent 4c81980804
commit 9381d1ff53
6 changed files with 6 additions and 26 deletions
+4 -18
View File
@@ -137,7 +137,6 @@ class AuthApply {
private static function info_from_application(array $application): array {
return [
'name' => (string) ($application['public_name'] ?? ''),
'desc' => (string) ($application['public_desc'] ?? ''),
'type' => (string) ($application['type'] ?? ''),
'time' => (string) (($application['completed_at'] ?? '') ?: ($application['updated_at'] ?? '')),
];
@@ -153,7 +152,6 @@ class AuthApply {
'user_id' => (int) ($application['user_id'] ?? 0),
'name' => (string) ($application['public_name'] ?? ''),
'real_name' => (string) ($application['person_name_masked'] ?? ''),
'desc' => (string) ($application['public_desc'] ?? ''),
'msg' => (string) ($application['manual_reason'] ?? ''),
'type' => (string) ($application['type'] ?? ''),
'time' => (string) ($application['created_at'] ?? ''),
@@ -172,7 +170,6 @@ class AuthApply {
'stage' => $stage,
'next_action' => self::next_action($stage),
'public_name' => (string) ($application['public_name'] ?? ''),
'public_desc' => (string) ($application['public_desc'] ?? ''),
'result_code' => (string) ($application['provider_result_code'] ?? ''),
'message' => (string) ($application['provider_result_summary'] ?? ''),
'redirect_url' => esc_url_raw((string) ($application['redirect_url'] ?? '')),
@@ -263,7 +260,7 @@ class AuthApply {
return new \WP_Error('aksrt_verify_note', __('请填写处理原因', 'aksrt'));
}
$fields = [];
foreach (['type', 'public_name', 'public_desc'] as $key) {
foreach (['type', 'public_name'] as $key) {
if (array_key_exists($key, $profile_fields)) {
$fields[$key] = (string) $profile_fields[$key];
}
@@ -310,7 +307,6 @@ class AuthApply {
$can_manage = current_user_can('aksrt_review_identity')
&& current_user_can('edit_user', $user_id);
$public_name = (string) ($application['public_name'] ?? '');
$public_desc = (string) ($application['public_desc'] ?? '');
$identity_type = in_array((string) ($application['type'] ?? ''), ['personal', 'enterprise'], true)
? (string) $application['type']
: 'personal';
@@ -350,17 +346,11 @@ class AuthApply {
</td>
</tr>
<tr>
<th><label for="aksrt_identity_public_name"><?php esc_html_e('认证身份', 'aksrt'); ?></label></th>
<th><label for="aksrt_identity_public_name"><?php esc_html_e('姓名 / 主体全称', 'aksrt'); ?></label></th>
<td>
<input type="text" class="regular-text" id="aksrt_identity_public_name" name="aksrt_identity_public_name" maxlength="64" value="<?php echo esc_attr($public_name); ?>">
</td>
</tr>
<tr>
<th><label for="aksrt_identity_public_desc"><?php esc_html_e('认证公开说明', 'aksrt'); ?></label></th>
<td>
<textarea class="large-text" id="aksrt_identity_public_desc" name="aksrt_identity_public_desc" rows="3" maxlength="300"><?php echo esc_textarea($public_desc); ?></textarea>
</td>
</tr>
<tr>
<th><label for="aksrt_identity_review_note"><?php esc_html_e('处理说明', 'aksrt'); ?></label></th>
<td>
@@ -374,8 +364,7 @@ class AuthApply {
<td><strong><?php echo esc_html(self::admin_status_label($raw_status)); ?></strong></td>
</tr>
<tr><th><?php esc_html_e('认证类型', 'aksrt'); ?></th><td><?php echo esc_html(self::admin_type_label($identity_type)); ?></td></tr>
<?php if ($public_name !== '') : ?><tr><th><?php esc_html_e('认证身份', 'aksrt'); ?></th><td><?php echo esc_html($public_name); ?></td></tr><?php endif; ?>
<?php if ($public_desc !== '') : ?><tr><th><?php esc_html_e('认证公开说明', 'aksrt'); ?></th><td><?php echo nl2br(esc_html($public_desc)); ?></td></tr><?php endif; ?>
<?php if ($public_name !== '') : ?><tr><th><?php esc_html_e('姓名 / 主体全称', 'aksrt'); ?></th><td><?php echo esc_html($public_name); ?></td></tr><?php endif; ?>
<?php endif; ?>
</table>
<?php
@@ -407,7 +396,6 @@ class AuthApply {
}
$public_name = wp_html_excerpt(sanitize_text_field((string) wp_unslash($_POST['aksrt_identity_public_name'] ?? '')), 64, '');
$public_desc = wp_html_excerpt(sanitize_textarea_field((string) wp_unslash($_POST['aksrt_identity_public_desc'] ?? '')), 300, '');
$identity_type = sanitize_key((string) wp_unslash($_POST['aksrt_identity_type'] ?? ''));
$status = sanitize_key((string) wp_unslash($_POST['aksrt_identity_status'] ?? ''));
$note = sanitize_textarea_field((string) wp_unslash($_POST['aksrt_identity_review_note'] ?? ''));
@@ -418,7 +406,6 @@ class AuthApply {
$fields = [
'type' => $identity_type,
'public_name' => $public_name,
'public_desc' => $public_desc,
];
$current_status = (string) ($application['status'] ?? '');
@@ -428,7 +415,7 @@ class AuthApply {
}
$target_status = $status === '' ? 'cancelled' : $status;
if ($target_status === 'verified' && $public_name === '') {
$this->set_admin_profile_notice('error', __('设为已认证时请填写认证身份。', 'aksrt'));
$this->set_admin_profile_notice('error', __('设为已认证时请填写姓名 / 主体全称。', 'aksrt'));
return;
}
if (in_array($target_status, ['rejected', 'cancelled'], true) && $target_status !== $current_status && $note === '') {
@@ -476,7 +463,6 @@ class AuthApply {
'provider' => '',
'status' => 'created',
'public_name' => $fields['public_name'],
'public_desc' => $fields['public_desc'],
'fee_amount' => '0.00',
'fee_status' => 'not_required',
'attempt_ordinal' => $repo->count_user_type($user_id, $fields['type']) + 1,