feat(messages): 消息中心前台 1:1 导航/门控/资源加载
对齐 Zibll 消息中心主 tab 语义,补齐 messages/conversation 资源 enqueue,按 message_s/private_s 门控私信与总开关,并收束页面壳层与作者栏入口。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
1ae6c3bd11
commit
593d209fc6
5 files changed
+356
-194
No files matched your search
@@ -578,3 +578,42 @@ html.dark .aksrt-pm__item.is-unread,
|
|||||||
html.dark .aksrt-pm__item.is-unread {
|
html.dark .aksrt-pm__item.is-unread {
|
||||||
background: rgba(240, 68, 148, 0.08);
|
background: rgba(240, 68, 148, 0.08);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Page header */
|
||||||
|
.messages-center__header {
|
||||||
|
margin: 8px 0 16px;
|
||||||
|
}
|
||||||
|
.messages-center__title {
|
||||||
|
margin: 0 0 6px;
|
||||||
|
font-size: 22px;
|
||||||
|
font-weight: 700;
|
||||||
|
color: var(--color-ink, #1f2937);
|
||||||
|
}
|
||||||
|
.messages-center__subtitle {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 14px;
|
||||||
|
color: var(--color-ink-3, #6b7280);
|
||||||
|
}
|
||||||
|
|
||||||
|
.messages-center--disabled {
|
||||||
|
display: block;
|
||||||
|
min-height: 40vh;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* PM thread uses hidden attribute instead of inline style */
|
||||||
|
.aksrt-pm__thread[hidden] {
|
||||||
|
display: none !important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.message-item__new-badge {
|
||||||
|
display: inline-block;
|
||||||
|
margin-left: 6px;
|
||||||
|
padding: 1px 6px;
|
||||||
|
border-radius: 999px;
|
||||||
|
background: var(--color-primary, #3b82f6);
|
||||||
|
color: #fff;
|
||||||
|
font-size: 11px;
|
||||||
|
font-weight: 600;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
||||||
@@ -58,7 +58,7 @@
|
|||||||
// Back button
|
// Back button
|
||||||
if (backBtn) {
|
if (backBtn) {
|
||||||
backBtn.addEventListener('click', function () {
|
backBtn.addEventListener('click', function () {
|
||||||
threadView.style.display = 'none';
|
threadView.hidden = true;
|
||||||
listView.style.display = '';
|
listView.style.display = '';
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -99,7 +99,7 @@
|
|||||||
}).then(function (d) {
|
}).then(function (d) {
|
||||||
if (d.success && d.data) {
|
if (d.success && d.data) {
|
||||||
renderMessages(d.data.messages || []);
|
renderMessages(d.data.messages || []);
|
||||||
listView.style.display = 'none';
|
listView.hidden = true;
|
||||||
threadView.style.display = '';
|
threadView.style.display = '';
|
||||||
|
|
||||||
// Mark as read
|
// Mark as read
|
||||||
|
|||||||
@@ -341,6 +341,39 @@ trait AKSRT_Scripts_Part_1b {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 消息中心页
|
||||||
|
if (is_page_template('templates/pages/page-messages.php')) {
|
||||||
|
$messages_css = get_template_directory() . '/assets/css/frontend/messages.css';
|
||||||
|
if (file_exists($messages_css)) {
|
||||||
|
wp_enqueue_style(
|
||||||
|
'aksrt-messages',
|
||||||
|
$base_uri . '/assets/css/frontend/messages.css',
|
||||||
|
['aksrt-tokens'],
|
||||||
|
(string) filemtime($messages_css)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$messages_js = get_template_directory() . '/assets/js/messages.js';
|
||||||
|
if (file_exists($messages_js)) {
|
||||||
|
wp_enqueue_script(
|
||||||
|
'aksrt-messages',
|
||||||
|
$base_uri . '/assets/js/messages.js',
|
||||||
|
['aksrt-script'],
|
||||||
|
(string) filemtime($messages_js),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
$conversation_js = get_template_directory() . '/assets/js/conversation.js';
|
||||||
|
if (file_exists($conversation_js)) {
|
||||||
|
wp_enqueue_script(
|
||||||
|
'aksrt-conversation',
|
||||||
|
$base_uri . '/assets/js/conversation.js',
|
||||||
|
['aksrt-script'],
|
||||||
|
(string) filemtime($conversation_js),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Forum pages (home / plate / board tax / tag / topic / compose / plate-cat)
|
// Forum pages (home / plate / board tax / tag / topic / compose / plate-cat)
|
||||||
$is_forum_surface = is_page_template('templates/pages/page-forums.php')
|
$is_forum_surface = is_page_template('templates/pages/page-forums.php')
|
||||||
|| is_page_template('templates/forum/forum-compose.php')
|
|| is_page_template('templates/forum/forum-compose.php')
|
||||||
|
|||||||
+276
-189
@@ -4,6 +4,7 @@
|
|||||||
* Template Post Type: page
|
* Template Post Type: page
|
||||||
*
|
*
|
||||||
* 独立消息中心页面 — 两栏布局(左侧导航 + 右侧消息列表)
|
* 独立消息中心页面 — 两栏布局(左侧导航 + 右侧消息列表)
|
||||||
|
* 对齐 Zibll msg-center:未读 / 评论 / 系统 / 私信(可开关)
|
||||||
*
|
*
|
||||||
* @package AKSRT
|
* @package AKSRT
|
||||||
*/
|
*/
|
||||||
@@ -12,225 +13,311 @@ defined('ABSPATH') || exit;
|
|||||||
|
|
||||||
get_header();
|
get_header();
|
||||||
|
|
||||||
if ( ! is_user_logged_in() ) {
|
if (!is_user_logged_in()) {
|
||||||
$login_url = function_exists( 'aksrt_get_login_url' ) ? aksrt_get_login_url() : wp_login_url( get_permalink() );
|
$login_url = function_exists('aksrt_get_login_url') ? aksrt_get_login_url() : wp_login_url(get_permalink());
|
||||||
wp_safe_redirect( $login_url );
|
wp_safe_redirect($login_url);
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$messages_enabled = !class_exists('AKSRT_Settings') || AKSRT_Settings::message_enabled();
|
||||||
|
$pm_settings = class_exists('AKSRT_Settings') ? AKSRT_Settings::private_message_settings() : ['enabled' => false];
|
||||||
|
$pm_enabled = !empty($pm_settings['enabled']);
|
||||||
|
|
||||||
|
if (!$messages_enabled) :
|
||||||
|
?>
|
||||||
|
<main id="main-content" class="site-main content-shell" tabindex="-1">
|
||||||
|
<div class="container messages-center messages-center--disabled">
|
||||||
|
<div class="messages-empty">
|
||||||
|
<span class="messages-empty__icon"><i class="fas fa-bell-slash"></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>
|
||||||
|
</div>
|
||||||
|
</main>
|
||||||
|
<?php
|
||||||
|
get_footer();
|
||||||
|
return;
|
||||||
|
endif;
|
||||||
|
|
||||||
$user_id = get_current_user_id();
|
$user_id = get_current_user_id();
|
||||||
|
|
||||||
// 获取所有通知(持久化 + 即时状态)
|
$all_notifications = function_exists('aksrt_get_user_all_notifications')
|
||||||
$all_notifications = function_exists( 'aksrt_get_user_all_notifications' )
|
? aksrt_get_user_all_notifications($user_id)
|
||||||
? aksrt_get_user_all_notifications( $user_id )
|
|
||||||
: [];
|
: [];
|
||||||
|
|
||||||
// 筛选类型
|
$current_type = isset($_GET['msg_type']) ? sanitize_key(wp_unslash((string) $_GET['msg_type'])) : 'unread';
|
||||||
$current_type = isset( $_GET['msg_type'] ) ? sanitize_key( $_GET['msg_type'] ) : 'all';
|
|
||||||
|
|
||||||
// 按类型过滤
|
// 类型分组:对齐 Zibll 主 tab 语义,同时兼容历史 type 键。
|
||||||
$filtered = $all_notifications;
|
$type_groups = [
|
||||||
if ( $current_type === 'unread' ) {
|
'unread' => null, // special: !read
|
||||||
$filtered = array_filter( $filtered, static fn( $n ) => empty( $n['read'] ) );
|
'all' => null, // special: all
|
||||||
} elseif ( $current_type !== 'all' ) {
|
'comment' => ['comment_reply', 'comment_approved', 'pending_comments'],
|
||||||
$filtered = array_filter( $filtered, static fn( $n ) => ( $n['type'] ?? '' ) === $current_type );
|
'credits' => ['credits_added', 'credits_deducted'],
|
||||||
|
'system' => ['notice', 'download_ready', 'upload_moderation', 'verify_email'],
|
||||||
|
'conversation' => ['conversation'],
|
||||||
|
];
|
||||||
|
|
||||||
|
if ($current_type === 'conversation' && !$pm_enabled) {
|
||||||
|
$current_type = 'unread';
|
||||||
}
|
}
|
||||||
$filtered = array_values( $filtered );
|
|
||||||
|
|
||||||
// 分页
|
$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;
|
$per_page = 20;
|
||||||
$current_page = max( 1, (int) ( $_GET['msg_page'] ?? 1 ) );
|
$current_page = max(1, (int) ($_GET['msg_page'] ?? 1));
|
||||||
$total = count( $filtered );
|
$total = count($filtered);
|
||||||
$total_pages = max( 1, (int) ceil( $total / $per_page ) );
|
$total_pages = max(1, (int) ceil($total / $per_page));
|
||||||
$offset = ( $current_page - 1 ) * $per_page;
|
$offset = ($current_page - 1) * $per_page;
|
||||||
$paged_items = array_slice( $filtered, $offset, $per_page );
|
$paged_items = array_slice($filtered, $offset, $per_page);
|
||||||
|
|
||||||
// 统计各类型数量
|
// 统计
|
||||||
$type_counts = [ 'all' => count( $all_notifications ), 'unread' => 0 ];
|
$type_counts = [
|
||||||
foreach ( $all_notifications as $n ) {
|
'all' => count($all_notifications),
|
||||||
$t = $n['type'] ?? 'notice';
|
'unread' => 0,
|
||||||
$type_counts[ $t ] = ( $type_counts[ $t ] ?? 0 ) + 1;
|
'comment'=> 0,
|
||||||
if ( empty( $n['read'] ) ) {
|
'credits'=> 0,
|
||||||
|
'system' => 0,
|
||||||
|
'conversation' => 0,
|
||||||
|
];
|
||||||
|
foreach ($all_notifications as $n) {
|
||||||
|
$t = (string) ($n['type'] ?? 'notice');
|
||||||
|
if (empty($n['read'])) {
|
||||||
$type_counts['unread']++;
|
$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 = [
|
$nav_items = [
|
||||||
'all' => __( '全部消息', 'aksrt' ),
|
'unread' => __('未读消息', 'aksrt'),
|
||||||
'unread' => __( '未读', 'aksrt' ),
|
'all' => __('全部消息', 'aksrt'),
|
||||||
'conversation' => __( '私信', 'aksrt' ),
|
'comment' => __('评论互动', 'aksrt'),
|
||||||
'comment_reply' => __( '评论回复', 'aksrt' ),
|
'credits' => __('积分动态', 'aksrt'),
|
||||||
'comment_approved' => __( '评论审核', 'aksrt' ),
|
'system' => __('系统通知', 'aksrt'),
|
||||||
'credits_added' => __( '积分增加', 'aksrt' ),
|
];
|
||||||
'credits_deducted' => __( '积分扣减', 'aksrt' ),
|
if ($pm_enabled) {
|
||||||
'download_ready' => __( '下载就绪', 'aksrt' ),
|
$nav_items['conversation'] = __('私信消息', 'aksrt');
|
||||||
'upload_moderation'=> __( '图片审核', 'aksrt' ),
|
}
|
||||||
'notice' => __( '系统通知', '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();
|
||||||
$icon_map = [
|
if (!$messages_base) {
|
||||||
'comment_reply' => 'fas fa-comment-dots',
|
$messages_base = get_permalink();
|
||||||
'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',
|
|
||||||
];
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<div class="messages-center container">
|
<main id="main-content" class="site-main content-shell" tabindex="-1">
|
||||||
<aside class="messages-center__nav">
|
<?php if (function_exists('aksrt_breadcrumbs')) { aksrt_breadcrumbs(); } ?>
|
||||||
<ul class="messages-nav__list">
|
|
||||||
<?php foreach ( $nav_items as $key => $label ) :
|
|
||||||
$count = (int) ( $type_counts[ $key ] ?? 0 );
|
|
||||||
if ( $key !== 'all' && $key !== 'unread' && $count < 1 ) continue;
|
|
||||||
$is_active = $current_type === $key;
|
|
||||||
?>
|
|
||||||
<li>
|
|
||||||
<a href="<?php echo esc_url( add_query_arg( [ 'msg_type' => $key, 'msg_page' => 1 ] ) ); ?>"
|
|
||||||
class="messages-nav__item<?php echo $is_active ? ' is-active' : ''; ?>"
|
|
||||||
data-type="<?php echo esc_attr( $key ); ?>">
|
|
||||||
<span><?php echo esc_html( $label ); ?></span>
|
|
||||||
<?php if ( $count > 0 ) : ?>
|
|
||||||
<span class="messages-nav__badge" data-type="<?php echo esc_attr( $key ); ?>" data-count="<?php echo esc_attr( (string) $count ); ?>"><?php echo esc_html( (string) $count ); ?></span>
|
|
||||||
<?php endif; ?>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</ul>
|
|
||||||
<div class="messages-nav__actions">
|
|
||||||
<button type="button" class="messages-nav__action-btn js-msg-mark-all-read"><?php esc_html_e( '全部已读', 'aksrt' ); ?></button>
|
|
||||||
<button type="button" class="messages-nav__action-btn js-msg-clear-read"><?php esc_html_e( '清除已读', 'aksrt' ); ?></button>
|
|
||||||
</div>
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
<main class="messages-center__content">
|
<div class="container">
|
||||||
<?php if ( $current_type === 'conversation' ) :
|
<header class="messages-center__header">
|
||||||
$pm = class_exists( 'AKSRT_Private_Message' ) ? AKSRT_Private_Message::get_instance() : null;
|
<h1 class="messages-center__title"><?php esc_html_e('消息中心', 'aksrt'); ?></h1>
|
||||||
$conversations = $pm ? $pm->get_conversations( $user_id, 30 ) : [];
|
<p class="messages-center__subtitle"><?php esc_html_e('查看站内通知与互动提醒', 'aksrt'); ?></p>
|
||||||
$pm_nonce = wp_create_nonce( 'aksrt_pm' );
|
</header>
|
||||||
?>
|
|
||||||
<div class="messages-conversations" id="aksrt-pm-conversations"
|
<div class="messages-center">
|
||||||
data-ajax="<?php echo esc_url( admin_url( 'admin-ajax.php' ) ); ?>"
|
<aside class="messages-center__nav" aria-label="<?php esc_attr_e('消息分类', 'aksrt'); ?>">
|
||||||
data-nonce="<?php echo esc_attr( $pm_nonce ); ?>">
|
<ul class="messages-nav__list">
|
||||||
<?php if ( ! empty( $conversations ) ) : ?>
|
<?php foreach ($nav_items as $key => $label) :
|
||||||
<div class="aksrt-pm__list">
|
$count = (int) ($type_counts[$key] ?? 0);
|
||||||
<?php foreach ( $conversations as $conv ) : ?>
|
// 始终显示核心 tab;其余无数据时可隐藏(保留 unread/all/system)
|
||||||
<div class="aksrt-pm__item<?php echo $conv['unread'] > 0 ? ' is-unread' : ''; ?>"
|
if (!in_array($key, ['unread', 'all', 'system', 'conversation'], true) && $count < 1) {
|
||||||
data-conv-id="<?php echo esc_attr( (string) $conv['id'] ); ?>"
|
continue;
|
||||||
data-other-id="<?php echo esc_attr( (string) $conv['other_user_id'] ); ?>">
|
}
|
||||||
<img class="aksrt-pm__avatar" src="<?php echo esc_url( $conv['other_avatar'] ); ?>" alt=""<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('avatar') : ' loading="lazy"'; ?> />
|
$is_active = $current_type === $key;
|
||||||
<div class="aksrt-pm__info">
|
$tab_url = add_query_arg(['msg_type' => $key, 'msg_page' => 1], $messages_base);
|
||||||
<div class="aksrt-pm__name">
|
?>
|
||||||
<?php echo esc_html( $conv['other_name'] ); ?>
|
<li>
|
||||||
<?php if ( $conv['unread'] > 0 ) : ?>
|
<a href="<?php echo esc_url($tab_url); ?>"
|
||||||
<span class="aksrt-pm__badge"><?php echo esc_html( (string) $conv['unread'] ); ?></span>
|
class="messages-nav__item<?php echo $is_active ? ' is-active' : ''; ?>"
|
||||||
|
data-type="<?php echo esc_attr($key); ?>">
|
||||||
|
<span><?php echo esc_html($label); ?></span>
|
||||||
|
<?php if ($count > 0) : ?>
|
||||||
|
<span class="messages-nav__badge" data-type="<?php echo esc_attr($key); ?>" data-count="<?php echo esc_attr((string) $count); ?>"><?php echo esc_html((string) $count); ?></span>
|
||||||
|
<?php endif; ?>
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</ul>
|
||||||
|
<div class="messages-nav__actions">
|
||||||
|
<button type="button" class="messages-nav__action-btn js-msg-mark-all-read"><?php esc_html_e('全部已读', 'aksrt'); ?></button>
|
||||||
|
<button type="button" class="messages-nav__action-btn js-msg-clear-read"><?php esc_html_e('清除已读', 'aksrt'); ?></button>
|
||||||
|
</div>
|
||||||
|
</aside>
|
||||||
|
|
||||||
|
<section class="messages-center__content">
|
||||||
|
<?php if ($current_type === 'conversation' && $pm_enabled) :
|
||||||
|
$pm = class_exists('AKSRT_Private_Message') ? AKSRT_Private_Message::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 class="aksrt-pm__avatar" src="<?php echo esc_url((string) ($conv['other_avatar'] ?? '')); ?>" alt=""<?php echo function_exists('aksrt_lazy_loading') ? aksrt_lazy_loading('avatar') : ' loading="lazy"'; ?> />
|
||||||
|
<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="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="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="fas fa-paper-plane"></i></button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<?php elseif (!empty($paged_items)) : ?>
|
||||||
|
<div class="messages-list">
|
||||||
|
<?php foreach ($paged_items as $notice) :
|
||||||
|
$n_type = (string) ($notice['type'] ?? 'notice');
|
||||||
|
$n_title = (string) ($notice['title'] ?? '');
|
||||||
|
$n_desc = (string) ($notice['desc'] ?? '');
|
||||||
|
$n_url = (string) ($notice['url'] ?? '');
|
||||||
|
$n_id = (string) ($notice['id'] ?? '');
|
||||||
|
$is_read = !empty($notice['read']);
|
||||||
|
$is_state = !empty($notice['stateful']);
|
||||||
|
$created = (string) ($notice['created_at'] ?? '');
|
||||||
|
$time_str = $is_state
|
||||||
|
? __('状态提醒', 'aksrt')
|
||||||
|
: ($created !== '' ? get_date_from_gmt($created, 'Y-m-d H:i') : '');
|
||||||
|
$icon_cls = $icon_map[$n_type] ?? 'fas fa-bell';
|
||||||
|
?>
|
||||||
|
<article class="message-item<?php echo !$is_read ? ' is-unread' : ''; ?>" data-notification-id="<?php echo esc_attr($n_id); ?>">
|
||||||
|
<span class="message-item__icon">
|
||||||
|
<i class="<?php echo esc_attr($icon_cls); ?>" aria-hidden="true"></i>
|
||||||
|
</span>
|
||||||
|
<div class="message-item__body">
|
||||||
|
<div class="message-item__title">
|
||||||
|
<?php echo esc_html($n_title); ?>
|
||||||
|
<?php if (!$is_read && !$is_state) : ?>
|
||||||
|
<span class="message-item__new-badge"><?php esc_html_e('新', 'aksrt'); ?></span>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="aksrt-pm__preview"><?php echo esc_html( mb_substr( $conv['last_message'], 0, 50 ) ); ?></div>
|
<?php if ($n_desc !== '') : ?>
|
||||||
|
<div class="message-item__desc"><?php echo esc_html($n_desc); ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if ($time_str !== '') : ?>
|
||||||
|
<div class="message-item__time"><?php echo esc_html($time_str); ?></div>
|
||||||
|
<?php endif; ?>
|
||||||
</div>
|
</div>
|
||||||
<div class="aksrt-pm__time"><?php echo esc_html( $conv['last_message_at'] ? mysql2date( 'm-d H:i', $conv['last_message_at'] ) : '' ); ?></div>
|
<div class="message-item__actions">
|
||||||
</div>
|
<?php if ($n_url !== '') : ?>
|
||||||
|
<a href="<?php echo esc_url($n_url); ?>" class="message-item__action-btn"><?php esc_html_e('查看', 'aksrt'); ?></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (!$is_state && !$is_read) : ?>
|
||||||
|
<button type="button" class="message-item__action-btn js-msg-mark-read" data-id="<?php echo esc_attr($n_id); ?>"><?php esc_html_e('已读', 'aksrt'); ?></button>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php if (!$is_state) : ?>
|
||||||
|
<button type="button" class="message-item__action-btn message-item__action-btn--danger js-msg-delete" data-id="<?php echo esc_attr($n_id); ?>"><?php esc_html_e('删除', 'aksrt'); ?></button>
|
||||||
|
<?php endif; ?>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php if ($total_pages > 1) : ?>
|
||||||
|
<nav class="messages-pagination" aria-label="<?php esc_attr_e('消息分页', 'aksrt'); ?>">
|
||||||
|
<?php for ($i = 1; $i <= $total_pages; $i++) :
|
||||||
|
$page_url = add_query_arg(['msg_type' => $current_type, 'msg_page' => $i], $messages_base);
|
||||||
|
?>
|
||||||
|
<?php if ($i === $current_page) : ?>
|
||||||
|
<span class="profile-status-chip is-active"><?php echo esc_html((string) $i); ?></span>
|
||||||
|
<?php else : ?>
|
||||||
|
<a href="<?php echo esc_url($page_url); ?>" class="profile-status-chip"><?php echo esc_html((string) $i); ?></a>
|
||||||
|
<?php endif; ?>
|
||||||
|
<?php endfor; ?>
|
||||||
|
</nav>
|
||||||
|
<?php endif; ?>
|
||||||
|
|
||||||
<?php else : ?>
|
<?php else : ?>
|
||||||
<div class="messages-empty">
|
<div class="messages-empty">
|
||||||
<span class="messages-empty__icon"><i class="fas fa-envelope"></i></span>
|
<span class="messages-empty__icon"><i class="fas fa-bell-slash"></i></span>
|
||||||
<p class="messages-empty__text"><?php esc_html_e( '暂无私信', 'aksrt' ); ?></p>
|
<p class="messages-empty__text"><?php esc_html_e('暂无消息', 'aksrt'); ?></p>
|
||||||
<p class="messages-empty__hint"><?php esc_html_e( '你可以在用户主页发起私信。', 'aksrt' ); ?></p>
|
|
||||||
</div>
|
</div>
|
||||||
<?php endif; ?>
|
<?php endif; ?>
|
||||||
</div>
|
</section>
|
||||||
|
</div>
|
||||||
<div class="aksrt-pm__thread" id="aksrt-pm-thread" style="display:none;">
|
</div>
|
||||||
<div class="aksrt-pm__thread-header">
|
</main>
|
||||||
<button type="button" class="aksrt-pm__back-btn" id="aksrt-pm-back"><i class="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 esc_attr_e( '输入消息...', 'aksrt' ); ?>"></textarea>
|
|
||||||
<button type="button" id="aksrt-pm-send" class="aksrt-pm__send-btn"><i class="fas fa-paper-plane"></i></button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php /* conversation.js is enqueued via AKSRT_Scripts */ ?>
|
|
||||||
<?php elseif ( ! empty( $paged_items ) ) : ?>
|
|
||||||
<div class="messages-list">
|
|
||||||
<?php foreach ( $paged_items as $notice ) :
|
|
||||||
$n_type = (string) ( $notice['type'] ?? 'notice' );
|
|
||||||
$n_title = (string) ( $notice['title'] ?? '' );
|
|
||||||
$n_desc = (string) ( $notice['desc'] ?? '' );
|
|
||||||
$n_url = (string) ( $notice['url'] ?? '' );
|
|
||||||
$n_id = (string) ( $notice['id'] ?? '' );
|
|
||||||
$is_read = ! empty( $notice['read'] );
|
|
||||||
$is_state = ! empty( $notice['stateful'] );
|
|
||||||
$created = (string) ( $notice['created_at'] ?? '' );
|
|
||||||
$time_str = $is_state
|
|
||||||
? __( '状态提醒', 'aksrt' )
|
|
||||||
: ( $created !== '' ? get_date_from_gmt( $created, 'Y-m-d H:i' ) : '' );
|
|
||||||
$icon_cls = $icon_map[ $n_type ] ?? 'fas fa-bell';
|
|
||||||
?>
|
|
||||||
<div class="message-item<?php echo ! $is_read ? ' is-unread' : ''; ?>" data-notification-id="<?php echo esc_attr( $n_id ); ?>">
|
|
||||||
<span class="message-item__icon">
|
|
||||||
<i class="<?php echo esc_attr( $icon_cls ); ?>" aria-hidden="true"></i>
|
|
||||||
</span>
|
|
||||||
<div class="message-item__body">
|
|
||||||
<div class="message-item__title">
|
|
||||||
<?php echo esc_html( $n_title ); ?>
|
|
||||||
<?php if ( ! $is_read && ! $is_state ) : ?>
|
|
||||||
<span class="message-item__new-badge">NEW</span>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
<?php if ( $n_desc !== '' ) : ?>
|
|
||||||
<div class="message-item__desc"><?php echo esc_html( $n_desc ); ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ( $time_str !== '' ) : ?>
|
|
||||||
<div class="message-item__time"><?php echo esc_html( $time_str ); ?></div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
<div class="message-item__actions">
|
|
||||||
<?php if ( $n_url !== '' ) : ?>
|
|
||||||
<a href="<?php echo esc_url( $n_url ); ?>" class="message-item__action-btn"><?php esc_html_e( '查看', 'aksrt' ); ?></a>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ( ! $is_state && ! $is_read ) : ?>
|
|
||||||
<button type="button" class="message-item__action-btn js-msg-mark-read" data-id="<?php echo esc_attr( $n_id ); ?>"><?php esc_html_e( '已读', 'aksrt' ); ?></button>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php if ( ! $is_state ) : ?>
|
|
||||||
<button type="button" class="message-item__action-btn message-item__action-btn--danger js-msg-delete" data-id="<?php echo esc_attr( $n_id ); ?>"><?php esc_html_e( '删除', 'aksrt' ); ?></button>
|
|
||||||
<?php endif; ?>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<?php endforeach; ?>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php if ( $total_pages > 1 ) : ?>
|
|
||||||
<div class="messages-pagination">
|
|
||||||
<?php for ( $i = 1; $i <= $total_pages; $i++ ) :
|
|
||||||
$page_url = add_query_arg( [ 'msg_type' => $current_type, 'msg_page' => $i ] );
|
|
||||||
?>
|
|
||||||
<?php if ( $i === $current_page ) : ?>
|
|
||||||
<span class="profile-status-chip is-active"><?php echo esc_html( (string) $i ); ?></span>
|
|
||||||
<?php else : ?>
|
|
||||||
<a href="<?php echo esc_url( $page_url ); ?>" class="profile-status-chip"><?php echo esc_html( (string) $i ); ?></a>
|
|
||||||
<?php endif; ?>
|
|
||||||
<?php endfor; ?>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
|
|
||||||
<?php else : ?>
|
|
||||||
<div class="messages-empty">
|
|
||||||
<span class="messages-empty__icon"><i class="fas fa-bell-slash"></i></span>
|
|
||||||
<p class="messages-empty__text"><?php esc_html_e( '暂无消息', 'aksrt' ); ?></p>
|
|
||||||
</div>
|
|
||||||
<?php endif; ?>
|
|
||||||
</main>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<?php get_footer(); ?>
|
<?php get_footer(); ?>
|
||||||
@@ -63,9 +63,12 @@ $classes = trim('article-avatar ' . $extra_class . ($show_actions ? ' article-av
|
|||||||
<i class="far fa-heart" aria-hidden="true"></i>
|
<i class="far fa-heart" aria-hidden="true"></i>
|
||||||
<span><?php esc_html_e('关注', 'aksrt'); ?></span>
|
<span><?php esc_html_e('关注', 'aksrt'); ?></span>
|
||||||
</button>
|
</button>
|
||||||
<?php // 私信为“停用候选”兼容能力:默认不在前台暴露,仅在站点显式开启时显示。 ?>
|
<?php
|
||||||
<?php if (is_user_logged_in()) : ?>
|
$aksrt_pm_on = class_exists('AKSRT_Settings') && !empty(AKSRT_Settings::private_message_settings()['enabled']);
|
||||||
<a href="<?php echo esc_url(add_query_arg('msg_type', 'conversation', function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : home_url('/'))); ?>" class="author-action-btn author-action-btn--ghost">
|
$aksrt_msg_url = function_exists('aksrt_get_messages_page_url') ? aksrt_get_messages_page_url() : '';
|
||||||
|
if ($aksrt_pm_on && $aksrt_msg_url !== '') :
|
||||||
|
?>
|
||||||
|
<a href="<?php echo esc_url(add_query_arg('msg_type', 'conversation', $aksrt_msg_url)); ?>" class="author-action-btn author-action-btn--ghost">
|
||||||
<i class="far fa-comment-dots" aria-hidden="true"></i>
|
<i class="far fa-comment-dots" aria-hidden="true"></i>
|
||||||
<span><?php esc_html_e('私信', 'aksrt'); ?></span>
|
<span><?php esc_html_e('私信', 'aksrt'); ?></span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in new issue
Block a user