删除私信分支链路
This commit is contained in:
1 parent
1c5c6d86bb
commit
c6c2c0af6d
39 files changed
+32
-1465
No files matched your search
@@ -4,7 +4,7 @@
|
||||
* Template Post Type: page
|
||||
*
|
||||
* 独立消息中心页面 — 两栏布局(左侧导航 + 右侧消息列表)
|
||||
* 对齐 legacy msg-center:未读 / 评论 / 系统 / 私信(可开关)
|
||||
* 对齐 legacy msg-center:未读 / 评论 / 系统
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -21,8 +21,6 @@ if (!is_user_logged_in()) {
|
||||
}
|
||||
|
||||
$messages_enabled = !class_exists('\AKSRT\Settings\Settings') || \AKSRT\Settings\Settings::message_enabled();
|
||||
$pm_settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::private_message_settings() : ['enabled' => false];
|
||||
$pm_enabled = !empty($pm_settings['enabled']);
|
||||
|
||||
if (!$messages_enabled) :
|
||||
?>
|
||||
@@ -60,13 +58,8 @@ $type_groups = [
|
||||
'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 等
|
||||
@@ -83,7 +76,7 @@ if (!in_array($current_type, $allowed_types, true)) {
|
||||
$filtered = $all_notifications;
|
||||
if ($current_type === 'unread') {
|
||||
$filtered = array_filter($filtered, static fn($n) => empty($n['read']));
|
||||
} elseif ($current_type !== 'all' && $current_type !== 'conversation') {
|
||||
} elseif ($current_type !== 'all') {
|
||||
$types = $type_groups[$current_type] ?? [];
|
||||
$filtered = array_filter($filtered, static function ($n) use ($types) {
|
||||
$t = (string) ($n['type'] ?? 'notice');
|
||||
@@ -110,31 +103,19 @@ $paged_items = array_slice($filtered, $offset, $per_page);
|
||||
'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) {
|
||||
foreach (['comment', 'credits', 'pay', 'vip', 'medal', 'ban_appeal', 'system'] 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'),
|
||||
@@ -146,9 +127,6 @@ $nav_items = [
|
||||
'ban_appeal' => __('禁封申诉', 'aksrt'),
|
||||
'system' => __('系统通知', 'aksrt'),
|
||||
];
|
||||
if ($pm_enabled) {
|
||||
$nav_items['conversation'] = __('私信消息', 'aksrt');
|
||||
}
|
||||
|
||||
$icon_map = [
|
||||
'comment_reply' => 'fa fas fa-comment-dots',
|
||||
@@ -158,9 +136,8 @@ $nav_items = [
|
||||
'download_ready' => 'fa fas fa-download',
|
||||
'upload_moderation' => 'fa fas fa-image',
|
||||
'verify_email' => 'fa fas fa-envelope-open',
|
||||
'pending_comments' => 'fa fas fa-clock',
|
||||
'conversation' => 'fa fas fa-envelope',
|
||||
'pay' => 'fa fas fa-file-alt',
|
||||
'pending_comments' => 'fa fas fa-clock',
|
||||
'pay' => 'fa fas fa-file-alt',
|
||||
'order_paid' => 'fa fas fa-file-alt',
|
||||
'order_refund' => 'fa fas fa-undo',
|
||||
'after_sale' => 'fa fas fa-undo',
|
||||
@@ -196,7 +173,7 @@ if (!$messages_base) {
|
||||
<?php foreach ($nav_items as $key => $label) :
|
||||
$count = (int) ($type_counts[$key] ?? 0);
|
||||
// 始终显示核心 tab;其余无数据时可隐藏(保留 unread/all/system)
|
||||
if (!in_array($key, ['unread', 'all', 'system', 'conversation'], true) && $count < 1) {
|
||||
if (!in_array($key, ['unread', 'all', 'system'], true) && $count < 1) {
|
||||
continue;
|
||||
}
|
||||
$is_active = $current_type === $key;
|
||||
@@ -221,58 +198,7 @@ if (!$messages_base) {
|
||||
</aside>
|
||||
|
||||
<section class="messages-center__content">
|
||||
<?php if ($current_type === 'conversation' && $pm_enabled) :
|
||||
$pm = class_exists('\AKSRT\Messages\PrivateMessage') ? \AKSRT\Messages\PrivateMessage::get_instance() : null;
|
||||
$conversations = $pm ? $pm->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'));
|
||||
?>
|
||||
<div class="messages-conversations" id="aksrt-pm-conversations"
|
||||
data-ajax="<?php echo esc_url(admin_url('admin-ajax.php')); ?>"
|
||||
data-nonce="<?php echo esc_attr($pm_nonce); ?>">
|
||||
<?php if (!empty($conversations)) : ?>
|
||||
<div class="aksrt-pm__list">
|
||||
<?php foreach ($conversations as $conv) : ?>
|
||||
<div class="aksrt-pm__item<?php echo !empty($conv['unread']) ? ' is-unread' : ''; ?>"
|
||||
data-conv-id="<?php echo esc_attr((string) ($conv['id'] ?? '')); ?>"
|
||||
data-other-id="<?php echo esc_attr((string) ($conv['other_user_id'] ?? '')); ?>">
|
||||
<img<?php echo aksrt_get_lazy_attr('lazy_private', (string) ($conv['other_avatar'] ?? ''), 'aksrt-pm__avatar', aksrt_get_lazy_thumb('sm')); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?> alt="">
|
||||
<div class="aksrt-pm__info">
|
||||
<div class="aksrt-pm__name">
|
||||
<?php echo esc_html((string) ($conv['other_name'] ?? '')); ?>
|
||||
<?php if (!empty($conv['unread'])) : ?>
|
||||
<span class="aksrt-pm__badge"><?php echo esc_html((string) $conv['unread']); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="aksrt-pm__preview"><?php echo esc_html(mb_substr((string) ($conv['last_message'] ?? ''), 0, 50)); ?></div>
|
||||
</div>
|
||||
<div class="aksrt-pm__time"><?php echo esc_html(!empty($conv['last_message_at']) ? mysql2date('m-d H:i', (string) $conv['last_message_at']) : ''); ?></div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="messages-empty">
|
||||
<span class="messages-empty__icon"><i class="fa fas fa-envelope"></i></span>
|
||||
<p class="messages-empty__text"><?php esc_html_e('暂无私信', 'aksrt'); ?></p>
|
||||
<p class="messages-empty__hint"><?php esc_html_e('你可以在用户主页或文章作者栏发起私信。', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="aksrt-pm__thread" id="aksrt-pm-thread" hidden>
|
||||
<div class="aksrt-pm__thread-header">
|
||||
<button type="button" class="aksrt-pm__back-btn" id="aksrt-pm-back"><i class="fa fas fa-arrow-left"></i> <?php esc_html_e('返回', 'aksrt'); ?></button>
|
||||
<span class="aksrt-pm__thread-name" id="aksrt-pm-thread-name"></span>
|
||||
</div>
|
||||
<div class="aksrt-pm__messages" id="aksrt-pm-messages"></div>
|
||||
<div class="aksrt-pm__compose">
|
||||
<textarea id="aksrt-pm-input" rows="2" placeholder="<?php echo esc_attr($pm_placeholder); ?>"></textarea>
|
||||
<button type="button" id="aksrt-pm-send" class="aksrt-pm__send-btn" aria-label="<?php echo esc_attr($pm_submit); ?>"><i class="fa fas fa-paper-plane"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php elseif (!empty($paged_items)) : ?>
|
||||
<?php if (!empty($paged_items)) : ?>
|
||||
<div class="messages-list">
|
||||
<?php foreach ($paged_items as $notice) :
|
||||
$n_type = (string) ($notice['type'] ?? 'notice');
|
||||
|
||||
Reference in new issue
Block a user