进行了一些小优化

This commit is contained in:
kate522 committed 2026-08-25 17:02:33 +08:00
1 parent 4a4009133c
commit 11f1c23fa7
12 files changed
+463 -10

No files matched your search

+2 -1
View File
@@ -178,6 +178,7 @@ if (!function_exists('aksrt_capture_user_center_view')) {
'orders' => 'orders',
'auth' => 'auth',
'revenue' => 'revenue',
'msg' => 'msg',
'settings' => 'settings',
'header' => 'header',
'sidebar' => 'sidebar',
@@ -201,7 +202,7 @@ if (!function_exists('aksrt_capture_user_center_panel')) {
* Capture a built-in or registered user-center panel body.
*/
function aksrt_capture_user_center_panel(string $tab_key, array $tab, array $context): string {
$built_in_tabs = ['profile', 'level', 'creator', 'posts', 'follow', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
$built_in_tabs = ['profile', 'level', 'creator', 'posts', 'follow', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'msg', 'settings'];
if (in_array($tab_key, $built_in_tabs, true)) {
return aksrt_capture_user_center_view($tab_key, $context);
}
@@ -0,0 +1,57 @@
<?php
/**
* User center notification preferences panel.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
$preferences = class_exists('\AKSRT\User\NotificationPreferences')
? \AKSRT\User\NotificationPreferences::get($user_id)
: ['posts' => true, 'like' => true, 'system' => true];
$items = [
'posts' => [
'title' => __('文章评论', 'aksrt'),
'description' => __('接收文章、评论、收藏等相关消息', 'aksrt'),
],
'like' => [
'title' => __('点赞喜欢', 'aksrt'),
'description' => __('接收点赞、关注等相关消息', 'aksrt'),
],
'system' => [
'title' => __('系统消息', 'aksrt'),
'description' => __('接收订单、活动、等系统消息', 'aksrt'),
],
];
?>
<form class="uc-notification-preferences" data-aksrt-notification-preferences>
<div class="uc-notification-preferences__header">
<div>
<h2><?php esc_html_e('消息通知', 'aksrt'); ?></h2>
<p><?php esc_html_e('选择你希望接收的站内消息类型。', 'aksrt'); ?></p>
</div>
<span class="uc-notification-preferences__header-icon" aria-hidden="true"><i class="fa fas fa-bell"></i></span>
</div>
<div class="uc-notification-preferences__list">
<?php foreach ($items as $key => $item) : ?>
<label class="uc-notification-preference" for="aksrt-notification-<?php echo esc_attr($key); ?>">
<span class="uc-notification-preference__copy">
<strong><?php echo esc_html($item['title']); ?></strong>
<small><?php echo esc_html($item['description']); ?></small>
</span>
<span class="uc-notification-switch">
<input id="aksrt-notification-<?php echo esc_attr($key); ?>" type="checkbox" name="<?php echo esc_attr($key); ?>" value="1" role="switch" <?php checked(!empty($preferences[$key])); ?>>
<span aria-hidden="true"></span>
</span>
</label>
<?php endforeach; ?>
</div>
<div class="uc-notification-preferences__footer">
<button type="submit" class="btn-primary"><?php esc_html_e('保存设置', 'aksrt'); ?></button>
</div>
</form>
@@ -43,8 +43,8 @@ $settings = array_values(array_filter([
'label' => __('消息通知', 'aksrt'),
'icon' => 'bell',
'tone' => 'notice',
'url' => (string) ($messages_url ?? ''),
'count' => (int) ($notification_unread_count ?? 0),
'url' => isset($dashboard_tabs['msg']) ? aksrt_get_user_center_tab_url('msg') : '',
'tab' => 'msg',
],
[
'label' => __('个人资料', 'aksrt'),