192 lines
8.5 KiB
PHP
192 lines
8.5 KiB
PHP
<?php
|
|
/**
|
|
* User center profile settings part.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
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' ); ?>">
|