44 lines
2.3 KiB
PHP
44 lines
2.3 KiB
PHP
<?php
|
|
/**
|
|
* Shared authentication modal shell.
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
if (is_user_logged_in() || (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::close_sign())) {
|
|
return;
|
|
}
|
|
|
|
$modal_ui = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::modal_ui() : [];
|
|
$images = $modal_ui['background'] ?? [];
|
|
$image_id = $images ? (int) $images[array_rand($images)] : 0;
|
|
$image_html = $image_id > 0 ? wp_get_attachment_image($image_id, 'full', false, [
|
|
'class' => 'fit-cover radius8',
|
|
'alt' => get_bloginfo('name'),
|
|
'loading' => 'lazy',
|
|
'decoding' => 'async',
|
|
]) : '';
|
|
$auto = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::sign_modal_auto() : ['enabled' => false, 'waiting' => 5, 'expires' => 1];
|
|
$wechat = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_weixingzh_settings() : [];
|
|
$initial_tab = !empty($wechat['priority']) && class_exists('\AKSRT\Auth\WeixinGzh') && \AKSRT\Auth\WeixinGzh::is_enabled() ? 'oauth' : 'signin';
|
|
$aksrt_auth_context = [
|
|
'surface' => 'modal',
|
|
'tab' => $initial_tab,
|
|
'show_logo' => !empty($modal_ui['show_logo']),
|
|
'redirect_to' => home_url('/'),
|
|
];
|
|
?>
|
|
<div id="u_sign" class="aksrt-auth-modal<?php echo $image_html !== '' ? ' has-sign-img' : ''; ?>" aria-hidden="true" role="dialog" aria-modal="true" aria-labelledby="aksrt-auth-modal-title" tabindex="-1" data-auth-modal data-auto="<?php echo !empty($auto['enabled']) ? '1' : '0'; ?>" data-auto-wait="<?php echo esc_attr((string) $auto['waiting']); ?>" data-auto-expires="<?php echo esc_attr((string) $auto['expires']); ?>">
|
|
<h2 id="aksrt-auth-modal-title" class="screen-reader-text"><?php esc_html_e('账户登录与注册', 'aksrt'); ?></h2>
|
|
<div class="auth-modal-backdrop" data-auth-close></div>
|
|
<div class="modal-dialog">
|
|
<div class="modal-content">
|
|
<button type="button" class="auth-modal-close" data-auth-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fa fas fa-times"></i></button>
|
|
<?php if ($image_html !== '') : ?><div class="sign-img"><?php echo $image_html; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped ?></div><?php endif; ?>
|
|
<?php require get_template_directory() . '/templates/parts/auth-content.php'; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|