用户域壳层收口:删除 uh/uc/profile 孤儿 partial 并修正侧栏与宽度选择器
清理减层后已无引用的草稿 partial,让公开主页/作者页侧栏接入 content-layout__aside,并修正 content-shell 与 aksrt-profile 同节点时的宽度选择器。
This commit is contained in:
@@ -54,8 +54,10 @@
|
||||
100% { opacity: 0; transform: translateY(8px) scale(0.95); }
|
||||
}
|
||||
|
||||
/* 用户主页 / 用户中心统一使用站点内容宽度,避免旧 page/dashboard 容器收窄 */
|
||||
.aksrt-profile .content-shell {
|
||||
/* 用户主页 / 用户中心统一使用站点内容宽度,避免旧 page/dashboard 容器收窄。
|
||||
* main 自身同时带 content-shell + aksrt-profile,不能写成 .aksrt-profile .content-shell。 */
|
||||
.aksrt-profile.content-shell,
|
||||
.content-shell.aksrt-profile {
|
||||
width: 100%;
|
||||
max-width: var(--container, 1440px);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,10 @@
|
||||
*/
|
||||
|
||||
/* ==================== 用户中心容器 ==================== */
|
||||
.aksrt-user-center .content-shell {
|
||||
/* main 自身同时带 content-shell + aksrt-profile;宽度选择器应对准同一节点。 */
|
||||
.aksrt-user-center .content-shell,
|
||||
.aksrt-profile.content-shell,
|
||||
.content-shell.aksrt-profile {
|
||||
max-width: var(--container, 1440px);
|
||||
width: 100%;
|
||||
margin: 0 auto;
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php';
|
||||
</div>
|
||||
|
||||
<?php if (!empty($user_home_settings['sidebar'])) : ?>
|
||||
<aside class="sidebar aksrt-author-page__aside" role="complementary" aria-label="<?php esc_attr_e('作者页侧栏', 'aksrt'); ?>">
|
||||
<aside class="content-layout__aside sidebar aksrt-author-page__aside" role="complementary" aria-label="<?php esc_attr_e('作者页侧栏', 'aksrt'); ?>">
|
||||
<?php
|
||||
$sidebar_id = is_active_sidebar('author-sidebar') ? 'author-sidebar' : 'sidebar-blog';
|
||||
if (is_active_sidebar('all_sidebar_top')) {
|
||||
|
||||
@@ -480,7 +480,7 @@ $home_url = function_exists('aksrt_get_user_home_url') ? aksrt_get_user_home_url
|
||||
</div>
|
||||
|
||||
<?php if (!empty($user_home_settings['sidebar'])) : ?>
|
||||
<aside class="sidebar uc-sidebar aksrt-user-home__aside" role="complementary" aria-label="<?php esc_attr_e('用户主页侧栏', 'aksrt'); ?>">
|
||||
<aside class="content-layout__aside sidebar uc-sidebar aksrt-user-home__aside" role="complementary" aria-label="<?php esc_attr_e('用户主页侧栏', 'aksrt'); ?>">
|
||||
<div class="uc-sidebar__section">
|
||||
<div class="uc-sidebar__title"><?php esc_html_e('主页概览', 'aksrt'); ?></div>
|
||||
<div class="uc-stats">
|
||||
|
||||
@@ -1,400 +0,0 @@
|
||||
<?php
|
||||
/**
|
||||
* Template Name: 用户中心
|
||||
* Template Post Type: page
|
||||
*
|
||||
* 单一页面模板,根据场景显示不同内容:
|
||||
* - 登录用户查看自己 → 仪表盘面板(个人信息 / 文章 / 评论 / 收藏 / 通知 / 设置)
|
||||
* - 查看其他用户主页 → 公开用户主页(头像 / 简介 / 文章 / 评论)
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
// 加载共享辅助函数(分页、空状态)
|
||||
require_once AKSRT_DIR . '/templates/parts/user-shared-helpers.php';
|
||||
|
||||
get_header(); ?>
|
||||
|
||||
<div id="toast-container"></div>
|
||||
<script>function showToast(text,d){d=d||2500;var c=document.getElementById('toast-container');if(!c){c=document.createElement('div');c.id='toast-container';document.body.appendChild(c);}var t=document.createElement('div');t.className='toast-item';t.textContent=text;c.appendChild(t);setTimeout(function(){t.classList.add('fade-out');setTimeout(function(){if(t.parentNode)t.parentNode.removeChild(t)},300)},d)}</script>
|
||||
|
||||
<?php // ─── Post/Redirect/Get:处理表单提交后跳转,防止刷新重复提交 ──
|
||||
if ( $_SERVER['REQUEST_METHOD'] === 'POST' && isset( $_POST['action'], $_POST['_profile_nonce'] )
|
||||
&& $_POST['action'] === 'aksrt_save_profile'
|
||||
&& wp_verify_nonce( $_POST['_profile_nonce'], 'aksrt_profile_save' )
|
||||
) {
|
||||
$uid = isset( $_POST['user_id'] ) ? (int) $_POST['user_id'] : 0;
|
||||
if ( $uid && $uid === get_current_user_id() ) {
|
||||
if ( isset( $_POST['nickname'] ) ) {
|
||||
wp_update_user( [ 'ID' => $uid, 'display_name' => sanitize_text_field( $_POST['nickname'] ) ] );
|
||||
}
|
||||
if ( isset( $_POST['description'] ) ) {
|
||||
wp_update_user( [ 'ID' => $uid, 'description' => sanitize_textarea_field( $_POST['description'] ) ] );
|
||||
}
|
||||
$contacts = [];
|
||||
if ( isset( $_POST['contacts'] ) && is_array( $_POST['contacts'] ) ) {
|
||||
foreach ( $_POST['contacts'] as $c ) {
|
||||
$u = isset( $c['url'] ) ? esc_url_raw( $c['url'] ) : '';
|
||||
$i = isset( $c['icon'] ) ? sanitize_key( $c['icon'] ) : '';
|
||||
// 清理 FA5 类名前缀:fab fa-xxx / fabfa-xxx / fa-xxx → xxx
|
||||
$i = preg_replace('/^(fab|fas|far)[\s-]*/', '', $i);
|
||||
$i = preg_replace('/^fa[\s-]*/', '', $i);
|
||||
$i = preg_replace('/^[\s-]+/', '', $i);
|
||||
$i = trim( $i, '- ' );
|
||||
if ( ! $u || ! $i ) continue;
|
||||
$n = aksrt_icon_key_to_name( $i );
|
||||
$contacts[] = [ 'name' => $n, 'url' => $u, 'icon' => $i ];
|
||||
}
|
||||
}
|
||||
update_user_meta( $uid, 'aksrt_user_contacts', $contacts );
|
||||
}
|
||||
wp_safe_redirect( add_query_arg( 'saved', '1', aksrt_get_user_center_url() ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
// ─── 确定目标用户 ─────────────────────────────────────────────
|
||||
// 来源: /user/{昵称} (自定义重写规则)
|
||||
// 注意: get_queried_object_id() 在页面中返回的是页面 ID 而非用户 ID
|
||||
$target_user_id = 0;
|
||||
$target_user_nicename = get_query_var('user_nicename');
|
||||
|
||||
if ( $target_user_nicename ) {
|
||||
$user = get_user_by( 'slug', $target_user_nicename );
|
||||
if ( $user ) {
|
||||
$target_user_id = $user->ID;
|
||||
}
|
||||
}
|
||||
|
||||
// 兜底:检查 queried object
|
||||
if ( ! $target_user_id ) {
|
||||
$qid = get_queried_object_id();
|
||||
if ( $qid && get_userdata( $qid ) ) {
|
||||
$target_user_id = $qid;
|
||||
}
|
||||
}
|
||||
|
||||
$current_user = wp_get_current_user();
|
||||
$target_user = $target_user_id ? get_userdata( $target_user_id ) : null;
|
||||
$is_own_profile = false;
|
||||
|
||||
if ( ! $target_user ) {
|
||||
if ( is_user_logged_in() ) {
|
||||
$target_user = $current_user;
|
||||
$target_user_id = $current_user->ID;
|
||||
$is_own_profile = true;
|
||||
} else {
|
||||
wp_safe_redirect( aksrt_get_login_url( aksrt_get_user_center_url() ) );
|
||||
exit;
|
||||
}
|
||||
} elseif ( is_user_logged_in() && (int) $current_user->ID === (int) $target_user->ID ) {
|
||||
$is_own_profile = true;
|
||||
}
|
||||
|
||||
if ( $target_user_nicename && ! $is_own_profile && function_exists( 'aksrt_get_user_home_url' ) ) {
|
||||
wp_safe_redirect( aksrt_get_user_home_url( $target_user ) );
|
||||
exit;
|
||||
}
|
||||
|
||||
$user_id = $target_user->ID;
|
||||
$post_count = (int) count_user_posts( $user_id, 'post', true );
|
||||
$comment_count = (int) get_comments( [ 'user_id' => $user_id, 'count' => true, 'status' => 'approve' ] );
|
||||
|
||||
// 加载用户自定义联系方式
|
||||
$user_contacts = get_user_meta( $user_id, 'aksrt_user_contacts', true ) ?: [];
|
||||
if ( ! is_array( $user_contacts ) ) $user_contacts = [];
|
||||
$user_center_settings = class_exists( 'AKSRT_Settings' )
|
||||
? AKSRT_Settings::get_user_center_settings()
|
||||
: [
|
||||
'tabs' => [ 'profile', 'posts', 'comments', 'favorites' ],
|
||||
'avatar_upload' => true,
|
||||
'cover_upload' => true,
|
||||
'social_links' => true,
|
||||
];
|
||||
$user_home_settings = class_exists( 'AKSRT_Settings' )
|
||||
? AKSRT_Settings::get_user_home_settings()
|
||||
: [
|
||||
'tabs' => [ 'posts', 'comments', 'favorites' ],
|
||||
'sidebar' => true,
|
||||
'cover' => true,
|
||||
'follow' => true,
|
||||
'posts_per_page' => 10,
|
||||
];
|
||||
$user_home_manager = class_exists( 'AKSRT_User_Home' ) ? AKSRT_User_Home::get_instance() : null;
|
||||
$profile_signals = $user_home_manager ? $user_home_manager->get_profile_signals( $user_id ) : [];
|
||||
$profile_notice = $user_home_manager ? $user_home_manager->get_profile_notice( $user_id ) : [];
|
||||
$show_report_button = $user_home_manager ? $user_home_manager->show_report_entry() : false;
|
||||
$public_visible_tabs = $user_home_manager
|
||||
? $user_home_manager->get_visible_tabs( false )
|
||||
: [
|
||||
'posts' => [ 'label' => __( '文章', 'aksrt' ) ],
|
||||
'comments' => [ 'label' => __( '评论', 'aksrt' ) ],
|
||||
'favorites' => [ 'label' => __( '收藏', 'aksrt' ) ],
|
||||
];
|
||||
|
||||
// 用户自定义背景图
|
||||
$user_background_url = get_user_meta( $user_id, 'aksrt_background_image', true ) ?: '';
|
||||
$allow_bg_upload = $is_own_profile
|
||||
&& ! empty( $user_center_settings['cover_upload'] )
|
||||
&& class_exists( 'AKSRT_Settings' )
|
||||
&& aksrt_get_setting( 'allow_background_upload', false );
|
||||
$show_avatar_edit = $is_own_profile && ! empty( $user_center_settings['avatar_upload'] );
|
||||
$avatar_settings_url = admin_url( 'profile.php' );
|
||||
$public_home_url = function_exists( 'aksrt_get_user_home_url' ) ? aksrt_get_user_home_url( $target_user ) : home_url( '/' );
|
||||
|
||||
$favorite_post_ids = function_exists( 'aksrt_get_user_interaction_posts' )
|
||||
? aksrt_get_user_interaction_posts( '_aksrt_favorite_posts', $user_id )
|
||||
: [];
|
||||
$favorite_count = count( $favorite_post_ids );
|
||||
$notification_unread_count = $is_own_profile && function_exists( 'aksrt_get_user_unread_notification_count' )
|
||||
? aksrt_get_user_unread_notification_count( $user_id )
|
||||
: 0;
|
||||
$dashboard_tabs = class_exists( 'AKSRT_User_Center' )
|
||||
? AKSRT_User_Center::get_instance()->get_dashboard_tabs()
|
||||
: [
|
||||
'profile' => [ 'label' => __( '个人信息', 'aksrt' ), 'icon' => 'user' ],
|
||||
'posts' => [ 'label' => __( '我的文章', 'aksrt' ), 'icon' => 'file-alt' ],
|
||||
'comments' => [ 'label' => __( '我的评论', 'aksrt' ), 'icon' => 'comment' ],
|
||||
'favorites' => [ 'label' => __( '我的收藏', 'aksrt' ), 'icon' => 'star' ],
|
||||
'settings' => [ 'label' => __( '账号设置', 'aksrt' ), 'icon' => 'cog' ],
|
||||
];
|
||||
$dashboard_tab_keys = array_keys( $dashboard_tabs );
|
||||
$public_tab_keys = array_keys( $public_visible_tabs );
|
||||
if ( empty( $public_tab_keys ) ) {
|
||||
$public_visible_tabs = [
|
||||
'posts' => [ 'label' => __( '文章', 'aksrt' ) ],
|
||||
'comments' => [ 'label' => __( '评论', 'aksrt' ) ],
|
||||
'favorites' => [ 'label' => __( '收藏', 'aksrt' ) ],
|
||||
];
|
||||
$public_tab_keys = array_keys( $public_visible_tabs );
|
||||
}
|
||||
$public_tab_labels = [
|
||||
'posts' => __( '文章', 'aksrt' ),
|
||||
'comments' => __( '评论', 'aksrt' ),
|
||||
'favorites' => __( '收藏', 'aksrt' ),
|
||||
];
|
||||
foreach ( $public_visible_tabs as $public_tab_key => $public_tab_config ) {
|
||||
if ( ! empty( $public_tab_config['label'] ) ) {
|
||||
$public_tab_labels[ $public_tab_key ] = (string) $public_tab_config['label'];
|
||||
}
|
||||
}
|
||||
$public_tab_counts = [
|
||||
'posts' => $post_count,
|
||||
'comments' => $comment_count,
|
||||
'favorites' => $favorite_count,
|
||||
];
|
||||
|
||||
// 消息中心页面 URL
|
||||
$messages_page = get_pages( [ 'meta_key' => '_wp_page_template', 'meta_value' => 'templates/pages/page-messages.php', 'number' => 1 ] );
|
||||
$messages_url = ! empty( $messages_page ) ? get_permalink( $messages_page[0] ) : aksrt_get_user_center_url( 'notif' );
|
||||
|
||||
// ─── 文章状态计数(仅自己模式;用于状态筛选 chip) ────────────
|
||||
$user_status_counts = [
|
||||
'publish' => 0,
|
||||
'draft' => 0,
|
||||
'pending' => 0,
|
||||
'private' => 0,
|
||||
];
|
||||
if ( $is_own_profile ) {
|
||||
global $wpdb;
|
||||
$rows = $wpdb->get_results( $wpdb->prepare(
|
||||
"SELECT post_status, COUNT(*) AS num FROM {$wpdb->posts}
|
||||
WHERE post_author = %d AND post_type = 'post'
|
||||
AND post_status IN ('publish','draft','pending','private')
|
||||
GROUP BY post_status",
|
||||
$user_id
|
||||
) );
|
||||
foreach ( (array) $rows as $row ) {
|
||||
$user_status_counts[ $row->post_status ] = (int) $row->num;
|
||||
}
|
||||
$post_count = (int) array_sum( $user_status_counts );
|
||||
}
|
||||
|
||||
// ─── 分页与筛选参数(自己 / 他人 共享) ────────────────────────
|
||||
$per_page = $is_own_profile ? 10 : max( 5, (int) ( $user_home_settings['posts_per_page'] ?? 10 ) );
|
||||
$default_dashboard_tab = in_array( 'profile', $dashboard_tab_keys, true ) ? 'profile' : ( $dashboard_tab_keys[0] ?? 'profile' );
|
||||
$active_tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : $default_dashboard_tab;
|
||||
$public_default_tab = $public_tab_keys[0] ?? 'posts';
|
||||
$public_active_tab = isset( $_GET['tab'] ) ? sanitize_key( wp_unslash( $_GET['tab'] ) ) : $public_default_tab;
|
||||
// 兼容旧链接:签到 / 邀请已经并入新面板
|
||||
if ( 'signin' === $active_tab ) {
|
||||
$active_tab = 'credits';
|
||||
} elseif ( 'invite' === $active_tab ) {
|
||||
$active_tab = 'settings';
|
||||
}
|
||||
if ( ! in_array( $active_tab, $dashboard_tab_keys, true ) ) {
|
||||
$active_tab = $default_dashboard_tab;
|
||||
}
|
||||
if ( ! in_array( $public_active_tab, $public_tab_keys, true ) ) {
|
||||
$public_active_tab = $public_default_tab;
|
||||
}
|
||||
$posts_page = max( 1, isset( $_GET['posts_page'] ) ? (int) $_GET['posts_page'] : 1 );
|
||||
$comments_page = max( 1, isset( $_GET['comments_page'] ) ? (int) $_GET['comments_page'] : 1 );
|
||||
$favorites_page = max( 1, isset( $_GET['favorites_page'] ) ? (int) $_GET['favorites_page'] : 1 );
|
||||
|
||||
$valid_post_status = [ 'all', 'publish', 'draft', 'pending', 'private' ];
|
||||
$post_status_filter = isset( $_GET['post_status'] ) ? sanitize_key( wp_unslash( $_GET['post_status'] ) ) : 'publish';
|
||||
if ( ! in_array( $post_status_filter, $valid_post_status, true ) ) {
|
||||
$post_status_filter = 'publish';
|
||||
}
|
||||
|
||||
// 空状态图标 SVG(提取以减少重复)
|
||||
$svg_empty_post = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><path d="M14 2v6h6"/><path d="M9 13h6M9 17h6M9 9h1"/></svg>';
|
||||
$svg_empty_comment = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"/></svg>';
|
||||
$svg_empty_favorite = '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"><polygon points="12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2"/></svg>';
|
||||
?>
|
||||
|
||||
<main id="main-content" class="site-main content-shell" tabindex="-1">
|
||||
|
||||
<?php if ( $is_own_profile ) : ?>
|
||||
<!-- ===================== 本人模式:用户中心 ===================== -->
|
||||
<div class="user-center">
|
||||
|
||||
<?php
|
||||
$oauth_action = isset( $_GET['oauth_action'] ) ? sanitize_key( wp_unslash( $_GET['oauth_action'] ) ) : '';
|
||||
$oauth_notice_provider = isset( $_GET['oauth_bound'] ) ? sanitize_key( wp_unslash( $_GET['oauth_bound'] ) ) : '';
|
||||
$oauth_unbound_provider = isset( $_GET['oauth_unbound'] ) ? sanitize_key( wp_unslash( $_GET['oauth_unbound'] ) ) : '';
|
||||
$oauth_notice_names = [
|
||||
'github' => 'GitHub',
|
||||
'gitee' => 'Gitee',
|
||||
'qq' => 'QQ',
|
||||
'google' => 'Google',
|
||||
];
|
||||
?>
|
||||
<?php if ( isset( $_GET['saved'] ) || $oauth_notice_provider || $oauth_unbound_provider ) : ?>
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded',function(){
|
||||
<?php if ( $oauth_notice_provider && $oauth_action === 'login' ) : ?>
|
||||
showToast('<?php echo esc_js( sprintf( __( '%s 登录成功', 'aksrt' ), $oauth_notice_names[ $oauth_notice_provider ] ?? ucfirst( $oauth_notice_provider ) ) ); ?>');
|
||||
<?php elseif ( $oauth_notice_provider ) : ?>
|
||||
showToast('<?php echo esc_js( sprintf( __( '%s 绑定成功', 'aksrt' ), $oauth_notice_names[ $oauth_notice_provider ] ?? ucfirst( $oauth_notice_provider ) ) ); ?>');
|
||||
<?php elseif ( $oauth_unbound_provider ) : ?>
|
||||
showToast('<?php echo esc_js( sprintf( __( '%s 已解绑', 'aksrt' ), $oauth_notice_names[ $oauth_unbound_provider ] ?? ucfirst( $oauth_unbound_provider ) ) ); ?>');
|
||||
<?php else : ?>
|
||||
showToast('已保存');
|
||||
<?php endif; ?>
|
||||
if(window.history.replaceState){
|
||||
var u=new URL(window.location);
|
||||
u.searchParams.delete('saved');
|
||||
u.searchParams.delete('oauth_bound');
|
||||
u.searchParams.delete('oauth_unbound');
|
||||
u.searchParams.delete('oauth_action');
|
||||
window.history.replaceState({},'',u);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- 头图 + 用户卡 -->
|
||||
<div class="uc-header">
|
||||
<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="">
|
||||
<div class="uc-header__cover-mask"></div>
|
||||
<?php if ( $allow_bg_upload ) : ?>
|
||||
<button type="button" class="uc-header__cover-upload" id="aksrt-upload-bg-btn" title="<?php esc_attr_e( '编辑背景图', 'aksrt' ); ?>">
|
||||
<i class="fas fa-pen" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e( '编辑', 'aksrt' ); ?></span>
|
||||
</button>
|
||||
<input type="file" id="aksrt-bg-file-input" accept="image/jpeg,image/png,image/webp,image/gif" style="display:none">
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="uc-header__content">
|
||||
<div class="uc-header__avatar">
|
||||
<?php echo get_avatar( $user_id, 120, '', $target_user->display_name ); ?>
|
||||
</div>
|
||||
<div class="uc-header__info">
|
||||
<h1 class="uc-header__name">
|
||||
<?php echo esc_html( $target_user->display_name ); ?>
|
||||
<?php
|
||||
$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
|
||||
?>
|
||||
</h1>
|
||||
<?php if ( $target_user->description ) : ?>
|
||||
<p class="uc-header__desc"><?php echo esc_html( $target_user->description ); ?></p>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! empty( $profile_signals ) ) : ?>
|
||||
<div class="aksrt-identity-chips">
|
||||
<?php foreach ( $profile_signals as $signal ) : ?>
|
||||
<span class="aksrt-identity-chip aksrt-identity-chip--<?php echo esc_attr( $signal['tone'] ); ?>">
|
||||
<i class="fas fa-<?php echo esc_attr( $signal['icon'] ); ?>" aria-hidden="true"></i>
|
||||
<span><?php echo esc_html( $signal['label'] ); ?></span>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<div class="uc-header__meta">
|
||||
<span class="uc-header__meta-item" title="<?php esc_attr_e( '用户名', 'aksrt' ); ?>">
|
||||
<i class="fas fa-user" aria-hidden="true"></i> <?php echo esc_html( $target_user->user_login ); ?>
|
||||
</span>
|
||||
<?php if ( $target_user->user_email ) : ?>
|
||||
<span class="uc-header__meta-item" title="<?php esc_attr_e( '邮箱', 'aksrt' ); ?>">
|
||||
<i class="fas fa-envelope" aria-hidden="true"></i> <?php echo esc_html( $target_user->user_email ); ?>
|
||||
</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uc-header__actions">
|
||||
<?php if ( $show_avatar_edit ) : ?>
|
||||
<a href="<?php echo esc_url( $avatar_settings_url ); ?>" class="btn-ghost btn-sm">
|
||||
<i class="fas fa-camera" aria-hidden="true"></i> <?php esc_html_e( '更换头像', 'aksrt' ); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<a href="<?php echo esc_url( aksrt_get_user_home_url() ); ?>" class="btn-ghost btn-sm">
|
||||
<i class="fas fa-map-marker-alt" aria-hidden="true"></i> <?php esc_html_e( '我的主页', 'aksrt' ); ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 两栏布局 -->
|
||||
<div class="uc-layout">
|
||||
<!-- 左侧边栏 -->
|
||||
<aside class="uc-sidebar">
|
||||
<!-- 数据统计 -->
|
||||
<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 ) : ?>
|
||||
<button type="button" class="uc-sidebar__btn" 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>
|
||||
</button>
|
||||
<?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
|
||||
$orders_url = function_exists('aksrt_get_orders_page_url') ? aksrt_get_orders_page_url() : '';
|
||||
$show_vip = class_exists('AKSRT_Settings') && !empty(AKSRT_Settings::get_all()['payment_vip_enabled']);
|
||||
$show_credit_tabs = class_exists('AKSRT_Settings') && AKSRT_Settings::credits_enabled();
|
||||
@@ -1,403 +0,0 @@
|
||||
<?php
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$affiliate_enabled = $show_credit_tabs && !empty(AKSRT_Settings::get_all()['payment_affiliate_enabled']);
|
||||
?>
|
||||
<?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) : ?>
|
||||
<button type="button" class="uc-sidebar__btn" data-tab="credits">
|
||||
<i class="fas fa-crown" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('VIP 会员', 'aksrt'); ?></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($show_credit_tabs) : ?>
|
||||
<button type="button" class="uc-sidebar__btn" data-tab="credits">
|
||||
<i class="fas fa-coins" aria-hidden="true"></i>
|
||||
<span><?php echo esc_html(AKSRT_Settings::get_currency_name()); ?></span>
|
||||
</button>
|
||||
<?php endif; ?>
|
||||
<?php if ($affiliate_enabled) : ?>
|
||||
<button type="button" class="uc-sidebar__btn" data-tab="credits">
|
||||
<i class="fas fa-share-alt" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e('推广返佣', 'aksrt'); ?></span>
|
||||
</button>
|
||||
<?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' ); ?>">
|
||||
<i class="fas fa-bars" aria-hidden="true"></i>
|
||||
</button>
|
||||
</aside>
|
||||
|
||||
<!-- 右侧内容区 -->
|
||||
<div class="uc-content">
|
||||
<!-- 移动端抽屉遮罩 -->
|
||||
<div class="uc-drawer-overlay" id="uc-drawer-overlay"></div>
|
||||
|
||||
<!-- 面板内容 -->
|
||||
<div class="dashboard-tabs uc-mobile-tabs" role="tablist">
|
||||
<?php foreach ( $dashboard_tabs as $tab_key => $tab ) : ?>
|
||||
<button type="button" class="<?php echo $active_tab === $tab_key ? 'is-active' : ''; ?>" data-tab="<?php echo esc_attr( $tab_key ); ?>" role="tab"><?php echo esc_html( $tab['label'] ); ?></button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
$show_credit_tabs = class_exists( 'AKSRT_Settings' ) && AKSRT_Settings::credits_enabled();
|
||||
$show_invite_section = $show_credit_tabs && class_exists( 'AKSRT_Settings' ) && AKSRT_Settings::invite_enabled() && AKSRT_Settings::invite_registration_enabled();
|
||||
$currency_name = $show_credit_tabs ? AKSRT_Settings::get_currency_name() : __( '积分', 'aksrt' );
|
||||
?>
|
||||
|
||||
<!-- ==================== 个人信息(可编辑) ==================== -->
|
||||
<div id="panel-profile" class="dashboard-panel<?php echo 'profile' === $active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'profile' !== $active_tab ? ' hidden' : ''; ?>>
|
||||
<form class="profile-form" id="profile-form" method="post">
|
||||
<?php wp_nonce_field( 'aksrt_profile_save', '_profile_nonce' ); ?>
|
||||
<input type="hidden" name="action" value="aksrt_save_profile">
|
||||
|
||||
<!-- 昵称 -->
|
||||
<div class="widget-card">
|
||||
<h3 class="widget-title"><?php esc_html_e( '昵称', 'aksrt' ); ?></h3>
|
||||
<input type="text" name="nickname" id="profile-nickname"
|
||||
value="<?php echo esc_attr( $target_user->display_name ); ?>"
|
||||
class="profile-input" maxlength="50" required>
|
||||
<p class="profile-hint"><?php esc_html_e( '修改后会同步更新个人主页地址', 'aksrt' ); ?></p>
|
||||
</div>
|
||||
|
||||
<!-- 个人简介 -->
|
||||
<div class="widget-card">
|
||||
<h3 class="widget-title"><?php esc_html_e( '个人简介', 'aksrt' ); ?></h3>
|
||||
<textarea name="description" id="profile-bio" class="profile-input profile-textarea"
|
||||
rows="4" maxlength="500" placeholder="<?php esc_attr_e( '介绍一下自己…', 'aksrt' ); ?>"><?php echo esc_textarea( $target_user->description ); ?></textarea>
|
||||
<p class="profile-hint"><?php esc_html_e( '显示在你的公开用户主页上,最多 500 字', 'aksrt' ); ?></p>
|
||||
</div>
|
||||
|
||||
<?php if ( ! empty( $user_center_settings['social_links'] ) ) : ?>
|
||||
<!-- 联系方式 -->
|
||||
<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' ); ?>">×</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">
|
||||
<button type="submit" class="btn-primary btn-lg" id="profile-save-btn">
|
||||
<?php esc_html_e( '保存修改', 'aksrt' ); ?>
|
||||
</button>
|
||||
<span id="profile-save-msg" class="profile-form__submit-msg"></span>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
|
||||
<!-- ==================== 我的文章 ==================== -->
|
||||
<div id="panel-posts" class="dashboard-panel<?php echo 'posts' === $active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'posts' !== $active_tab ? ' hidden' : ''; ?>>
|
||||
<div class="widget-card">
|
||||
<div class="profile-list-header">
|
||||
<h3 class="widget-title widget-title--inline">
|
||||
<?php
|
||||
/* translators: %d: post count */
|
||||
printf( esc_html__( '我的文章(%d 篇)', 'aksrt' ), $post_count );
|
||||
?>
|
||||
</h3>
|
||||
<?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>
|
||||
|
||||
<?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;
|
||||
}
|
||||
set_query_var( 'aksrt_profile_item_status', $status_label );
|
||||
|
||||
$edit_link = get_edit_post_link();
|
||||
set_query_var( 'aksrt_profile_item_action', $edit_link ? [
|
||||
'type' => 'edit',
|
||||
'url' => $edit_link,
|
||||
'label' => __( '编辑', 'aksrt' ),
|
||||
] : [] );
|
||||
|
||||
get_template_part( 'templates/parts/content', 'profile-list-item' );
|
||||
endwhile; ?>
|
||||
</div>
|
||||
<?php aksrt_render_profile_pagination( (int) $q->max_num_pages, $posts_page, 'posts_page' ); ?>
|
||||
<?php
|
||||
wp_reset_postdata();
|
||||
set_query_var( 'aksrt_profile_item_action', [] );
|
||||
set_query_var( 'aksrt_profile_item_status', '' );
|
||||
else :
|
||||
aksrt_render_profile_empty(
|
||||
$svg_empty_post,
|
||||
__( '还没有文章', 'aksrt' ),
|
||||
__( '试试发布你的第一篇文章吧。', 'aksrt' ),
|
||||
admin_url( 'post-new.php' ),
|
||||
__( '写文章', 'aksrt' )
|
||||
);
|
||||
endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ==================== 我的评论 ==================== -->
|
||||
<div id="panel-comments" class="dashboard-panel<?php echo 'comments' === $active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'comments' !== $active_tab ? ' hidden' : ''; ?>>
|
||||
<div class="widget-card">
|
||||
<div class="profile-list-header">
|
||||
<h3 class="widget-title widget-title--inline">
|
||||
<?php printf( esc_html__( '我的评论(%d 条)', 'aksrt' ), $comment_count ); ?>
|
||||
</h3>
|
||||
</div>
|
||||
<?php
|
||||
$comments_total = $comment_count;
|
||||
$cs = get_comments( [
|
||||
'user_id' => $user_id,
|
||||
'number' => $per_page,
|
||||
'offset' => ( $comments_page - 1 ) * $per_page,
|
||||
'status' => 'approve',
|
||||
'update_comment_meta_cache' => false,
|
||||
] );
|
||||
if ( $cs ) : ?>
|
||||
<div class="profile-comment-list">
|
||||
<?php foreach ( $cs as $c ) :
|
||||
set_query_var( 'aksrt_profile_comment', $c );
|
||||
get_template_part( 'templates/parts/content', 'profile-comment-item' );
|
||||
endforeach;
|
||||
set_query_var( 'aksrt_profile_comment', null ); ?>
|
||||
</div>
|
||||
<?php
|
||||
$comments_total_pages = (int) ceil( $comments_total / $per_page );
|
||||
aksrt_render_profile_pagination( $comments_total_pages, $comments_page, 'comments_page' );
|
||||
?>
|
||||
<?php else :
|
||||
aksrt_render_profile_empty(
|
||||
$svg_empty_comment,
|
||||
__( '暂无评论', 'aksrt' ),
|
||||
__( '在你感兴趣的文章下留下你的看法吧。', 'aksrt' )
|
||||
);
|
||||
endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ==================== 我的收藏 ==================== -->
|
||||
<div id="panel-favorites" class="dashboard-panel<?php echo 'favorites' === $active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'favorites' !== $active_tab ? ' hidden' : ''; ?>>
|
||||
<div class="widget-card">
|
||||
<div class="profile-list-header">
|
||||
<h3 class="widget-title widget-title--inline">
|
||||
<?php printf( esc_html__( '我的收藏(%d 篇)', 'aksrt' ), $favorite_count ); ?>
|
||||
</h3>
|
||||
</div>
|
||||
<?php if ( ! empty( $favorite_post_ids ) ) :
|
||||
$favorites_query = new WP_Query( [
|
||||
'post_type' => 'post',
|
||||
'post_status' => 'publish',
|
||||
'post__in' => $favorite_post_ids,
|
||||
'orderby' => 'post__in',
|
||||
'posts_per_page' => $per_page,
|
||||
'paged' => $favorites_page,
|
||||
'ignore_sticky_posts' => true,
|
||||
'no_found_rows' => false,
|
||||
'update_post_meta_cache' => false,
|
||||
] );
|
||||
if ( $favorites_query->have_posts() ) : ?>
|
||||
<div class="profile-list" data-list="favorites">
|
||||
<?php while ( $favorites_query->have_posts() ) : $favorites_query->the_post();
|
||||
set_query_var( 'aksrt_profile_item_action', [
|
||||
'type' => 'unfavorite',
|
||||
'url' => '#',
|
||||
'label' => __( '取消收藏', 'aksrt' ),
|
||||
] );
|
||||
set_query_var( 'aksrt_profile_item_status', '' );
|
||||
get_template_part( 'templates/parts/content', 'profile-list-item' );
|
||||
endwhile; ?>
|
||||
</div>
|
||||
<?php aksrt_render_profile_pagination( (int) $favorites_query->max_num_pages, $favorites_page, 'favorites_page' ); ?>
|
||||
<?php
|
||||
wp_reset_postdata();
|
||||
set_query_var( 'aksrt_profile_item_action', [] );
|
||||
else :
|
||||
aksrt_render_profile_empty(
|
||||
$svg_empty_favorite,
|
||||
__( '收藏列表为空', 'aksrt' ),
|
||||
__( '点击文章页面的星标收藏喜欢的内容。', 'aksrt' ),
|
||||
home_url( '/' ),
|
||||
__( '去发现好文', 'aksrt' )
|
||||
);
|
||||
endif;
|
||||
else :
|
||||
aksrt_render_profile_empty(
|
||||
$svg_empty_favorite,
|
||||
__( '收藏列表为空', 'aksrt' ),
|
||||
__( '点击文章页面的星标收藏喜欢的内容。', 'aksrt' ),
|
||||
home_url( '/' ),
|
||||
__( '去发现好文', 'aksrt' )
|
||||
);
|
||||
endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$balance = function_exists( 'aksrt_user_credits' ) ? aksrt_user_credits( $user_id ) : 0;
|
||||
$currency_name = class_exists( 'AKSRT_Settings' ) ? AKSRT_Settings::get_currency_name() : __( '积分', 'aksrt' );
|
||||
$credits_enabled = class_exists( 'AKSRT_Settings' ) && AKSRT_Settings::credits_enabled();
|
||||
$vip_settings = class_exists( 'AKSRT_Settings' ) ? AKSRT_Settings::get_payment_vip_settings() : [];
|
||||
$show_vip_card = ! empty( $vip_settings['enabled'] );
|
||||
$is_vip_user = function_exists( 'aksrt_is_vip' ) && aksrt_is_vip( $user_id );
|
||||
$vip_badge_text = function_exists( 'aksrt_get_vip_badge_text' ) ? aksrt_get_vip_badge_text() : 'VIP';
|
||||
?>
|
||||
<!-- ==================== 账户余额 ==================== -->
|
||||
<div id="panel-credits" class="dashboard-panel<?php echo 'credits' === $active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'credits' !== $active_tab ? ' hidden' : ''; ?>>
|
||||
|
||||
<!-- 余额卡片 -->
|
||||
<div class="uc-balance-card">
|
||||
<div class="uc-balance-card__bg"></div>
|
||||
<div class="uc-balance-card__content">
|
||||
<div class="uc-balance-card__header">
|
||||
<span class="uc-balance-card__label"><?php esc_html_e( '账户余额', 'aksrt' ); ?></span>
|
||||
<span class="uc-balance-card__currency"><?php echo esc_html( $currency_name ); ?></span>
|
||||
</div>
|
||||
<div class="uc-balance-card__amount">
|
||||
<span class="uc-balance-card__value"><?php echo esc_html( aksrt_format_credits( $balance ) ); ?></span>
|
||||
</div>
|
||||
<?php if ( $credits_enabled ) : ?>
|
||||
<div class="uc-balance-card__actions" data-aksrt-signin>
|
||||
<span class="uc-balance-card__sign-status" data-signin-status></span>
|
||||
<button type="button" class="uc-balance-card__sign-btn" data-signin-btn disabled>
|
||||
<i class="fas fa-calendar-check" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e( '签到', 'aksrt' ); ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<p class="uc-balance-card__tip" data-signin-tip></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( $show_vip_card ) : ?>
|
||||
<!-- VIP 会员卡片 -->
|
||||
<div class="uc-vip-card<?php echo $is_vip_user ? ' uc-vip-card--active' : ''; ?>">
|
||||
<div class="uc-vip-card__bg"></div>
|
||||
<div class="uc-vip-card__content">
|
||||
<div class="uc-vip-card__header">
|
||||
<div class="uc-vip-card__icon">
|
||||
<i class="fas fa-crown" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div class="uc-vip-card__info">
|
||||
<span class="uc-vip-card__label"><?php echo esc_html( $vip_settings['name'] ?? __( 'VIP会员', 'aksrt' ) ); ?></span>
|
||||
<?php if ( $is_vip_user ) : ?>
|
||||
<span class="uc-vip-card__status uc-vip-card__status--active"><?php esc_html_e( '已开通', 'aksrt' ); ?></span>
|
||||
<?php else : ?>
|
||||
<span class="uc-vip-card__status"><?php esc_html_e( '未开通', 'aksrt' ); ?></span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php if ( $is_vip_user ) : ?>
|
||||
<div class="uc-vip-card__benefits">
|
||||
<span class="uc-vip-card__benefit"><i class="fas fa-download" aria-hidden="true"></i> <?php esc_html_e( '免费下载', 'aksrt' ); ?></span>
|
||||
<span class="uc-vip-card__benefit"><i class="fas fa-crown" aria-hidden="true"></i> <?php esc_html_e( '专属身份', 'aksrt' ); ?></span>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<div class="uc-vip-card__benefits">
|
||||
<span class="uc-vip-card__benefit"><i class="fas fa-download" aria-hidden="true"></i> <?php esc_html_e( '解锁免费下载', 'aksrt' ); ?></span>
|
||||
<span class="uc-vip-card__benefit"><i class="fas fa-tag" aria-hidden="true"></i> <?php esc_html_e( '享专属折扣', 'aksrt' ); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
<?php if ( ! $is_vip_user ) : ?>
|
||||
<a href="<?php echo esc_url( aksrt_get_user_center_url( 'credits' ) ); ?>" class="uc-vip-card__btn">
|
||||
<?php esc_html_e( '立即开通', 'aksrt' ); ?>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $credits_enabled && function_exists('aksrt_is_captcha_enabled_for') && aksrt_is_captcha_enabled_for('signin') ) : ?>
|
||||
<div class="aksrt-signin-captcha" data-signin-captcha style="margin-bottom:16px;">
|
||||
<?php aksrt_render_captcha('signin'); ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php
|
||||
// 签到日历可视化
|
||||
$signin_dates = [];
|
||||
if ($credits_enabled && class_exists('AKSRT_Signin')) {
|
||||
$signin_log = AKSRT_Signin::get_instance()->get_recent_signins($user_id, 30);
|
||||
$signin_dates = array_map(function ($entry) {
|
||||
return $entry['signin_date'] ?? '';
|
||||
}, $signin_log);
|
||||
$signin_dates = array_filter($signin_dates);
|
||||
}
|
||||
?>
|
||||
<?php if (!empty($signin_dates)) : ?>
|
||||
@@ -1,403 +0,0 @@
|
||||
<?php
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
<div class="uc-signin-calendar" style="margin-bottom:16px;">
|
||||
<h4 class="uc-signin-calendar__title">
|
||||
<i class="fas fa-calendar-alt" aria-hidden="true"></i>
|
||||
<?php esc_html_e('最近 30 天签到', 'aksrt'); ?>
|
||||
</h4>
|
||||
<div data-aksrt-signin-calendar='<?php echo esc_attr(wp_json_encode(array_values($signin_dates))); ?>'></div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- 积分流水 -->
|
||||
<div class="uc-transactions">
|
||||
<div class="uc-transactions__header">
|
||||
<h3 class="uc-transactions__title">
|
||||
<i class="fas fa-list-ul" aria-hidden="true"></i>
|
||||
<?php echo esc_html( sprintf( __( '%s明细', 'aksrt' ), $currency_name ) ); ?>
|
||||
</h3>
|
||||
</div>
|
||||
<?php
|
||||
$credits_page = max(1, isset($_GET['credits_page']) ? (int) $_GET['credits_page'] : 1);
|
||||
if ( class_exists( 'AKSRT_Credits' ) ) {
|
||||
$log = AKSRT_Credits::get_log( [ 'user_id' => $user_id, 'page' => $credits_page, 'per_page' => 10 ] );
|
||||
} else {
|
||||
$log = [ 'items' => [], 'total' => 0 ];
|
||||
}
|
||||
if ( ! empty( $log['items'] ) ) :
|
||||
?>
|
||||
<div class="uc-transactions__list">
|
||||
<?php foreach ( $log['items'] as $row ) :
|
||||
$delta = (int) $row['delta'];
|
||||
$delta_class = $delta >= 0 ? 'is-positive' : 'is-negative';
|
||||
?>
|
||||
<div class="uc-transactions__item">
|
||||
<div class="uc-transactions__icon <?php echo esc_attr( $delta_class ); ?>">
|
||||
<i class="fas fa-<?php echo $delta >= 0 ? 'arrow-up' : 'arrow-down'; ?>" aria-hidden="true"></i>
|
||||
</div>
|
||||
<div class="uc-transactions__info">
|
||||
<div class="uc-transactions__reason">
|
||||
<?php echo esc_html( aksrt_credits_label( (string) $row['reason'] ) ); ?>
|
||||
<?php if ( ! empty( $row['remark'] ) ) : ?>
|
||||
<span class="uc-transactions__remark">(<?php echo esc_html( (string) $row['remark'] ); ?>)</span>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<div class="uc-transactions__time">
|
||||
<?php echo esc_html( get_date_from_gmt( (string) $row['created_at'], 'Y-m-d H:i' ) ); ?>
|
||||
</div>
|
||||
</div>
|
||||
<div class="uc-transactions__amount">
|
||||
<span class="uc-transactions__delta <?php echo esc_attr( $delta_class ); ?>">
|
||||
<?php echo esc_html( ( $delta > 0 ? '+' : '' ) . $delta ); ?>
|
||||
</span>
|
||||
<span class="uc-transactions__balance">
|
||||
<?php
|
||||
/* translators: %s: 余额 */
|
||||
printf( esc_html__( '余额 %s', 'aksrt' ), esc_html( (string) (int) $row['balance_after'] ) );
|
||||
?>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php
|
||||
$total_pages = (int) ceil( (int) ($log['total'] ?? 0) / 10 );
|
||||
if ( $total_pages > 1 ) {
|
||||
aksrt_render_profile_pagination( $total_pages, $credits_page, 'credits_page' );
|
||||
}
|
||||
?>
|
||||
<?php else : ?>
|
||||
<div class="uc-transactions__empty">
|
||||
<div class="uc-transactions__empty-icon">
|
||||
<i class="fas fa-receipt" aria-hidden="true"></i>
|
||||
</div>
|
||||
<p><?php echo esc_html( sprintf( __( '还没有任何%s流水', 'aksrt' ), $currency_name ) ); ?></p>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ==================== 账号设置 ==================== -->
|
||||
<div id="panel-settings" class="dashboard-panel<?php echo 'settings' === $active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'settings' !== $active_tab ? ' hidden' : ''; ?>>
|
||||
<?php
|
||||
$oauth = AKSRT_OAuth::get_instance();
|
||||
$oauth_data = $oauth->get_frontend_bindings_data($user_id);
|
||||
$user_email = $target_user->user_email ?: '';
|
||||
$binding_name_map = [
|
||||
'github' => 'GitHub',
|
||||
'gitee' => 'Gitee',
|
||||
'qq' => 'QQ',
|
||||
'google' => 'Google',
|
||||
];
|
||||
$binding_rows = [];
|
||||
foreach ( (array) ( $oauth_data['bindings'] ?? [] ) as $binding ) {
|
||||
$key = $binding['key'] ?? '';
|
||||
if ( ! $key ) continue;
|
||||
$binding_rows[ $key ] = [
|
||||
'key' => $key,
|
||||
'name' => $binding_name_map[ $key ] ?? ( $binding['name'] ?? ucfirst( $key ) ),
|
||||
'icon' => $binding['icon'] ?? '',
|
||||
'is_bound' => true,
|
||||
'url' => '',
|
||||
];
|
||||
}
|
||||
foreach ( (array) ( $oauth_data['available'] ?? [] ) as $binding ) {
|
||||
$key = $binding['key'] ?? '';
|
||||
if ( ! $key ) continue;
|
||||
$binding_rows[ $key ] = [
|
||||
'key' => $key,
|
||||
'name' => $binding_name_map[ $key ] ?? ( $binding['name'] ?? ucfirst( $key ) ),
|
||||
'icon' => $binding['icon'] ?? '',
|
||||
'is_bound' => false,
|
||||
'url' => $binding['url'] ?? '',
|
||||
];
|
||||
}
|
||||
?>
|
||||
|
||||
<!-- 第三方绑定区域 -->
|
||||
<div class="settings-section">
|
||||
<div class="settings-section__header">
|
||||
<span class="settings-icon"><i class="fas fa-link" aria-hidden="true"></i></span>
|
||||
<h3 class="widget-title settings-section__title"><?php esc_html_e( '社交账号绑定', 'aksrt' ); ?></h3>
|
||||
</div>
|
||||
|
||||
<?php if ( ! empty( $binding_rows ) ) : ?>
|
||||
<p class="settings-hint settings-hint--top"><?php esc_html_e( '点击下方按钮管理第三方账号绑定状态:', 'aksrt' ); ?></p>
|
||||
<div class="binding-list">
|
||||
<?php foreach ( $binding_rows as $binding ) : ?>
|
||||
<?php if ( ! empty( $binding['is_bound'] ) ) : ?>
|
||||
<div class="binding-item">
|
||||
<span class="binding-item__icon"><?php echo $binding['icon']; ?></span>
|
||||
<span class="binding-item__meta">
|
||||
<span class="binding-status">
|
||||
<i class="fas fa-check-circle badge__icon" aria-hidden="true"></i>
|
||||
<?php esc_html_e( '已绑定', 'aksrt' ); ?>
|
||||
</span>
|
||||
<span class="binding-item__name"><?php echo esc_html( $binding['name'] ); ?></span>
|
||||
</span>
|
||||
<button type="button" class="binding-unbind-btn" data-provider="<?php echo esc_attr( $binding['key'] ); ?>">
|
||||
<?php esc_html_e( '解绑', 'aksrt' ); ?>
|
||||
</button>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<a href="<?php echo esc_url( $binding['url'] ); ?>" class="binding-item binding-item--linkable" target="_self">
|
||||
<span class="binding-item__icon"><?php echo $binding['icon']; ?></span>
|
||||
<span class="binding-item__meta">
|
||||
<span class="binding-status binding-status--idle"><?php esc_html_e( '未绑定', 'aksrt' ); ?></span>
|
||||
<span class="binding-item__name"><?php echo esc_html( $binding['name'] ); ?></span>
|
||||
</span>
|
||||
<span class="badge badge--bind"><?php esc_html_e( '绑定', 'aksrt' ); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php else : ?>
|
||||
<p class="settings-empty"><?php esc_html_e( '暂无可用的第三方登录服务', 'aksrt' ); ?></p>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<!-- 安全设置区域 -->
|
||||
<div class="settings-section">
|
||||
<div class="settings-section__header">
|
||||
<span class="settings-icon"><i class="fas fa-lock" aria-hidden="true"></i></span>
|
||||
<h3 class="widget-title settings-section__title"><?php esc_html_e( '安全设置', 'aksrt' ); ?></h3>
|
||||
</div>
|
||||
<div class="security-actions">
|
||||
<!-- 修改密码 -->
|
||||
<div class="security-action-item">
|
||||
<div class="security-action-info">
|
||||
<span class="security-action-icon"><i class="fas fa-lock" aria-hidden="true"></i></span>
|
||||
<div class="security-action-text">
|
||||
<span class="security-action-title"><?php esc_html_e( '修改密码', 'aksrt' ); ?></span>
|
||||
<span class="security-action-desc"><?php esc_html_e( '通过邮箱验证码验证后可更改登录密码', 'aksrt' ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn-primary btn-sm security-trigger" data-modal="pwd-modal">
|
||||
<?php esc_html_e( '修改', 'aksrt' ); ?>
|
||||
</button>
|
||||
</div>
|
||||
<!-- 更改邮箱 -->
|
||||
<div class="security-action-item">
|
||||
<div class="security-action-info">
|
||||
<span class="security-action-icon"><i class="far fa-envelope" aria-hidden="true"></i></span>
|
||||
<div class="security-action-text">
|
||||
<span class="security-action-title"><?php esc_html_e( '更改邮箱', 'aksrt' ); ?></span>
|
||||
<span class="security-action-desc"><?php esc_html_e( '更新用于接收通知和找回密码的邮箱地址', 'aksrt' ); ?></span>
|
||||
</div>
|
||||
</div>
|
||||
<button type="button" class="btn-primary btn-sm security-trigger" data-modal="email-modal">
|
||||
<?php esc_html_e( '更改', 'aksrt' ); ?>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php if ( $show_invite_section ) : ?>
|
||||
<div class="settings-section">
|
||||
<div class="settings-section__header">
|
||||
<span class="settings-icon"><i class="fas fa-user-plus" aria-hidden="true"></i></span>
|
||||
<h3 class="widget-title settings-section__title"><?php esc_html_e( '邀请好友', 'aksrt' ); ?></h3>
|
||||
</div>
|
||||
<div class="aksrt-invite-panel" data-aksrt-invite>
|
||||
<div class="aksrt-invite-hero">
|
||||
<div class="aksrt-invite-hero__main">
|
||||
<span class="aksrt-invite-kicker"><?php esc_html_e( '邀请奖励', 'aksrt' ); ?></span>
|
||||
<p class="aksrt-invite-desc">
|
||||
<?php echo esc_html( sprintf( __( '将专属链接分享给好友,好友完成注册与验证后即可获得双向%s奖励。', 'aksrt' ), $currency_name ) ); ?>
|
||||
</p>
|
||||
</div>
|
||||
<div class="aksrt-invite-code-card">
|
||||
<span><?php esc_html_e( '邀请码', 'aksrt' ); ?></span>
|
||||
<strong data-invite-code>--</strong>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aksrt-invite-link-row">
|
||||
<input type="text" class="aksrt-invite-link" data-invite-link readonly value="" aria-label="<?php esc_attr_e( '邀请链接', 'aksrt' ); ?>">
|
||||
<button type="button" class="btn-primary btn-sm aksrt-invite-copy" data-invite-copy>
|
||||
<i class="fas fa-copy" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e( '复制链接', 'aksrt' ); ?></span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="aksrt-invite-stats" data-invite-stats>
|
||||
<div class="aksrt-invite-stat">
|
||||
<span><?php esc_html_e( '已注册', 'aksrt' ); ?></span>
|
||||
<strong data-stat="registered">0</strong>
|
||||
<small><?php esc_html_e( '通过链接完成注册', 'aksrt' ); ?></small>
|
||||
</div>
|
||||
<div class="aksrt-invite-stat">
|
||||
<span><?php esc_html_e( '已验证', 'aksrt' ); ?></span>
|
||||
<strong data-stat="verified">0</strong>
|
||||
<small><?php esc_html_e( '完成邮箱验证', 'aksrt' ); ?></small>
|
||||
</div>
|
||||
<div class="aksrt-invite-stat">
|
||||
<span><?php esc_html_e( '已奖励', 'aksrt' ); ?></span>
|
||||
<strong data-stat="rewarded">0</strong>
|
||||
<small><?php esc_html_e( '奖励已发放', 'aksrt' ); ?></small>
|
||||
</div>
|
||||
</div>
|
||||
<div class="aksrt-invite-records">
|
||||
<div class="aksrt-invite-records__header">
|
||||
<h4><?php esc_html_e( '邀请记录', 'aksrt' ); ?></h4>
|
||||
<span data-invite-total><?php esc_html_e( '加载中', 'aksrt' ); ?></span>
|
||||
</div>
|
||||
<div class="aksrt-invite-record-list is-loading" data-invite-list>
|
||||
<div class="aksrt-invite-record-empty">
|
||||
<?php esc_html_e( '正在加载邀请记录...', 'aksrt' ); ?>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<!-- 隐藏字段 -->
|
||||
<input type="hidden" id="aksrt-settings-nonce" value="<?php echo wp_create_nonce( 'aksrt_account_settings' ); ?>">
|
||||
<input type="hidden" id="aksrt-oauth-unbind-nonce" value="<?php echo wp_create_nonce( 'aksrt_oauth_unbind' ); ?>">
|
||||
<input type="hidden" id="aksrt-user-email" value="<?php echo esc_attr( $user_email ); ?>">
|
||||
<input type="hidden" id="aksrt-ajax-url" value="<?php echo admin_url( 'admin-ajax.php' ); ?>">
|
||||
<input type="hidden" id="aksrt-login-url" value="<?php echo esc_attr( aksrt_get_login_url() ); ?>">
|
||||
<input type="hidden" id="aksrt-public-nonce" value="<?php echo wp_create_nonce( 'aksrt_public_nonce' ); ?>">
|
||||
</div>
|
||||
|
||||
<!-- ==================== 修改密码弹窗 ==================== -->
|
||||
<div id="pwd-modal" class="aksrt-modal" role="dialog" aria-modal="true" aria-label="<?php esc_attr_e( '修改密码', 'aksrt' ); ?>">
|
||||
<div class="aksrt-modal__overlay" data-close-modal></div>
|
||||
<div class="aksrt-modal__box">
|
||||
<div class="aksrt-modal__header">
|
||||
<div class="aksrt-modal__title-wrap">
|
||||
<span class="aksrt-modal__icon"><i class="fas fa-lock" aria-hidden="true"></i></span>
|
||||
<h4><?php esc_html_e( '修改密码', 'aksrt' ); ?></h4>
|
||||
</div>
|
||||
<button type="button" class="aksrt-modal__close" data-close-modal title="<?php esc_attr_e( '关闭', 'aksrt' ); ?>"><i class="fas fa-times" aria-hidden="true"></i></button>
|
||||
</div>
|
||||
<form id="pwd-form" autocomplete="off" novalidate>
|
||||
<div class="modal-field">
|
||||
<label for="pwd-old"><?php esc_html_e( '原密码', 'aksrt' ); ?></label>
|
||||
<input type="password" id="pwd-old" name="old_password" required minlength="1">
|
||||
<button type="button" class="toggle-pwd" data-target="pwd-old"></button>
|
||||
</div>
|
||||
<div class="modal-field">
|
||||
<label for="pwd-new"><?php esc_html_e( '新密码', 'aksrt' ); ?></label>
|
||||
<input type="password" id="pwd-new" name="new_password" required minlength="6" placeholder="<?php esc_attr_e( '至少6位字符', 'aksrt' ); ?>">
|
||||
<button type="button" class="toggle-pwd" data-target="pwd-new"></button>
|
||||
<div class="pwd-strength" id="pwd-strength-bar">
|
||||
<div class="pwd-strength__fill"></div>
|
||||
</div>
|
||||
<span class="pwd-strength__text" id="pwd-strength-text"></span>
|
||||
</div>
|
||||
<div class="modal-field">
|
||||
<label for="pwd-new-confirm"><?php esc_html_e( '确认新密码', 'aksrt' ); ?></label>
|
||||
<input type="password" id="pwd-new-confirm" name="new_password_confirm" required minlength="6" placeholder="<?php esc_attr_e( '再次输入新密码', 'aksrt' ); ?>">
|
||||
<button type="button" class="toggle-pwd" data-target="pwd-new-confirm"></button>
|
||||
</div>
|
||||
<div class="modal-field modal-field--code">
|
||||
<label for="pwd-code"><?php esc_html_e( '当前邮箱验证码', 'aksrt' ); ?></label>
|
||||
<div class="code-input-group">
|
||||
<input type="text" id="pwd-code" name="email_code" maxlength="6" inputmode="numeric" pattern="[0-9]*" placeholder="6位数字验证码" required>
|
||||
<button type="button" class="btn-ghost btn-sm code-send-btn" id="pwd-send-code"><?php esc_html_e( '发送到当前邮箱', 'aksrt' ); ?></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php aksrt_render_captcha('change_password'); ?>
|
||||
|
||||
<div class="aksrt-modal__footer">
|
||||
<button type="button" class="btn-ghost btn-sm" data-close-modal><?php esc_html_e( '取消', 'aksrt' ); ?></button>
|
||||
<button type="submit" class="btn-primary btn-sm" id="pwd-submit"><?php esc_html_e( '确认修改', 'aksrt' ); ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- ==================== 更改邮箱弹窗 ==================== -->
|
||||
<div id="email-modal" class="aksrt-modal" role="dialog" aria-modal="true" aria-label="<?php esc_attr_e( '更改邮箱', 'aksrt' ); ?>">
|
||||
<div class="aksrt-modal__overlay" data-close-modal></div>
|
||||
<div class="aksrt-modal__box">
|
||||
<div class="aksrt-modal__header">
|
||||
<div class="aksrt-modal__title-wrap">
|
||||
<span class="aksrt-modal__icon"><i class="far fa-envelope" aria-hidden="true"></i></span>
|
||||
<h4><?php esc_html_e( '更改邮箱', 'aksrt' ); ?></h4>
|
||||
</div>
|
||||
<button type="button" class="aksrt-modal__close" data-close-modal title="<?php esc_attr_e( '关闭', 'aksrt' ); ?>"><i class="fas fa-times" aria-hidden="true"></i></button>
|
||||
</div>
|
||||
<form id="email-form" autocomplete="off" novalidate>
|
||||
<div class="modal-field">
|
||||
<label><?php esc_html_e( '当前邮箱', 'aksrt' ); ?></label>
|
||||
<div class="readonly-display"><?php echo esc_html( $user_email ); ?></div>
|
||||
</div>
|
||||
<div class="modal-field">
|
||||
<label for="email-current-password"><?php esc_html_e( '当前密码', 'aksrt' ); ?></label>
|
||||
<input type="password" id="email-current-password" name="current_password" required minlength="1" placeholder="<?php esc_attr_e( '请输入当前登录密码', 'aksrt' ); ?>">
|
||||
<button type="button" class="toggle-pwd" data-target="email-current-password"></button>
|
||||
</div>
|
||||
<div class="modal-field">
|
||||
<label for="email-new"><?php esc_html_e( '新邮箱', 'aksrt' ); ?></label>
|
||||
<input type="email" id="email-new" name="new_email" required placeholder="<?php esc_attr_e( '请输入新的邮箱地址', 'aksrt' ); ?>">
|
||||
</div>
|
||||
<div class="modal-field modal-field--code">
|
||||
<label for="email-code"><?php esc_html_e( '新邮箱验证码', 'aksrt' ); ?></label>
|
||||
<div class="code-input-group">
|
||||
<input type="text" id="email-code" name="email_code" maxlength="6" inputmode="numeric" pattern="[0-9]*" placeholder="6位数字验证码" required>
|
||||
<button type="button" class="btn-ghost btn-sm code-send-btn" id="email-send-code"><?php esc_html_e( '发送到新邮箱', 'aksrt' ); ?></button>
|
||||
</div>
|
||||
<p class="settings-hint settings-hint--bottom"><?php esc_html_e( '验证码将发送到你填写的新邮箱,验证通过后才会正式切换。', 'aksrt' ); ?></p>
|
||||
</div>
|
||||
|
||||
<?php aksrt_render_captcha('change_email'); ?>
|
||||
|
||||
<div class="aksrt-modal__footer">
|
||||
<button type="button" class="btn-ghost btn-sm" data-close-modal><?php esc_html_e( '取消', 'aksrt' ); ?></button>
|
||||
<button type="submit" class="btn-primary btn-sm" id="email-submit"><?php esc_html_e( '确认更改', 'aksrt' ); ?></button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div><!-- /.uc-content -->
|
||||
</div><!-- /.uc-layout -->
|
||||
</div><!-- /.user-center -->
|
||||
|
||||
<?php else : ?>
|
||||
<!-- ===================== 他人模式:公开用户主页 ===================== -->
|
||||
<header class="profile-public-header"<?php if ( ! empty( $user_home_settings['cover'] ) && $user_background_url ) echo ' style="--user-bg:url(' . esc_url( $user_background_url ) . ')"'; ?>>
|
||||
<div class="profile-public-left">
|
||||
<?php echo get_avatar( $user_id, 96, '', $target_user->display_name ); ?>
|
||||
<h1><?php echo esc_html( $target_user->display_name ); ?></h1>
|
||||
|
||||
<?php if ( ! empty( $profile_signals ) ) : ?>
|
||||
<div class="aksrt-identity-chips">
|
||||
<?php foreach ( $profile_signals as $signal ) : ?>
|
||||
<span class="aksrt-identity-chip aksrt-identity-chip--<?php echo esc_attr( $signal['tone'] ); ?>">
|
||||
<i class="fas fa-<?php echo esc_attr( $signal['icon'] ); ?>" aria-hidden="true"></i>
|
||||
<span><?php echo esc_html( $signal['label'] ); ?></span>
|
||||
</span>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( ! empty( $user_contacts ) && ! empty( $user_center_settings['social_links'] ) ) : ?>
|
||||
<div class="profile-public-contacts">
|
||||
<?php if ( function_exists( 'aksrt_render_social_links' ) ) : ?>
|
||||
<?php aksrt_render_social_links( $user_contacts ); ?>
|
||||
<?php else : ?>
|
||||
<?php foreach ( $user_contacts as $c ) : ?>
|
||||
<a href="<?php echo esc_url( $c['url'] ?? '#' ); ?>" target="_blank" rel="noopener" title="<?php echo esc_attr( $c['name'] ?? '' ); ?>">
|
||||
<?php echo esc_html( $c['name'] ?? '' ); ?>
|
||||
</a>
|
||||
<?php endforeach; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<div class="profile-public-right">
|
||||
<?php if ( $target_user->description ) : ?>
|
||||
<p><?php echo nl2br( esc_html( $target_user->description ) ); ?></p>
|
||||
<?php else : ?>
|
||||
<p class="profile-public-empty"><?php esc_html_e( '这个人很懒,还没有填写个人简介', 'aksrt' ); ?></p>
|
||||
<?php endif; ?>
|
||||
<div class="uc-header__actions">
|
||||
<?php if ( ! empty( $user_home_settings['follow'] ) ) : ?>
|
||||
<?php if ( is_user_logged_in() ) : ?>
|
||||
<button type="button" class="btn-outline btn-sm aksrt-user-home__follow-btn" data-aksrt-follow="<?php echo (int) $user_id; ?>" title="<?php esc_attr_e( '关注该用户', 'aksrt' ); ?>">
|
||||
<i class="far fa-heart" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e( '关注', 'aksrt' ); ?></span>
|
||||
@@ -1,222 +0,0 @@
|
||||
<?php
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
</button>
|
||||
<?php else : ?>
|
||||
<a href="<?php echo esc_url( aksrt_get_login_url( $public_home_url ) ); ?>" class="btn-outline btn-sm aksrt-user-home__follow-btn">
|
||||
<i class="far fa-heart" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e( '登录后关注', 'aksrt' ); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
<?php if ( $show_report_button ) : ?>
|
||||
<?php if ( is_user_logged_in() ) : ?>
|
||||
<button type="button" class="btn-ghost btn-sm aksrt-user-home__report-btn" data-aksrt-report='{"target_type":"user","target_id":<?php echo (int) $user_id; ?>}' title="<?php esc_attr_e( '举报该用户', 'aksrt' ); ?>">
|
||||
<i class="far fa-flag" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e( '举报', 'aksrt' ); ?></span>
|
||||
</button>
|
||||
<?php else : ?>
|
||||
<a href="<?php echo esc_url( aksrt_get_login_url( $public_home_url ) ); ?>" class="btn-ghost btn-sm aksrt-user-home__report-btn">
|
||||
<i class="far fa-flag" aria-hidden="true"></i>
|
||||
<span><?php esc_html_e( '登录后举报', 'aksrt' ); ?></span>
|
||||
</a>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
<?php if ( ! empty( $profile_notice ) ) : ?>
|
||||
<div class="aksrt-user-home__notice aksrt-user-home__notice--<?php echo esc_attr( $profile_notice['state'] ); ?>">
|
||||
<i class="fas fa-exclamation-circle" aria-hidden="true"></i>
|
||||
<span><?php echo esc_html( $profile_notice['text'] ); ?></span>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<div class="dashboard dashboard--public" data-default-tab="<?php echo esc_attr( $public_default_tab ); ?>">
|
||||
<div class="dashboard-tabs" role="tablist">
|
||||
<?php foreach ( $public_tab_keys as $public_tab_key ) : ?>
|
||||
<button type="button" class="<?php echo $public_active_tab === $public_tab_key ? 'is-active' : ''; ?>" data-tab="<?php echo esc_attr( $public_tab_key ); ?>" role="tab">
|
||||
<?php echo esc_html( $public_tab_labels[ $public_tab_key ] ?? ucfirst( $public_tab_key ) ); ?>
|
||||
<span class="dashboard-tabs__count"><?php echo esc_html( (string) ( $public_tab_counts[ $public_tab_key ] ?? 0 ) ); ?></span>
|
||||
</button>
|
||||
<?php endforeach; ?>
|
||||
</div>
|
||||
|
||||
<?php if ( in_array( 'posts', $public_tab_keys, true ) ) : ?>
|
||||
<div id="panel-posts" class="dashboard-panel<?php echo 'posts' === $public_active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'posts' !== $public_active_tab ? ' hidden' : ''; ?>>
|
||||
<?php
|
||||
$author_posts = new WP_Query( [
|
||||
'author' => $user_id,
|
||||
'posts_per_page' => $per_page,
|
||||
'post_status' => 'publish',
|
||||
'paged' => $posts_page,
|
||||
'no_found_rows' => false,
|
||||
'update_post_meta_cache' => false,
|
||||
] );
|
||||
if ( $author_posts->have_posts() ) : ?>
|
||||
<div class="profile-list">
|
||||
<?php while ( $author_posts->have_posts() ) : $author_posts->the_post();
|
||||
set_query_var( 'aksrt_profile_item_action', [
|
||||
'type' => 'view',
|
||||
'url' => get_permalink(),
|
||||
'label' => __( '阅读', 'aksrt' ),
|
||||
] );
|
||||
set_query_var( 'aksrt_profile_item_status', '' );
|
||||
get_template_part( 'templates/parts/content', 'profile-list-item' );
|
||||
endwhile; ?>
|
||||
</div>
|
||||
<?php
|
||||
aksrt_render_profile_pagination( (int) $author_posts->max_num_pages, $posts_page, 'posts_page' );
|
||||
wp_reset_postdata();
|
||||
set_query_var( 'aksrt_profile_item_action', [] );
|
||||
else :
|
||||
aksrt_render_profile_empty( $svg_empty_post, __( 'TA 还没有发布文章', 'aksrt' ) );
|
||||
endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( in_array( 'comments', $public_tab_keys, true ) ) : ?>
|
||||
<div id="panel-comments" class="dashboard-panel<?php echo 'comments' === $public_active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'comments' !== $public_active_tab ? ' hidden' : ''; ?>>
|
||||
<?php
|
||||
$user_comments = get_comments( [
|
||||
'user_id' => $user_id,
|
||||
'status' => 'approve',
|
||||
'number' => $per_page,
|
||||
'offset' => ( $comments_page - 1 ) * $per_page,
|
||||
'type' => 'comment',
|
||||
'update_comment_meta_cache' => false,
|
||||
] );
|
||||
if ( $user_comments ) : ?>
|
||||
<div class="profile-comment-list">
|
||||
<?php foreach ( $user_comments as $c ) :
|
||||
set_query_var( 'aksrt_profile_comment', $c );
|
||||
get_template_part( 'templates/parts/content', 'profile-comment-item' );
|
||||
endforeach;
|
||||
set_query_var( 'aksrt_profile_comment', null ); ?>
|
||||
</div>
|
||||
<?php
|
||||
$cm_total_pages = (int) ceil( $comment_count / $per_page );
|
||||
aksrt_render_profile_pagination( $cm_total_pages, $comments_page, 'comments_page' );
|
||||
?>
|
||||
<?php else :
|
||||
aksrt_render_profile_empty( $svg_empty_comment, __( 'TA 还没有发表评论', 'aksrt' ) );
|
||||
endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( in_array( 'favorites', $public_tab_keys, true ) ) : ?>
|
||||
<div id="panel-favorites" class="dashboard-panel<?php echo 'favorites' === $public_active_tab ? ' is-active' : ''; ?>" role="tabpanel"<?php echo 'favorites' !== $public_active_tab ? ' hidden' : ''; ?>>
|
||||
<?php
|
||||
if ( ! empty( $favorite_post_ids ) ) {
|
||||
$favorite_query = new WP_Query( [
|
||||
'post_type' => 'post',
|
||||
'post__in' => $favorite_post_ids,
|
||||
'orderby' => 'post__in',
|
||||
'posts_per_page' => $per_page,
|
||||
'paged' => $favorites_page,
|
||||
'no_found_rows' => false,
|
||||
'update_post_meta_cache' => false,
|
||||
] );
|
||||
} else {
|
||||
$favorite_query = null;
|
||||
}
|
||||
|
||||
if ( $favorite_query && $favorite_query->have_posts() ) :
|
||||
?>
|
||||
<div class="profile-list">
|
||||
<?php while ( $favorite_query->have_posts() ) : $favorite_query->the_post();
|
||||
set_query_var( 'aksrt_profile_item_action', [
|
||||
'type' => 'view',
|
||||
'url' => get_permalink(),
|
||||
'label' => __( '阅读', 'aksrt' ),
|
||||
] );
|
||||
set_query_var( 'aksrt_profile_item_status', '' );
|
||||
get_template_part( 'templates/parts/content', 'profile-list-item' );
|
||||
endwhile; ?>
|
||||
</div>
|
||||
<?php
|
||||
aksrt_render_profile_pagination( (int) $favorite_query->max_num_pages, $favorites_page, 'favorites_page' );
|
||||
wp_reset_postdata();
|
||||
set_query_var( 'aksrt_profile_item_action', [] );
|
||||
else :
|
||||
aksrt_render_profile_empty( $svg_empty_favorite, __( 'TA 还没有公开收藏内容', 'aksrt' ) );
|
||||
endif; ?>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
</div>
|
||||
|
||||
<?php endif; ?>
|
||||
|
||||
<?php if ( $is_own_profile ) : ?>
|
||||
<!-- 配置对象:供 user-center.js 使用 -->
|
||||
<script>window.aksrtUserCenter = {
|
||||
ajaxUrl: <?php echo wp_json_encode( admin_url( 'admin-ajax.php' ) ); ?>,
|
||||
publicNonce: <?php echo wp_json_encode( wp_create_nonce( 'aksrt_public_nonce' ) ); ?>,
|
||||
settingsNonce: <?php echo wp_json_encode( wp_create_nonce( 'aksrt_account_settings' ) ); ?>,
|
||||
userId: <?php echo (int) $user_id; ?>,
|
||||
defaultTab: <?php echo wp_json_encode( $default_dashboard_tab ); ?>,
|
||||
i18n: {
|
||||
contactUrlPlaceholder: <?php echo wp_json_encode( __( '链接 URL', 'aksrt' ) ); ?>,
|
||||
deleteLabel: <?php echo wp_json_encode( __( '删除', 'aksrt' ) ); ?>,
|
||||
saving: <?php echo wp_json_encode( __( '保存中…', 'aksrt' ) ); ?>,
|
||||
saveBtn: <?php echo wp_json_encode( __( '保存修改', 'aksrt' ) ); ?>,
|
||||
saved: <?php echo wp_json_encode( __( '已保存', 'aksrt' ) ); ?>,
|
||||
saveFailed: <?php echo wp_json_encode( __( '保存失败', 'aksrt' ) ); ?>,
|
||||
networkError: <?php echo wp_json_encode( __( '网络错误,请重试', 'aksrt' ) ); ?>,
|
||||
confirmUnfavorite: <?php echo wp_json_encode( __( '确定取消收藏这篇文章?', 'aksrt' ) ); ?>,
|
||||
unfavorited: <?php echo wp_json_encode( __( '已取消收藏', 'aksrt' ) ); ?>,
|
||||
operationFailed: <?php echo wp_json_encode( __( '操作失败', 'aksrt' ) ); ?>,
|
||||
markedRead: <?php echo wp_json_encode( __( '已标记为已读', 'aksrt' ) ); ?>,
|
||||
notificationDeleted: <?php echo wp_json_encode( __( '已删除通知', 'aksrt' ) ); ?>,
|
||||
allMarkedRead: <?php echo wp_json_encode( __( '已全部标记为已读', 'aksrt' ) ); ?>,
|
||||
selectNotifications: <?php echo wp_json_encode( __( '请先选择要标记的通知', 'aksrt' ) ); ?>,
|
||||
selectedMarkedRead: <?php echo wp_json_encode( __( '已标记所选通知为已读', 'aksrt' ) ); ?>,
|
||||
confirmDeleteNotification: <?php echo wp_json_encode( __( '确定删除这条通知?', 'aksrt' ) ); ?>,
|
||||
confirmBatchDelete: <?php echo wp_json_encode( __( '确定批量删除所选通知?', 'aksrt' ) ); ?>,
|
||||
batchDeleted: <?php echo wp_json_encode( __( '已删除所选通知', 'aksrt' ) ); ?>,
|
||||
sendToCurrentEmail: <?php echo wp_json_encode( __( '发送到当前邮箱', 'aksrt' ) ); ?>,
|
||||
sendToNewEmail: <?php echo wp_json_encode( __( '发送到新邮箱', 'aksrt' ) ); ?>,
|
||||
sendCode: <?php echo wp_json_encode( __( '发送验证码', 'aksrt' ) ); ?>,
|
||||
sending: <?php echo wp_json_encode( __( '发送中...', 'aksrt' ) ); ?>,
|
||||
codeSent: <?php echo wp_json_encode( __( '验证码已发送', 'aksrt' ) ); ?>,
|
||||
sendFailed: <?php echo wp_json_encode( __( '发送失败', 'aksrt' ) ); ?>,
|
||||
fillRequired: <?php echo wp_json_encode( __( '请填写必填项', 'aksrt' ) ); ?>,
|
||||
passwordMismatch: <?php echo wp_json_encode( __( '两次输入的新密码不一致', 'aksrt' ) ); ?>,
|
||||
submitting: <?php echo wp_json_encode( __( '提交中...', 'aksrt' ) ); ?>,
|
||||
confirmUnbind: <?php echo wp_json_encode( __( '确定解除绑定?', 'aksrt' ) ); ?>,
|
||||
unbinding: <?php echo wp_json_encode( __( '解除中...', 'aksrt' ) ); ?>,
|
||||
unbindSuccess: <?php echo wp_json_encode( __( '解除成功', 'aksrt' ) ); ?>,
|
||||
unbindFailed: <?php echo wp_json_encode( __( '解除失败', 'aksrt' ) ); ?>,
|
||||
unbind: <?php echo wp_json_encode( __( '解除', 'aksrt' ) ); ?>
|
||||
}
|
||||
};</script>
|
||||
|
||||
<?php if ( $allow_bg_upload ) : ?>
|
||||
<script>
|
||||
window.aksrtAuthorPage = Object.assign({}, window.aksrtAuthorPage || {}, {
|
||||
coverUpload: {
|
||||
enabled: true,
|
||||
restUrl: <?php echo wp_json_encode( rest_url( 'aksrt/v1/user/background' ) ); ?>,
|
||||
restNonce: <?php echo wp_json_encode( wp_create_nonce( 'wp_rest' ) ); ?>,
|
||||
buttonId: 'aksrt-upload-bg-btn',
|
||||
inputId: 'aksrt-bg-file-input',
|
||||
imageId: 'aksrt-cover-img',
|
||||
fieldName: 'background',
|
||||
maxSize: 2097152,
|
||||
fallbackImage: <?php echo wp_json_encode( AKSRT_URI . '/assets/img/person_background.png' ); ?>,
|
||||
idleText: <?php echo wp_json_encode( __( '编辑', 'aksrt' ) ); ?>,
|
||||
loadingText: <?php echo wp_json_encode( __( '上传中…', 'aksrt' ) ); ?>,
|
||||
tooLargeText: <?php echo wp_json_encode( __( '图片大小不能超过 2MB', 'aksrt' ) ); ?>,
|
||||
successText: <?php echo wp_json_encode( __( '背景图已更新', 'aksrt' ) ); ?>,
|
||||
errorText: <?php echo wp_json_encode( __( '上传失败', 'aksrt' ) ); ?>,
|
||||
networkErrorText: <?php echo wp_json_encode( __( '网络错误,请重试', 'aksrt' ) ); ?>
|
||||
}
|
||||
});
|
||||
</script>
|
||||
<?php endif; ?>
|
||||
<?php endif; ?>
|
||||
</main>
|
||||
|
||||
<?php
|
||||
get_footer();
|
||||
@@ -1 +1,9 @@
|
||||
<!-- 本人中心 partial 模板目录 -->
|
||||
<!-- 本人用户中心 partial 目录
|
||||
|
||||
当前主路径:
|
||||
- 壳层:templates/pages/page-profile.php
|
||||
- 挂载点:header / sidebar / mobile-tabs / panel-* / account-modals / runtime-config
|
||||
- 渲染器:inc/helpers/user-center-renderers/profile-*.php
|
||||
|
||||
旧 uc-* 草稿 partial 与 templates/parts/profile/part-* 拆分残片已删除,勿再引入。
|
||||
-->
|
||||
|
||||
@@ -1,81 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,59 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,98 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,75 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,71 +0,0 @@
|
||||
<?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>
|
||||
@@ -1 +1,9 @@
|
||||
<!-- 公开用户主页 partial 模板目录 -->
|
||||
<!-- 公开用户主页 partial 目录
|
||||
|
||||
当前主路径:
|
||||
- 壳层:templates/pages/page-user-home.php
|
||||
- 头区:templates/parts/user/author-hero.php
|
||||
- 列表项:templates/parts/content-profile-*.php
|
||||
|
||||
旧 uh-* 草稿 partial 已删除,勿再引入。
|
||||
-->
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,66 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,55 +0,0 @@
|
||||
<?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>
|
||||
@@ -1,106 +0,0 @@
|
||||
<?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>
|
||||
Reference in New Issue
Block a user