用户中心 credits/settings 渲染器整包拆分:编排器 + 子块
This commit is contained in:
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
/**
|
||||
* User center credits: balance card + sign-in controls.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$balance = (float) ($credit_balance ?? 0.0);
|
||||
$credits_enabled = !empty($credits_enabled);
|
||||
?>
|
||||
<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>
|
||||
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
/**
|
||||
* User center credits: sign-in captcha + recent calendar.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$credits_enabled = !empty($credits_enabled);
|
||||
if (!$credits_enabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (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;
|
||||
|
||||
$signin_dates = [];
|
||||
if (class_exists('AKSRT_Signin')) {
|
||||
$signin_log = AKSRT_Signin::get_instance()->get_recent_signins($user_id, 30);
|
||||
$signin_dates = array_filter(array_map(static function ($entry) {
|
||||
return $entry['signin_date'] ?? '';
|
||||
}, $signin_log));
|
||||
}
|
||||
|
||||
if (empty($signin_dates)) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<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>
|
||||
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
/**
|
||||
* User center credits: transaction log list.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
?>
|
||||
<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: balance */
|
||||
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>
|
||||
@@ -0,0 +1,50 @@
|
||||
<?php
|
||||
/**
|
||||
* User center credits: VIP membership card.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$vip_settings = is_array($vip_settings ?? null) ? $vip_settings : [];
|
||||
if (empty($vip_settings['enabled'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$is_vip_user = function_exists('aksrt_is_vip') && aksrt_is_vip($user_id);
|
||||
?>
|
||||
<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>
|
||||
<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>
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* User center profile credits part.
|
||||
* User center profile credits part (orchestrator).
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -9,169 +9,9 @@ defined('ABSPATH') || exit;
|
||||
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
||||
?>
|
||||
<?php
|
||||
$balance = (float) ($credit_balance ?? 0.0);
|
||||
$credits_enabled = ! empty( $credits_enabled );
|
||||
$vip_settings = is_array( $vip_settings ?? null ) ? $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 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)) : ?>
|
||||
<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>
|
||||
$dir = __DIR__;
|
||||
require $dir . '/credits-balance.php';
|
||||
require $dir . '/credits-vip.php';
|
||||
require $dir . '/credits-signin.php';
|
||||
require $dir . '/credits-transactions.php';
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
/**
|
||||
* User center profile settings part.
|
||||
* User center profile settings part (orchestrator).
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
@@ -9,183 +9,9 @@ defined('ABSPATH') || exit;
|
||||
|
||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||
extract($context, EXTR_SKIP); // phpcs:ignore WordPress.PHP.DontExtract.extract_extract
|
||||
?>
|
||||
<!-- ==================== 账号设置 ==================== -->
|
||||
<?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' ); ?>">
|
||||
$dir = __DIR__;
|
||||
require $dir . '/settings-bindings.php';
|
||||
require $dir . '/settings-security.php';
|
||||
require $dir . '/settings-invite.php';
|
||||
require $dir . '/settings-runtime-fields.php';
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<?php
|
||||
/**
|
||||
* User center settings: OAuth binding list.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$oauth = class_exists('AKSRT_OAuth') ? AKSRT_OAuth::get_instance() : null;
|
||||
$oauth_data = $oauth ? $oauth->get_frontend_bindings_data($user_id) : ['bindings' => [], 'available' => []];
|
||||
$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']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></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']; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></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>
|
||||
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
/**
|
||||
* User center settings: invite friends panel.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
if (empty($show_invite_section)) {
|
||||
return;
|
||||
}
|
||||
?>
|
||||
<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>
|
||||
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
/**
|
||||
* User center settings: hidden runtime fields for JS.
|
||||
*
|
||||
* Expects extracted $context vars.
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
|
||||
$user_email = isset($target_user) && $target_user instanceof WP_User
|
||||
? (string) $target_user->user_email
|
||||
: (string) ($user_email ?? '');
|
||||
?>
|
||||
<input type="hidden" id="aksrt-settings-nonce" value="<?php echo esc_attr(wp_create_nonce('aksrt_account_settings')); ?>">
|
||||
<input type="hidden" id="aksrt-oauth-unbind-nonce" value="<?php echo esc_attr(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 esc_url(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 esc_attr(wp_create_nonce('aksrt_public_nonce')); ?>">
|
||||
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
/**
|
||||
* User center settings: security actions (password / email).
|
||||
*
|
||||
* @package AKSRT
|
||||
*/
|
||||
|
||||
defined('ABSPATH') || exit;
|
||||
?>
|
||||
<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>
|
||||
@@ -7,8 +7,12 @@
|
||||
- aksrt_user_center_resolve_tabs()
|
||||
- aksrt_capture_user_center_view() (profile → form 映射)
|
||||
- 挂载点:header / sidebar / mobile-tabs / panel / account-modals / runtime-config
|
||||
- 渲染器:inc/helpers/user-center-renderers/profile-*.php
|
||||
- profile 面板内容文件为 profile-form.php
|
||||
- 渲染器:inc/helpers/user-center-renderers/
|
||||
- profile-form / posts / comments / favorites / header / sidebar / account-modals
|
||||
- profile-credits.php 编排:
|
||||
credits-balance / credits-vip / credits-signin / credits-transactions
|
||||
- profile-settings.php 编排:
|
||||
settings-bindings / settings-security / settings-invite / settings-runtime-fields
|
||||
|
||||
样式归属:
|
||||
- assets/css/routes/user-center.css
|
||||
|
||||
Reference in New Issue
Block a user