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'], 'pay' => ['pay', 'order_paid', 'order_refund', 'shop_order', 'after_sale'], 'vip' => ['vip', 'pay_vip', 'vip_expire', 'vip_upgrade'], 'medal' => ['medal', 'badge', 'level_up'], 'ban_appeal' => ['ban_appeal', 'user_ban', 'restriction'], 'system' => ['notice', 'download_ready', 'upload_moderation', 'verify_email', 'auth_apply', 'auth_apply_reply'], '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, 'pay' => 0, 'vip' => 0, 'medal' => 0, 'ban_appeal' => 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', 'pay', 'vip', 'medal', 'ban_appeal', 'system', 'conversation'] as $group) { if (!empty($type_groups[$group]) && is_array($type_groups[$group]) && in_array($t, $type_groups[$group], true)) { $type_counts[$group]++; } } } if ($pm_enabled && class_exists('\AKSRT\Messages\PrivateMessage')) { // conversation count prefers live PM conversations when available $pm_tmp = \AKSRT\Messages\PrivateMessage::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'), 'pay' => __('交易通知', 'aksrt'), 'vip' => __('会员动态', 'aksrt'), 'medal' => __('徽章等级', 'aksrt'), 'ban_appeal' => __('禁封申诉', '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', 'pay' => 'fas fa-receipt', 'order_paid' => 'fas fa-receipt', 'order_refund' => 'fas fa-undo', 'after_sale' => 'fas fa-undo-alt', 'vip' => 'fas fa-crown', 'pay_vip' => 'fas fa-crown', 'medal' => 'fas fa-medal', 'badge' => 'fas fa-certificate', 'ban_appeal' => 'fas fa-gavel', 'user_ban' => 'fas fa-ban', 'auth_apply' => 'fas fa-id-badge', 'auth_apply_reply' => 'fas fa-id-badge', '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) : ?>