用户中心 credits/settings 渲染器整包拆分:编排器 + 子块
This commit is contained in:
1 parent
f43519b1df
commit
81d5647205
11 files changed
+442
-348
No files matched your search
@@ -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>
|
||||
Reference in new issue
Block a user