导入 AKSRT 主题开发源码

This commit is contained in:
Claude Code
2026-07-03 22:50:34 +08:00
parent 9681dd3d48
commit 1268a55dd0
595 changed files with 127705 additions and 0 deletions
+1
View File
@@ -0,0 +1 @@
<!-- 公开用户主页 partial 模板目录 -->
+76
View File
@@ -0,0 +1,76 @@
<?php
/**
* 公开用户主页 — 评论列表
*
* @package AKSRT
* @since 5.0.0
*/
defined('ABSPATH') || exit;
$user_id = $args['user_id'] ?? 0;
$per_page = $args['per_page'] ?? 15;
$paged = max(1, get_query_var('paged'));
$total = get_comments([
'user_id' => $user_id,
'status' => 'approve',
'post_status' => 'publish',
'count' => true,
]);
$comments = get_comments([
'user_id' => $user_id,
'status' => 'approve',
'post_status' => 'publish',
'number' => $per_page,
'offset' => ($paged - 1) * $per_page,
'orderby' => 'comment_date_gmt',
'order' => 'DESC',
]);
$max_pages = ceil($total / $per_page);
?>
<div class="uh-comments">
<?php if (!empty($comments)) : ?>
<div class="uh-comments__list">
<?php foreach ($comments as $comment) :
$post = get_post($comment->comment_post_ID);
if (!$post) continue;
?>
<div class="uh-comments__item">
<div class="uh-comments__header">
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>" class="uh-comments__post-title">
<?php echo esc_html($post->post_title); ?>
</a>
<span class="uh-comments__date"><?php echo esc_html(get_comment_date('Y-m-d', $comment)); ?></span>
</div>
<div class="uh-comments__body">
<?php echo function_exists('aksrt_render_comment_content') ? aksrt_render_comment_content((string) get_comment_text($comment)) : wp_kses_post((string) $comment->comment_content); // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?>
</div>
</div>
<?php endforeach; ?>
</div>
<?php if ($max_pages > 1) : ?>
<div class="aksrt-pagination">
<?php
echo paginate_links([
'base' => str_replace(999999999, '%#%', esc_url(get_pagenum_link(999999999))),
'format' => '?tab=comments&paged=%#%',
'current' => $paged,
'total' => $max_pages,
'prev_text' => '<i class="fas fa-chevron-left"></i>',
'next_text' => '<i class="fas fa-chevron-right"></i>',
]);
?>
</div>
<?php endif; ?>
<?php else : ?>
<div class="empty-state empty-state--sm">
<div class="empty-state__icon"><i class="far fa-comment-dots"></i></div>
<p class="empty-state__title"><?php esc_html_e('暂无评论', 'aksrt'); ?></p>
</div>
<?php endif; ?>
</div>
+66
View File
@@ -0,0 +1,66 @@
<?php
/**
* 公开用户主页 — Hero 封面区
*
* @package AKSRT
* @since 5.0.0
*/
defined('ABSPATH') || exit;
$user = $args['user'] ?? null;
$user_id = $user ? (int) $user->ID : 0;
$dashboard = $args['dashboard'] ?? [];
$settings = $args['settings'] ?? [];
$show_cover = $settings['cover'] ?? true;
$show_follow = $settings['follow'] ?? true;
$is_own = $dashboard['is_own_profile'] ?? false;
$viewer_id = $dashboard['viewer_id'] ?? 0;
if (!$user) return;
$cover_url = get_user_meta($user_id, 'aksrt_user_cover', true) ?: '';
$avatar = get_avatar_url($user_id, ['size' => 96]);
$desc = $user->description ?: '';
$is_vip = function_exists('aksrt_is_vip') && aksrt_is_vip($user_id);
?>
<div class="uh-hero <?php echo $cover_url ? 'uh-hero--has-cover' : ''; ?>" <?php echo $cover_url ? 'style="background-image:url(' . esc_url($cover_url) . ')"' : ''; ?>>
<div class="uh-hero__overlay"></div>
<div class="uh-hero__content">
<div class="uh-hero__avatar">
<img src="<?php echo esc_url($avatar); ?>" alt="<?php echo esc_attr($user->display_name); ?>" width="96" height="96">
<?php if ($is_vip) : ?>
<span class="aksrt-vip-badge">VIP</span>
<?php endif; ?>
</div>
<div class="uh-hero__info">
<h2 class="uh-hero__name">
<?php echo esc_html($user->display_name); ?>
<?php if ($is_own) : ?>
<a href="<?php echo esc_url(get_edit_profile_url($user_id)); ?>" class="uh-hero__edit" title="<?php esc_attr_e('编辑资料', 'aksrt'); ?>">
<i class="fas fa-pen"></i>
</a>
<?php endif; ?>
</h2>
<?php if ($desc) : ?>
<p class="uh-hero__desc"><?php echo esc_html(wp_trim_words($desc, 50)); ?></p>
<?php endif; ?>
<div class="uh-hero__meta">
<span><i class="fas fa-calendar-alt"></i> <?php echo esc_html(date_i18n(get_option('date_format'), strtotime($user->user_registered))); ?></span>
<span><i class="fas fa-file-alt"></i> <?php echo esc_html($dashboard['post_count'] ?? 0); ?> <?php esc_html_e('篇文章', 'aksrt'); ?></span>
</div>
</div>
<?php if ($show_follow && !$is_own && $viewer_id > 0) : ?>
<?php
$is_following = function_exists('aksrt_is_following') && aksrt_is_following($viewer_id, $user_id);
?>
<button class="btn <?php echo $is_following ? 'btn-outline-primary' : 'btn-primary'; ?> uh-hero__follow-btn"
data-action="toggle-follow"
data-target-user="<?php echo esc_attr($user_id); ?>">
<i class="fas <?php echo $is_following ? 'fa-user-check' : 'fa-user-plus'; ?>"></i>
<?php echo $is_following ? esc_html__('已关注', 'aksrt') : esc_html__('关注', 'aksrt'); ?>
</button>
<?php endif; ?>
</div>
</div>
+55
View File
@@ -0,0 +1,55 @@
<?php
/**
* 公开用户主页 — 文章列表
*
* @package AKSRT
* @since 5.0.0
*/
defined('ABSPATH') || exit;
$user_id = $args['user_id'] ?? 0;
$per_page = $args['per_page'] ?? 10;
$paged = max(1, get_query_var('paged'));
$query = new WP_Query([
'author' => $user_id,
'post_type' => 'post',
'post_status' => 'publish',
'posts_per_page' => $per_page,
'paged' => $paged,
'no_found_rows' => false,
]);
if (!$query->have_posts()) :
wp_reset_postdata();
?>
<div class="empty-state empty-state--sm">
<div class="empty-state__icon"><i class="far fa-file-alt"></i></div>
<p class="empty-state__title"><?php esc_html_e('暂无文章', 'aksrt'); ?></p>
</div>
<?php return;
endif;
?>
<div class="uh-posts">
<?php while ($query->have_posts()) : $query->the_post(); ?>
<?php get_template_part('templates/parts/content-post-card'); ?>
<?php endwhile; ?>
<?php if ($query->max_num_pages > 1) : ?>
<div class="aksrt-pagination">
<?php
echo paginate_links([
'base' => str_replace(999999999, '%#%', esc_url(get_pagenum_link(999999999))),
'format' => '?tab=posts&paged=%#%',
'current' => $paged,
'total' => $query->max_num_pages,
'prev_text' => '<i class="fas fa-chevron-left"></i>',
'next_text' => '<i class="fas fa-chevron-right"></i>',
]);
?>
</div>
<?php endif; ?>
<?php wp_reset_postdata(); ?>
</div>
+106
View File
@@ -0,0 +1,106 @@
<?php
/**
* 公开用户主页 — 侧边栏
*
* @package AKSRT
* @since 5.0.0
*/
defined('ABSPATH') || exit;
$user = $args['user'] ?? null;
$user_id = $user ? (int) $user->ID : 0;
$dashboard = $args['dashboard'] ?? [];
$settings = $args['settings'] ?? [];
$show_follow = $settings['follow'] ?? true;
$is_own = $dashboard['is_own_profile'] ?? false;
$viewer_id = $dashboard['viewer_id'] ?? 0;
$contacts = $dashboard['user_contacts'] ?? [];
if (!$user) return;
?>
<div class="uh-sidebar">
<!-- 数据统计 -->
<div class="widget">
<div class="widget-title"><i class="fas fa-chart-bar"></i> <?php esc_html_e('数据概览', 'aksrt'); ?></div>
<div class="widget-content">
<div class="uh-sidebar__stats">
<div class="uh-sidebar__stat">
<span class="uh-sidebar__stat-num"><?php echo esc_html($dashboard['post_count'] ?? 0); ?></span>
<span class="uh-sidebar__stat-label"><?php esc_html_e('文章', 'aksrt'); ?></span>
</div>
<div class="uh-sidebar__stat">
<span class="uh-sidebar__stat-num"><?php echo esc_html($dashboard['comment_count'] ?? 0); ?></span>
<span class="uh-sidebar__stat-label"><?php esc_html_e('评论', 'aksrt'); ?></span>
</div>
<div class="uh-sidebar__stat">
<span class="uh-sidebar__stat-num"><?php echo esc_html($dashboard['follower_count'] ?? 0); ?></span>
<span class="uh-sidebar__stat-label"><?php esc_html_e('粉丝', 'aksrt'); ?></span>
</div>
</div>
</div>
</div>
<!-- 社交链接 -->
<?php if (!empty($contacts)) : ?>
<div class="widget">
<div class="widget-title"><i class="fas fa-link"></i> <?php esc_html_e('社交链接', 'aksrt'); ?></div>
<div class="widget-content">
<div class="uh-sidebar__contacts">
<?php foreach ($contacts as $contact) : ?>
<a href="<?php echo esc_url($contact['url'] ?? '#'); ?>" target="_blank" rel="noopener noreferrer" class="uh-sidebar__contact" title="<?php echo esc_attr($contact['name'] ?? ''); ?>">
<i class="fab fa-<?php echo esc_attr($contact['icon'] ?? 'link'); ?>"></i>
<span><?php echo esc_html($contact['name'] ?? ''); ?></span>
</a>
<?php endforeach; ?>
</div>
</div>
</div>
<?php endif; ?>
<!-- 关注/粉丝 -->
<?php if ($show_follow && !$is_own && $viewer_id > 0) : ?>
<?php
$following_ids = function_exists('aksrt_get_following_ids') ? aksrt_get_following_ids($user_id, 6) : [];
$follower_ids = function_exists('aksrt_get_follower_ids') ? aksrt_get_follower_ids($user_id, 6) : [];
?>
<?php if (!empty($following_ids) || !empty($follower_ids)) : ?>
<div class="widget">
<div class="widget-title"><i class="fas fa-users"></i> <?php esc_html_e('社交关系', 'aksrt'); ?></div>
<div class="widget-content">
<?php if (!empty($following_ids)) : ?>
<div class="uh-sidebar__follow-section">
<span class="uh-sidebar__follow-label"><?php esc_html_e('关注', 'aksrt'); ?></span>
<div class="uh-sidebar__avatars">
<?php foreach ($following_ids as $fid) :
$f_user = get_userdata($fid);
if (!$f_user) continue;
?>
<a href="<?php echo esc_url(get_author_posts_url($fid)); ?>">
<?php echo get_avatar($fid, 32); ?>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
<?php if (!empty($follower_ids)) : ?>
<div class="uh-sidebar__follow-section">
<span class="uh-sidebar__follow-label"><?php esc_html_e('粉丝', 'aksrt'); ?></span>
<div class="uh-sidebar__avatars">
<?php foreach ($follower_ids as $fid) :
$f_user = get_userdata($fid);
if (!$f_user) continue;
?>
<a href="<?php echo esc_url(get_author_posts_url($fid)); ?>">
<?php echo get_avatar($fid, 32); ?>
</a>
<?php endforeach; ?>
</div>
</div>
<?php endif; ?>
</div>
</div>
<?php endif; ?>
<?php endif; ?>
</div>