用户中心 posts/sidebar/form 渲染器整包拆分并清理标记

This commit is contained in:
kate522 committed 2026-07-10 22:44:15 +08:00
1 parent 81d5647205
commit 57ccdb60c4
13 files changed
+281 -211

No files matched your search

@@ -0,0 +1,34 @@
<?php
/**
* User center profile form: contact rows block.
*
* Expects extracted $context vars.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
if (empty($user_center_settings['social_links'])) {
return;
}
?>
<div class="widget-card">
<h3 class="widget-title"><?php esc_html_e('联系方式', 'aksrt'); ?></h3>
<p class="profile-hint profile-hint--top"><?php esc_html_e('添加你的社交链接,显示在公开用户主页', 'aksrt'); ?></p>
<div id="contacts-list">
<?php foreach ((array) $user_contacts as $i => $contact) : ?>
<div class="contact-row" data-index="<?php echo (int) $i; ?>">
<select name="contacts[<?php echo (int) $i; ?>][icon]" class="profile-input contact-icon">
<?php echo aksrt_contact_icon_options($contact['icon'] ?? ''); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</select>
<input type="hidden" name="contacts[<?php echo (int) $i; ?>][name]" value="">
<input type="url" name="contacts[<?php echo (int) $i; ?>][url]"
value="<?php echo esc_url($contact['url'] ?? ''); ?>"
class="profile-input contact-url" placeholder="<?php esc_attr_e('链接 URL', 'aksrt'); ?>">
<button type="button" class="contact-remove" onclick="this.parentElement.remove()" title="<?php esc_attr_e('删除', 'aksrt'); ?>">&times;</button>
</div>
<?php endforeach; ?>
</div>
<button type="button" class="btn-ghost btn-sm profile-add-contact" id="add-contact-btn">+ <?php esc_html_e('添加联系方式', 'aksrt'); ?></button>
</div>
@@ -0,0 +1,60 @@
<?php
/**
* User center posts: list + pagination.
*
* Expects extracted $context vars.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$ps_args = [
'author' => $user_id,
'post_status' => ('all' === $post_status_filter)
? ['publish', 'draft', 'pending', 'private']
: $post_status_filter,
'posts_per_page' => $per_page,
'paged' => $posts_page,
'no_found_rows' => false,
'update_post_meta_cache' => false,
'update_post_term_cache' => true,
];
$q = new WP_Query($ps_args);
if ($q->have_posts()) :
?>
<div class="profile-list">
<?php
while ($q->have_posts()) :
$q->the_post();
$st = get_post_status();
$status_label = '';
if ('publish' !== $st) {
$st_map = [
'draft' => __('草稿', 'aksrt'),
'pending' => __('待审', 'aksrt'),
'private' => __('私密', 'aksrt'),
'future' => __('定时', 'aksrt'),
];
$status_label = $st_map[$st] ?? $st;
}
$edit_link = get_edit_post_link();
get_template_part('templates/parts/content', 'profile-list-item', [
'action' => $edit_link ? ['type' => 'edit', 'url' => $edit_link, 'label' => __('编辑', 'aksrt')] : [],
'status' => $status_label,
]);
endwhile;
?>
</div>
<?php
aksrt_render_profile_pagination((int) $q->max_num_pages, $posts_page, 'posts_page');
wp_reset_postdata();
else :
aksrt_render_profile_empty(
$svg_empty_post,
__('还没有文章', 'aksrt'),
__('试试发布你的第一篇文章吧。', 'aksrt'),
admin_url('post-new.php'),
__('写文章', 'aksrt')
);
endif;
@@ -0,0 +1,40 @@
<?php
/**
* User center posts: status filter chips.
*
* Expects extracted $context vars.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
$status_chip_defs = [
'publish' => __('已发布', 'aksrt'),
'draft' => __('草稿', 'aksrt'),
'pending' => __('待审', 'aksrt'),
'private' => __('私密', 'aksrt'),
'all' => __('全部', 'aksrt'),
];
?>
<div class="profile-status-filter" role="tablist" aria-label="<?php esc_attr_e('文章状态筛选', 'aksrt'); ?>">
<?php foreach ($status_chip_defs as $status_key => $status_text) :
$count_for_chip = ('all' === $status_key)
? $post_count
: ($user_status_counts[$status_key] ?? 0);
if ('publish' !== $status_key && 'all' !== $status_key && $count_for_chip < 1) {
continue;
}
$chip_url = add_query_arg([
'tab' => 'posts',
'post_status' => $status_key,
'posts_page' => 1,
], remove_query_arg(['posts_page']));
$chip_active = ($post_status_filter === $status_key);
?>
<a href="<?php echo esc_url($chip_url); ?>" class="profile-status-chip<?php echo $chip_active ? ' is-active' : ''; ?>" role="tab" aria-selected="<?php echo $chip_active ? 'true' : 'false'; ?>">
<?php echo esc_html($status_text); ?>
<span class="profile-status-chip__count"><?php echo esc_html((string) $count_for_chip); ?></span>
</a>
<?php endforeach; ?>
</div>
@@ -10,7 +10,6 @@ defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : []; $context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
?> ?>
<!-- ==================== 我的评论 ==================== -->
<div class="widget-card"> <div class="widget-card">
<div class="profile-list-header"> <div class="profile-list-header">
<h3 class="widget-title widget-title--inline"> <h3 class="widget-title widget-title--inline">
@@ -18,7 +17,6 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
</h3> </h3>
</div> </div>
<?php <?php
$comments_total = $comment_count;
$cs = get_comments([ $cs = get_comments([
'user_id' => $user_id, 'user_id' => $user_id,
'number' => $per_page, 'number' => $per_page,
@@ -26,21 +24,24 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
'status' => 'approve', 'status' => 'approve',
'update_comment_meta_cache' => false, 'update_comment_meta_cache' => false,
]); ]);
if ( $cs ) : ?> if ($cs) :
?>
<div class="profile-comment-list"> <div class="profile-comment-list">
<?php foreach ( $cs as $c ) : <?php
foreach ($cs as $c) {
get_template_part('templates/parts/content', 'profile-comment-item', ['comment' => $c]); get_template_part('templates/parts/content', 'profile-comment-item', ['comment' => $c]);
endforeach; ?> }
?>
</div> </div>
<?php <?php
$comments_total_pages = (int) ceil( $comments_total / $per_page ); $comments_total_pages = (int) ceil($comment_count / $per_page);
aksrt_render_profile_pagination($comments_total_pages, $comments_page, 'comments_page'); aksrt_render_profile_pagination($comments_total_pages, $comments_page, 'comments_page');
?> else :
<?php else :
aksrt_render_profile_empty( aksrt_render_profile_empty(
$svg_empty_comment, $svg_empty_comment,
__('暂无评论', 'aksrt'), __('暂无评论', 'aksrt'),
__('在你感兴趣的文章下留下你的看法吧。', 'aksrt') __('在你感兴趣的文章下留下你的看法吧。', 'aksrt')
); );
endif; ?> endif;
?>
</div> </div>
@@ -10,7 +10,6 @@ defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : []; $context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
?> ?>
<!-- ==================== 我的收藏 ==================== -->
<div class="widget-card"> <div class="widget-card">
<div class="profile-list-header"> <div class="profile-list-header">
<h3 class="widget-title widget-title--inline"> <h3 class="widget-title widget-title--inline">
@@ -29,9 +28,12 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
'no_found_rows' => false, 'no_found_rows' => false,
'update_post_meta_cache' => false, 'update_post_meta_cache' => false,
]); ]);
if ( $favorites_query->have_posts() ) : ?> if ($favorites_query->have_posts()) :
?>
<div class="profile-list" data-list="favorites"> <div class="profile-list" data-list="favorites">
<?php while ( $favorites_query->have_posts() ) : $favorites_query->the_post(); <?php
while ($favorites_query->have_posts()) :
$favorites_query->the_post();
get_template_part('templates/parts/content', 'profile-list-item', [ get_template_part('templates/parts/content', 'profile-list-item', [
'action' => [ 'action' => [
'type' => 'unfavorite', 'type' => 'unfavorite',
@@ -39,10 +41,11 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
'label' => __('取消收藏', 'aksrt'), 'label' => __('取消收藏', 'aksrt'),
], ],
]); ]);
endwhile; ?> endwhile;
?>
</div> </div>
<?php aksrt_render_profile_pagination( (int) $favorites_query->max_num_pages, $favorites_page, 'favorites_page' ); ?>
<?php <?php
aksrt_render_profile_pagination((int) $favorites_query->max_num_pages, $favorites_page, 'favorites_page');
wp_reset_postdata(); wp_reset_postdata();
else : else :
aksrt_render_profile_empty( aksrt_render_profile_empty(
@@ -61,5 +64,6 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
home_url('/'), home_url('/'),
__('去发现好文', 'aksrt') __('去发现好文', 'aksrt')
); );
endif; ?> endif;
?>
</div> </div>
@@ -1,6 +1,6 @@
<?php <?php
/** /**
* User center profile form part. * User center profile form part (orchestrator).
* *
* @package AKSRT * @package AKSRT
*/ */
@@ -10,13 +10,11 @@ defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : []; $context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
?> ?>
<!-- ==================== 个人信息(可编辑) ==================== -->
<form class="profile-form" id="profile-form" method="post"> <form class="profile-form" id="profile-form" method="post">
<?php wp_nonce_field('aksrt_profile_save', '_profile_nonce'); ?> <?php wp_nonce_field('aksrt_profile_save', '_profile_nonce'); ?>
<input type="hidden" name="action" value="aksrt_save_profile"> <input type="hidden" name="action" value="aksrt_save_profile">
<input type="hidden" name="user_id" value="<?php echo (int) $user_id; ?>"> <input type="hidden" name="user_id" value="<?php echo (int) $user_id; ?>">
<!-- 昵称 -->
<div class="widget-card"> <div class="widget-card">
<h3 class="widget-title"><?php esc_html_e('昵称', 'aksrt'); ?></h3> <h3 class="widget-title"><?php esc_html_e('昵称', 'aksrt'); ?></h3>
<input type="text" name="nickname" id="profile-nickname" <input type="text" name="nickname" id="profile-nickname"
@@ -25,7 +23,6 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
<p class="profile-hint"><?php esc_html_e('修改后会同步更新个人主页地址', 'aksrt'); ?></p> <p class="profile-hint"><?php esc_html_e('修改后会同步更新个人主页地址', 'aksrt'); ?></p>
</div> </div>
<!-- 个人简介 -->
<div class="widget-card"> <div class="widget-card">
<h3 class="widget-title"><?php esc_html_e('个人简介', 'aksrt'); ?></h3> <h3 class="widget-title"><?php esc_html_e('个人简介', 'aksrt'); ?></h3>
<textarea name="description" id="profile-bio" class="profile-input profile-textarea" <textarea name="description" id="profile-bio" class="profile-input profile-textarea"
@@ -33,30 +30,8 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
<p class="profile-hint"><?php esc_html_e('显示在你的公开用户主页上,最多 500 字', 'aksrt'); ?></p> <p class="profile-hint"><?php esc_html_e('显示在你的公开用户主页上,最多 500 字', 'aksrt'); ?></p>
</div> </div>
<?php if ( ! empty( $user_center_settings['social_links'] ) ) : ?> <?php require __DIR__ . '/form-contacts.php'; ?>
<!-- 联系方式 -->
<div class="widget-card">
<h3 class="widget-title"><?php esc_html_e( '联系方式', 'aksrt' ); ?></h3>
<p class="profile-hint profile-hint--top"><?php esc_html_e( '添加你的社交链接,显示在公开用户主页', 'aksrt' ); ?></p>
<div id="contacts-list">
<?php foreach ( $user_contacts as $i => $contact ) : ?>
<div class="contact-row" data-index="<?php echo (int) $i; ?>">
<select name="contacts[<?php echo (int) $i; ?>][icon]" class="profile-input contact-icon">
<?php echo aksrt_contact_icon_options( $contact['icon'] ?? '' ); ?>
</select>
<input type="hidden" name="contacts[<?php echo (int) $i; ?>][name]" value="">
<input type="url" name="contacts[<?php echo (int) $i; ?>][url]"
value="<?php echo esc_url( $contact['url'] ?? '' ); ?>"
class="profile-input contact-url" placeholder="<?php esc_attr_e( '链接 URL', 'aksrt' ); ?>">
<button type="button" class="contact-remove" onclick="this.parentElement.remove()" title="<?php esc_attr_e( '删除', 'aksrt' ); ?>">&times;</button>
</div>
<?php endforeach; ?>
</div>
<button type="button" class="btn-ghost btn-sm profile-add-contact" id="add-contact-btn">+ <?php esc_html_e( '添加联系方式', 'aksrt' ); ?></button>
</div>
<?php endif; ?>
<!-- 保存按钮 -->
<div class="profile-form__submit"> <div class="profile-form__submit">
<button type="submit" class="btn-primary btn-lg" id="profile-save-btn"> <button type="submit" class="btn-primary btn-lg" id="profile-save-btn">
<?php esc_html_e('保存修改', 'aksrt'); ?> <?php esc_html_e('保存修改', 'aksrt'); ?>
@@ -10,7 +10,6 @@ defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : []; $context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
?> ?>
<!-- 头图 + 用户卡 -->
<div class="uc-header"> <div class="uc-header">
<div class="uc-header__cover"> <div class="uc-header__cover">
<img id="aksrt-cover-img" class="uc-header__cover-img" src="<?php echo esc_url($user_background_url ? $user_background_url : get_theme_file_uri('assets/img/person_background.png')); ?>" alt=""> <img id="aksrt-cover-img" class="uc-header__cover-img" src="<?php echo esc_url($user_background_url ? $user_background_url : get_theme_file_uri('assets/img/person_background.png')); ?>" alt="">
@@ -25,14 +24,16 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
</div> </div>
<div class="uc-header__content"> <div class="uc-header__content">
<div class="uc-header__avatar"> <div class="uc-header__avatar">
<?php echo get_avatar( $user_id, 120, '', $target_user->display_name ); ?> <?php echo get_avatar($user_id, 120, '', $target_user->display_name); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div> </div>
<div class="uc-header__info"> <div class="uc-header__info">
<h1 class="uc-header__name"> <h1 class="uc-header__name">
<?php echo esc_html($target_user->display_name); ?> <?php echo esc_html($target_user->display_name); ?>
<?php <?php
$vip_badge = function_exists('aksrt_render_vip_badge') ? aksrt_render_vip_badge($user_id) : ''; $vip_badge = function_exists('aksrt_render_vip_badge') ? aksrt_render_vip_badge($user_id) : '';
if ($vip_badge) echo $vip_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped if ($vip_badge) {
echo $vip_badge; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped
}
?> ?>
</h1> </h1>
<?php if ($target_user->description) : ?> <?php if ($target_user->description) : ?>
@@ -1,6 +1,6 @@
<?php <?php
/** /**
* User center profile posts part. * User center profile posts part (orchestrator).
* *
* @package AKSRT * @package AKSRT
*/ */
@@ -10,7 +10,6 @@ defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : []; $context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
?> ?>
<!-- ==================== 我的文章 ==================== -->
<div class="widget-card"> <div class="widget-card">
<div class="profile-list-header"> <div class="profile-list-header">
<h3 class="widget-title widget-title--inline"> <h3 class="widget-title widget-title--inline">
@@ -19,83 +18,7 @@ extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_
printf(esc_html__('我的文章(%d 篇)', 'aksrt'), $post_count); printf(esc_html__('我的文章(%d 篇)', 'aksrt'), $post_count);
?> ?>
</h3> </h3>
<?php <?php require __DIR__ . '/posts-status-filter.php'; ?>
$status_chip_defs = [
'publish' => __( '已发布', 'aksrt' ),
'draft' => __( '草稿', 'aksrt' ),
'pending' => __( '待审', 'aksrt' ),
'private' => __( '私密', 'aksrt' ),
'all' => __( '全部', 'aksrt' ),
];
?>
<div class="profile-status-filter" role="tablist" aria-label="<?php esc_attr_e( '文章状态筛选', 'aksrt' ); ?>">
<?php foreach ( $status_chip_defs as $status_key => $status_text ) :
$count_for_chip = ( 'all' === $status_key )
? $post_count
: ( $user_status_counts[ $status_key ] ?? 0 );
if ( 'publish' !== $status_key && 'all' !== $status_key && $count_for_chip < 1 ) {
continue;
}
$chip_url = add_query_arg( [
'tab' => 'posts',
'post_status' => $status_key,
'posts_page' => 1,
], remove_query_arg( [ 'posts_page' ] ) );
$chip_active = ( $post_status_filter === $status_key );
?>
<a href="<?php echo esc_url( $chip_url ); ?>" class="profile-status-chip<?php echo $chip_active ? ' is-active' : ''; ?>" role="tab" aria-selected="<?php echo $chip_active ? 'true' : 'false'; ?>">
<?php echo esc_html( $status_text ); ?>
<span class="profile-status-chip__count"><?php echo esc_html( (string) $count_for_chip ); ?></span>
</a>
<?php endforeach; ?>
</div> </div>
</div> <?php require __DIR__ . '/posts-list.php'; ?>
<?php
$ps_args = [
'author' => $user_id,
'post_status' => ( 'all' === $post_status_filter )
? [ 'publish', 'draft', 'pending', 'private' ]
: $post_status_filter,
'posts_per_page' => $per_page,
'paged' => $posts_page,
'no_found_rows' => false,
'update_post_meta_cache' => false,
'update_post_term_cache' => true,
];
$q = new WP_Query( $ps_args );
if ( $q->have_posts() ) : ?>
<div class="profile-list">
<?php while ( $q->have_posts() ) : $q->the_post();
$st = get_post_status();
$status_label = '';
if ( 'publish' !== $st ) {
$st_map = [
'draft' => __( '草稿', 'aksrt' ),
'pending' => __( '待审', 'aksrt' ),
'private' => __( '私密', 'aksrt' ),
'future' => __( '定时', 'aksrt' ),
];
$status_label = $st_map[ $st ] ?? $st;
}
$edit_link = get_edit_post_link();
get_template_part('templates/parts/content', 'profile-list-item', [
'action' => $edit_link ? ['type' => 'edit', 'url' => $edit_link, 'label' => __('编辑', 'aksrt')] : [],
'status' => $status_label,
]);
endwhile; ?>
</div>
<?php aksrt_render_profile_pagination( (int) $q->max_num_pages, $posts_page, 'posts_page' ); ?>
<?php
wp_reset_postdata();
else :
aksrt_render_profile_empty(
$svg_empty_post,
__( '还没有文章', 'aksrt' ),
__( '试试发布你的第一篇文章吧。', 'aksrt' ),
admin_url( 'post-new.php' ),
__( '写文章', 'aksrt' )
);
endif; ?>
</div> </div>
@@ -1,6 +1,6 @@
<?php <?php
/** /**
* User center profile sidebar part. * User center profile sidebar part (orchestrator).
* *
* @package AKSRT * @package AKSRT
*/ */
@@ -9,86 +9,11 @@ defined('ABSPATH') || exit;
$context = is_array($args['context'] ?? null) ? $args['context'] : []; $context = is_array($args['context'] ?? null) ? $args['context'] : [];
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
require __DIR__ . '/sidebar-stats.php';
require __DIR__ . '/sidebar-nav.php';
require __DIR__ . '/sidebar-commerce.php';
?> ?>
<!-- 数据统计 -->
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e( '数据统计', 'aksrt' ); ?></div>
<div class="uc-stats">
<?php foreach ( [ 'posts', 'comments', 'favorites' ] as $stat_tab ) : ?>
<?php if ( ! isset( $dashboard_tabs[ $stat_tab ] ) ) { continue; } ?>
<?php
$stat_count = 'posts' === $stat_tab
? $post_count
: ( 'comments' === $stat_tab ? $comment_count : $favorite_count );
?>
<a class="uc-stats__item" href="<?php echo esc_url( add_query_arg( 'tab', $stat_tab, remove_query_arg( 'tab' ) ) ); ?>">
<span class="uc-stats__value"><?php echo esc_html( (string) $stat_count ); ?></span>
<span class="uc-stats__label"><?php echo esc_html( $dashboard_tabs[ $stat_tab ]['label'] ); ?></span>
</a>
<?php endforeach; ?>
<a class="uc-stats__item" href="<?php echo esc_url( $messages_url ); ?>">
<span class="uc-stats__value"><?php echo esc_html( (string) $notification_unread_count ); ?></span>
<span class="uc-stats__label"><?php esc_html_e( '通知', 'aksrt' ); ?></span>
</a>
</div>
</div>
<!-- 我的服务 -->
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e( '我的服务', 'aksrt' ); ?></div>
<div class="uc-sidebar__buttons">
<?php foreach ( $dashboard_tabs as $tab_key => $tab ) : ?>
<a class="uc-sidebar__btn<?php echo $active_tab === $tab_key ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url($tab_key)); ?>" data-tab="<?php echo esc_attr($tab_key); ?>">
<i class="fas fa-<?php echo esc_attr( $tab['icon'] ); ?>" aria-hidden="true"></i>
<span><?php echo esc_html( $tab['label'] ); ?></span>
</a>
<?php endforeach; ?>
<a href="<?php echo esc_url( $messages_url ); ?>" class="uc-sidebar__btn">
<i class="fas fa-bell" aria-hidden="true"></i>
<span><?php esc_html_e( '消息通知', 'aksrt' ); ?></span>
<?php if ( $notification_unread_count > 0 ) : ?>
<span class="uc-sidebar__badge"><?php echo esc_html( (string) $notification_unread_count ); ?></span>
<?php endif; ?>
</a>
</div>
</div>
<!-- 交易服务 -->
<?php if ($orders_url || $show_vip || $show_credit_tabs) : ?>
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e('权益与消费', 'aksrt'); ?></div>
<div class="uc-sidebar__buttons">
<?php if ($orders_url) : ?>
<a href="<?php echo esc_url($orders_url); ?>" class="uc-sidebar__btn">
<i class="fas fa-receipt" aria-hidden="true"></i>
<span><?php esc_html_e('我的订单', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<?php if ($show_vip) : ?>
<a class="uc-sidebar__btn<?php echo $active_tab === 'credits' ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url('credits')); ?>" data-tab="credits">
<i class="fas fa-crown" aria-hidden="true"></i>
<span><?php esc_html_e('VIP 会员', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<?php if ($show_credit_tabs) : ?>
<a class="uc-sidebar__btn<?php echo $active_tab === 'credits' ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url('credits')); ?>" data-tab="credits">
<i class="fas fa-coins" aria-hidden="true"></i>
<span><?php echo esc_html($currency_name); ?></span>
</a>
<?php endif; ?>
<?php if ($affiliate_enabled) : ?>
<a class="uc-sidebar__btn<?php echo $active_tab === 'credits' ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url('credits')); ?>" data-tab="credits">
<i class="fas fa-share-alt" aria-hidden="true"></i>
<span><?php esc_html_e('推广返佣', 'aksrt'); ?></span>
</a>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<!-- 功能设置 -->
<!-- 移动端抽屉触发器 -->
<button type="button" class="uc-sidebar__drawer-trigger" id="uc-drawer-trigger" aria-label="<?php esc_attr_e('打开导航', 'aksrt'); ?>"> <button type="button" class="uc-sidebar__drawer-trigger" id="uc-drawer-trigger" aria-label="<?php esc_attr_e('打开导航', 'aksrt'); ?>">
<i class="fas fa-bars" aria-hidden="true"></i> <i class="fas fa-bars" aria-hidden="true"></i>
</button> </button>
@@ -0,0 +1,44 @@
<?php
/**
* User center sidebar: rights / commerce shortcuts.
*
* Expects extracted $context vars.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
if (empty($orders_url) && empty($show_vip) && empty($show_credit_tabs)) {
return;
}
?>
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e('权益与消费', 'aksrt'); ?></div>
<div class="uc-sidebar__buttons">
<?php if ($orders_url) : ?>
<a href="<?php echo esc_url($orders_url); ?>" class="uc-sidebar__btn">
<i class="fas fa-receipt" aria-hidden="true"></i>
<span><?php esc_html_e('我的订单', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<?php if ($show_vip) : ?>
<a class="uc-sidebar__btn<?php echo $active_tab === 'credits' ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url('credits')); ?>" data-tab="credits">
<i class="fas fa-crown" aria-hidden="true"></i>
<span><?php esc_html_e('VIP 会员', 'aksrt'); ?></span>
</a>
<?php endif; ?>
<?php if ($show_credit_tabs) : ?>
<a class="uc-sidebar__btn<?php echo $active_tab === 'credits' ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url('credits')); ?>" data-tab="credits">
<i class="fas fa-coins" aria-hidden="true"></i>
<span><?php echo esc_html($currency_name); ?></span>
</a>
<?php endif; ?>
<?php if (!empty($affiliate_enabled)) : ?>
<a class="uc-sidebar__btn<?php echo $active_tab === 'credits' ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url('credits')); ?>" data-tab="credits">
<i class="fas fa-share-alt" aria-hidden="true"></i>
<span><?php esc_html_e('推广返佣', 'aksrt'); ?></span>
</a>
<?php endif; ?>
</div>
</div>
@@ -0,0 +1,29 @@
<?php
/**
* User center sidebar: main service navigation.
*
* Expects extracted $context vars.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
?>
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e('我的服务', 'aksrt'); ?></div>
<div class="uc-sidebar__buttons">
<?php foreach ($dashboard_tabs as $tab_key => $tab) : ?>
<a class="uc-sidebar__btn<?php echo $active_tab === $tab_key ? ' is-active' : ''; ?>" href="<?php echo esc_url(aksrt_get_user_center_tab_url($tab_key)); ?>" data-tab="<?php echo esc_attr($tab_key); ?>">
<i class="fas fa-<?php echo esc_attr($tab['icon']); ?>" aria-hidden="true"></i>
<span><?php echo esc_html($tab['label']); ?></span>
</a>
<?php endforeach; ?>
<a href="<?php echo esc_url($messages_url); ?>" class="uc-sidebar__btn">
<i class="fas fa-bell" aria-hidden="true"></i>
<span><?php esc_html_e('消息通知', 'aksrt'); ?></span>
<?php if ($notification_unread_count > 0) : ?>
<span class="uc-sidebar__badge"><?php echo esc_html((string) $notification_unread_count); ?></span>
<?php endif; ?>
</a>
</div>
</div>
@@ -0,0 +1,32 @@
<?php
/**
* User center sidebar: stats section.
*
* Expects extracted $context vars.
*
* @package AKSRT
*/
defined('ABSPATH') || exit;
?>
<div class="uc-sidebar__section">
<div class="uc-sidebar__title"><?php esc_html_e('数据统计', 'aksrt'); ?></div>
<div class="uc-stats">
<?php foreach (['posts', 'comments', 'favorites'] as $stat_tab) : ?>
<?php if (!isset($dashboard_tabs[$stat_tab])) { continue; } ?>
<?php
$stat_count = 'posts' === $stat_tab
? $post_count
: ('comments' === $stat_tab ? $comment_count : $favorite_count);
?>
<a class="uc-stats__item" href="<?php echo esc_url(add_query_arg('tab', $stat_tab, remove_query_arg('tab'))); ?>">
<span class="uc-stats__value"><?php echo esc_html((string) $stat_count); ?></span>
<span class="uc-stats__label"><?php echo esc_html($dashboard_tabs[$stat_tab]['label']); ?></span>
</a>
<?php endforeach; ?>
<a class="uc-stats__item" href="<?php echo esc_url($messages_url); ?>">
<span class="uc-stats__value"><?php echo esc_html((string) $notification_unread_count); ?></span>
<span class="uc-stats__label"><?php esc_html_e('通知', 'aksrt'); ?></span>
</a>
</div>
</div>
+8 -6
View File
@@ -7,12 +7,14 @@
- aksrt_user_center_resolve_tabs() - aksrt_user_center_resolve_tabs()
- aksrt_capture_user_center_view() (profile → form 映射) - aksrt_capture_user_center_view() (profile → form 映射)
- 挂载点:header / sidebar / mobile-tabs / panel / account-modals / runtime-config - 挂载点:header / sidebar / mobile-tabs / panel / account-modals / runtime-config
- 渲染器:inc/helpers/user-center-renderers/
- profile-form / posts / comments / favorites / header / sidebar / account-modals 渲染器(inc/helpers/user-center-renderers/):
- profile-credits.php 编排: - profile-form.php → form-contacts.php
credits-balance / credits-vip / credits-signin / credits-transactions - profile-posts.php → posts-status-filter.php + posts-list.php
- profile-settings.php 编排: - profile-sidebar.php → sidebar-stats/nav/commerce.php
settings-bindings / settings-security / settings-invite / settings-runtime-fields - profile-credits.php → credits-balance/vip/signin/transactions.php
- profile-settings.php → settings-bindings/security/invite/runtime-fields.php
- profile-header / comments / favorites / account-modals
样式归属: 样式归属:
- assets/css/routes/user-center.css - assets/css/routes/user-center.css