403 lines
18 KiB
PHP
403 lines
18 KiB
PHP
<?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)) : ?>
|