导入 AKSRT 主题开发源码
This commit is contained in:
@@ -0,0 +1 @@
|
||||
<!-- 本人中心 partial 模板目录 -->
|
||||
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/**
|
||||
* 用户中心 — 我的评论
|
||||
*
|
||||
* @package AKSRT
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$per_page = 15;
|
||||
$paged = max(1, get_query_var('paged'));
|
||||
|
||||
$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',
|
||||
'count' => true,
|
||||
]);
|
||||
|
||||
$total_comments = $comments;
|
||||
$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_comments / $per_page);
|
||||
?>
|
||||
|
||||
<div class="uc-comments" id="uc-comments">
|
||||
<?php if (!empty($comments)) : ?>
|
||||
<div class="uc-comments__list">
|
||||
<?php foreach ($comments as $comment) :
|
||||
$post = get_post($comment->comment_post_ID);
|
||||
if (!$post) continue;
|
||||
?>
|
||||
<div class="uc-comments__item">
|
||||
<div class="uc-comments__header">
|
||||
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>" class="uc-comments__post-title">
|
||||
<?php echo esc_html($post->post_title); ?>
|
||||
</a>
|
||||
<span class="uc-comments__date"><?php echo esc_html(get_comment_date('Y-m-d', $comment)); ?></span>
|
||||
</div>
|
||||
<div class="uc-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' => '?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>
|
||||
<p class="empty-state__desc"><?php esc_html_e('去文章下方发表你的看法吧~', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
/**
|
||||
* 用户中心 — 我的积分
|
||||
*
|
||||
* @package AKSRT
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$credits_enabled = class_exists('AKSRT_Settings') && AKSRT_Settings::get_credits_settings()['enabled'] ?? false;
|
||||
|
||||
if (!$credits_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
$balance = function_exists('aksrt_get_user_credits') ? aksrt_get_user_credits($user_id) : 0;
|
||||
$currency_name = class_exists('AKSRT_Settings') ? AKSRT_Settings::get_credits_settings()['currency_name'] ?? __('积分', 'aksrt') : __('积分', 'aksrt');
|
||||
|
||||
// 获取积分记录
|
||||
$records = function_exists('aksrt_get_credit_logs') ? aksrt_get_credit_logs($user_id, 20) : [];
|
||||
?>
|
||||
|
||||
<div class="uc-credits" id="uc-credits">
|
||||
<!-- 积分概览 -->
|
||||
<div class="uc-credits__overview">
|
||||
<div class="uc-credits__balance">
|
||||
<span class="uc-credits__balance-num"><?php echo esc_html(number_format($balance, 2)); ?></span>
|
||||
<span class="uc-credits__balance-label"><?php echo esc_html($currency_name); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 积分记录 -->
|
||||
<?php if (!empty($records)) : ?>
|
||||
<div class="uc-credits__records">
|
||||
<h4 class="uc-credits__section-title"><?php esc_html_e('积分记录', 'aksrt'); ?></h4>
|
||||
<div class="uc-credits__list">
|
||||
<?php foreach ($records as $record) : ?>
|
||||
<div class="uc-credits__record">
|
||||
<div class="uc-credits__record-info">
|
||||
<span class="uc-credits__record-desc"><?php echo esc_html($record['description'] ?? ''); ?></span>
|
||||
<span class="uc-credits__record-date"><?php echo esc_html($record['date'] ?? ''); ?></span>
|
||||
</div>
|
||||
<span class="uc-credits__record-amount <?php echo ($record['amount'] ?? 0) > 0 ? 'uc-credits__record-amount--plus' : 'uc-credits__record-amount--minus'; ?>">
|
||||
<?php echo ($record['amount'] ?? 0) > 0 ? '+' : ''; ?><?php echo esc_html(number_format($record['amount'] ?? 0, 2)); ?>
|
||||
</span>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="empty-state empty-state--sm">
|
||||
<div class="empty-state__icon"><i class="fas fa-coins"></i></div>
|
||||
<p class="empty-state__title"><?php esc_html_e('暂无积分记录', 'aksrt'); ?></p>
|
||||
<p class="empty-state__desc"><?php esc_html_e('每天签到、发布内容都可以获得积分哦~', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -0,0 +1,98 @@
|
||||
<?php
|
||||
/**
|
||||
* 用户中心 — 仪表盘面板
|
||||
*
|
||||
* 显示当前登录用户的基本信息概览、积分、VIP状态、快捷操作。
|
||||
*
|
||||
* @package AKSRT
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$user = wp_get_current_user();
|
||||
$dashboard = function_exists('aksrt_get_user_dashboard_view')
|
||||
? aksrt_get_user_dashboard_view($user_id, ['viewer_id' => $user_id])
|
||||
: [];
|
||||
|
||||
$credits_enabled = !empty($dashboard['credits_enabled']);
|
||||
$credit_balance = $dashboard['credit_balance'] ?? 0;
|
||||
$currency_name = $dashboard['currency_name'] ?? __('积分', 'aksrt');
|
||||
$is_vip = function_exists('aksrt_is_vip') && aksrt_is_vip($user_id);
|
||||
$post_count = (int) ($dashboard['post_count'] ?? 0);
|
||||
$comment_count = (int) ($dashboard['comment_count'] ?? 0);
|
||||
$favorite_count = (int) ($dashboard['favorite_count'] ?? 0);
|
||||
$order_count = (int) ($dashboard['order_count'] ?? 0);
|
||||
?>
|
||||
|
||||
<div class="uc-dashboard">
|
||||
<!-- 用户信息卡片 -->
|
||||
<div class="uc-dashboard__profile">
|
||||
<div class="uc-dashboard__avatar">
|
||||
<?php echo get_avatar($user_id, 80); ?>
|
||||
<?php if ($is_vip) : ?>
|
||||
<span class="aksrt-vip-badge aksrt-vip-badge--sm">VIP</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="uc-dashboard__info">
|
||||
<h3 class="uc-dashboard__name"><?php echo esc_html($user->display_name); ?></h3>
|
||||
<p class="uc-dashboard__desc">
|
||||
<?php
|
||||
$desc = $user->description ?: __('这个人很懒,什么都没写~', 'aksrt');
|
||||
echo esc_html(wp_trim_words($desc, 30));
|
||||
?>
|
||||
</p>
|
||||
<div class="uc-dashboard__meta">
|
||||
<span><i class="fas fa-calendar-alt"></i> <?php echo esc_html(__('注册于', 'aksrt') . ' ' . date_i18n(get_option('date_format'), strtotime($user->user_registered))); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<a href="<?php echo esc_url(get_edit_profile_url($user_id)); ?>" class="btn btn-outline-primary btn-sm">
|
||||
<i class="fas fa-edit"></i> <?php esc_html_e('编辑资料', 'aksrt'); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<!-- 数据统计 -->
|
||||
<div class="uc-dashboard__stats">
|
||||
<a href="<?php echo esc_url(get_author_posts_url($user_id)); ?>" class="uc-dashboard__stat">
|
||||
<span class="uc-dashboard__stat-num"><?php echo $post_count; ?></span>
|
||||
<span class="uc-dashboard__stat-label"><?php esc_html_e('文章', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<a href="#uc-comments" class="uc-dashboard__stat">
|
||||
<span class="uc-dashboard__stat-num"><?php echo $comment_count; ?></span>
|
||||
<span class="uc-dashboard__stat-label"><?php esc_html_e('评论', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<a href="#uc-favorites" class="uc-dashboard__stat">
|
||||
<span class="uc-dashboard__stat-num"><?php echo $favorite_count; ?></span>
|
||||
<span class="uc-dashboard__stat-label"><?php esc_html_e('收藏', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php if ($credits_enabled) : ?>
|
||||
<a href="#uc-credits" class="uc-dashboard__stat">
|
||||
<span class="uc-dashboard__stat-num"><?php echo esc_html(number_format($credit_balance, 2)); ?></span>
|
||||
<span class="uc-dashboard__stat-label"><?php echo esc_html($currency_name); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- 快捷操作 -->
|
||||
<div class="uc-dashboard__actions">
|
||||
<a href="<?php echo esc_url(get_edit_profile_url($user_id)); ?>" class="uc-dashboard__action">
|
||||
<i class="fas fa-user-edit"></i>
|
||||
<span><?php esc_html_e('编辑资料', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<a href="<?php echo esc_url(get_edit_profile_url($user_id) . '#password'); ?>" class="uc-dashboard__action">
|
||||
<i class="fas fa-key"></i>
|
||||
<span><?php esc_html_e('修改密码', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php if ($order_count > 0) : ?>
|
||||
<a href="<?php echo esc_url(home_url('/orders/')); ?>" class="uc-dashboard__action">
|
||||
<i class="fas fa-shopping-bag"></i>
|
||||
<span><?php esc_html_e('我的订单', 'aksrt'); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo esc_url(wp_logout_url(home_url())); ?>" class="uc-dashboard__action uc-dashboard__action--danger">
|
||||
<i class="fas fa-sign-out-alt"></i>
|
||||
<span><?php esc_html_e('退出登录', 'aksrt'); ?></span>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
/**
|
||||
* 用户中心 — 我的收藏
|
||||
*
|
||||
* @package AKSRT
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$per_page = 10;
|
||||
$paged = max(1, get_query_var('paged'));
|
||||
|
||||
$favorite_ids = get_user_meta($user_id, 'aksrt_favorite_posts', true);
|
||||
$favorite_ids = is_array($favorite_ids) ? $favorite_ids : [];
|
||||
$total = count($favorite_ids);
|
||||
|
||||
// 分页切片
|
||||
$offset = ($paged - 1) * $per_page;
|
||||
$page_ids = array_slice($favorite_ids, $offset, $per_page);
|
||||
$max_pages = ceil($total / $per_page);
|
||||
?>
|
||||
|
||||
<div class="uc-favorites" id="uc-favorites">
|
||||
<?php if (!empty($page_ids)) : ?>
|
||||
<div class="uc-favorites__list">
|
||||
<?php foreach ($page_ids as $fid) :
|
||||
$post = get_post((int) $fid);
|
||||
if (!$post || $post->post_status !== 'publish') continue;
|
||||
?>
|
||||
<div class="uc-favorites__item">
|
||||
<div class="uc-favorites__content">
|
||||
<h4 class="uc-favorites__title">
|
||||
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>"><?php echo esc_html($post->post_title); ?></a>
|
||||
</h4>
|
||||
<div class="uc-favorites__meta">
|
||||
<span><i class="far fa-clock"></i> <?php echo esc_html(get_the_date('Y-m-d', $post->ID)); ?></span>
|
||||
<span><i class="far fa-eye"></i> <?php echo esc_html(get_post_meta($post->ID, 'aksrt_post_views', true) ?: 0); ?></span>
|
||||
</div>
|
||||
<button class="uc-favorites__remove" data-action="remove-favorite" data-post-id="<?php echo esc_attr($post->ID); ?>">
|
||||
<i class="fas fa-heart-broken"></i> <?php esc_html_e('取消收藏', 'aksrt'); ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php if (has_post_thumbnail($post->ID)) : ?>
|
||||
<a href="<?php echo esc_url(get_permalink($post->ID)); ?>" class="uc-favorites__thumb">
|
||||
<?php echo get_the_post_thumbnail($post->ID, 'thumbnail'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</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' => '?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-heart"></i></div>
|
||||
<p class="empty-state__title"><?php esc_html_e('暂无收藏', 'aksrt'); ?></p>
|
||||
<p class="empty-state__desc"><?php esc_html_e('看到喜欢的文章,点击收藏按钮即可保存~', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
@@ -0,0 +1,71 @@
|
||||
<?php
|
||||
/**
|
||||
* 用户中心 — 我的文章
|
||||
*
|
||||
* @package AKSRT
|
||||
* @since 5.0.0
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$user_id = get_current_user_id();
|
||||
$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,
|
||||
]);
|
||||
?>
|
||||
|
||||
<div class="uc-posts" id="uc-posts">
|
||||
<?php if ($query->have_posts()) : ?>
|
||||
<div class="uc-posts__list">
|
||||
<?php while ($query->have_posts()) : $query->the_post(); ?>
|
||||
<div class="uc-posts__item">
|
||||
<div class="uc-posts__content">
|
||||
<h4 class="uc-posts__title">
|
||||
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
|
||||
</h4>
|
||||
<div class="uc-posts__meta">
|
||||
<span><i class="far fa-clock"></i> <?php echo esc_html(get_the_date()); ?></span>
|
||||
<span><i class="far fa-eye"></i> <?php echo esc_html(get_post_meta(get_the_ID(), 'aksrt_post_views', true) ?: 0); ?></span>
|
||||
<span><i class="far fa-comment"></i> <?php echo esc_html(get_comments_number()); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<?php if (has_post_thumbnail()) : ?>
|
||||
<a href="<?php the_permalink(); ?>" class="uc-posts__thumb">
|
||||
<?php the_post_thumbnail('thumbnail'); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endwhile; ?>
|
||||
</div>
|
||||
|
||||
<?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' => '?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 else : ?>
|
||||
<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>
|
||||
<p class="empty-state__desc"><?php esc_html_e('你还没有发布过文章,去写一篇吧~', 'aksrt'); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php wp_reset_postdata(); ?>
|
||||
</div>
|
||||
Reference in New Issue
Block a user