diff --git a/assets/css/admin/user-level.css b/assets/css/admin/user-level.css new file mode 100644 index 00000000..f4a51522 --- /dev/null +++ b/assets/css/admin/user-level.css @@ -0,0 +1,10 @@ +#users .aksrt-user-level-icon--admin, +#your-profile .aksrt-user-level-icon--admin, +#profile-page .aksrt-user-level-icon--admin { + display: inline-block; + width: auto; + height: 18px; + max-width: 40px; + object-fit: contain; + vertical-align: middle; +} diff --git a/src/AKSRT/User/Home.php b/src/AKSRT/User/Home.php index 172b346e..64a42082 100644 --- a/src/AKSRT/User/Home.php +++ b/src/AKSRT/User/Home.php @@ -143,7 +143,7 @@ class Home { $application = class_exists('AKSRT\\User\\AuthApply') ? AuthApply::get_apply_payload($user_id) : []; $type = sanitize_key((string) ($info['type'] ?? $application['type'] ?? '')); $type_settings = is_array($settings['verify']['types'][$type] ?? null) ? $settings['verify']['types'][$type] : []; - $label = (string) ($type_settings['badge_text'] ?? $type_settings['label'] ?? __('认证用户', 'aksrt')); + $label = (string) ($type_settings['badge_text'] ?? $type_settings['label'] ?? ''); $signals[] = [ 'type' => 'verify', 'label' => $label, diff --git a/src/AKSRT/User/LevelAdmin.php b/src/AKSRT/User/LevelAdmin.php index aa1853e8..d9467193 100644 --- a/src/AKSRT/User/LevelAdmin.php +++ b/src/AKSRT/User/LevelAdmin.php @@ -25,6 +25,7 @@ class LevelAdmin { if (!is_admin()) { return; } + add_action('admin_enqueue_scripts', [$this, 'enqueue_assets']); add_filter('manage_users_columns', [$this, 'add_column']); add_filter('manage_users_custom_column', [$this, 'render_column'], 10, 3); add_filter('manage_users_sortable_columns', [$this, 'sortable_columns']); @@ -40,6 +41,18 @@ class LevelAdmin { return class_exists(Level::class) && !empty(Level::settings()['enabled']); } + public function enqueue_assets(string $hook): void { + if (!in_array($hook, ['users.php', 'user-edit.php', 'profile.php'], true)) { + return; + } + wp_enqueue_style( + 'aksrt-user-level-admin', + get_theme_file_uri('/assets/css/admin/user-level.css'), + [], + defined('AKSRT_VERSION') ? AKSRT_VERSION : null + ); + } + private function can_manage(int $user_id): bool { return current_user_can('manage_options') && current_user_can('edit_user', $user_id); }