false]; $pm_enabled = !empty($pm_settings['enabled']); if (!$messages_enabled) : ?>

null, // special: !read 'all' => null, // special: all 'comment' => ['comment_reply', 'comment_approved', 'pending_comments'], 'credits' => ['credits_added', 'credits_deducted'], 'system' => ['notice', 'download_ready', 'upload_moderation', 'verify_email'], 'conversation' => ['conversation'], ]; if ($current_type === 'conversation' && !$pm_enabled) { $current_type = 'unread'; } $allowed_types = array_keys($type_groups); if (!in_array($current_type, $allowed_types, true)) { // 兼容旧 URL:msg_type=comment_reply 等 $mapped = 'all'; foreach ($type_groups as $group => $types) { if (is_array($types) && in_array($current_type, $types, true)) { $mapped = $group; break; } } $current_type = $mapped; } $filtered = $all_notifications; if ($current_type === 'unread') { $filtered = array_filter($filtered, static fn($n) => empty($n['read'])); } elseif ($current_type !== 'all' && $current_type !== 'conversation') { $types = $type_groups[$current_type] ?? []; $filtered = array_filter($filtered, static function ($n) use ($types) { $t = (string) ($n['type'] ?? 'notice'); return in_array($t, $types, true); }); } $filtered = array_values($filtered); $per_page = 20; $current_page = max(1, (int) ($_GET['msg_page'] ?? 1)); $total = count($filtered); $total_pages = max(1, (int) ceil($total / $per_page)); $offset = ($current_page - 1) * $per_page; $paged_items = array_slice($filtered, $offset, $per_page); // 统计 $type_counts = [ 'all' => count($all_notifications), 'unread' => 0, 'comment'=> 0, 'credits'=> 0, 'system' => 0, 'conversation' => 0, ]; foreach ($all_notifications as $n) { $t = (string) ($n['type'] ?? 'notice'); if (empty($n['read'])) { $type_counts['unread']++; } foreach (['comment', 'credits', 'system', 'conversation'] as $group) { if (in_array($t, $type_groups[$group], true)) { $type_counts[$group]++; } } } if ($pm_enabled && class_exists('AKSRT_Private_Message')) { // conversation count prefers live PM conversations when available $pm_tmp = AKSRT_Private_Message::get_instance(); if (method_exists($pm_tmp, 'get_conversations')) { $convs = $pm_tmp->get_conversations($user_id, 100); if (is_array($convs)) { $type_counts['conversation'] = count($convs); } } } $nav_items = [ 'unread' => __('未读消息', 'aksrt'), 'all' => __('全部消息', 'aksrt'), 'comment' => __('评论互动', 'aksrt'), 'credits' => __('积分动态', 'aksrt'), 'system' => __('系统通知', 'aksrt'), ]; if ($pm_enabled) { $nav_items['conversation'] = __('私信消息', 'aksrt'); } $icon_map = [ 'comment_reply' => 'fas fa-comment-dots', 'comment_approved' => 'fas fa-check-circle', 'credits_added' => 'fas fa-coins', 'credits_deducted' => 'fas fa-coins', 'download_ready' => 'fas fa-download', 'upload_moderation' => 'fas fa-image', 'verify_email' => 'fas fa-envelope-open-text', 'pending_comments' => 'fas fa-clock', 'conversation' => 'fas fa-envelope', 'notice' => 'fas fa-bell', ]; $messages_base = function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : get_permalink(); if (!$messages_base) { $messages_base = get_permalink(); } ?>

get_conversations($user_id, 30) : []; $pm_nonce = wp_create_nonce('aksrt_pm'); $pm_placeholder = (string) ($pm_settings['placeholder'] ?? __('请输入消息...', 'aksrt')); $pm_submit = (string) ($pm_settings['submit_text'] ?? __('发送', 'aksrt')); ?>
/>

1) : ?>