Move 288 types from global AKSRT_* + inc/classes manual requires into
namespace AKSRT\{Domain} under src/AKSRT/, wire composer.json psr-4,
and slim bootstrap to helpers/modules/hooks only. Split multi-class
widget/gateway files, update admin contract audit paths, and document
the layout in ADR/README.
88 lines
3.2 KiB
PHP
88 lines
3.2 KiB
PHP
<?php
|
|
/**
|
|
* User center settings: OAuth binding list.
|
|
*
|
|
* Expects extracted $context vars.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$oauth = class_exists('\AKSRT\Auth\OAuth') ? \AKSRT\Auth\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>
|