Files
wordpress-theme-aksrt/templates/parts/profile/part-3.php
T

403 lines
20 KiB
PHP

<?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>