Files
wordpress-theme-aksrt/templates/parts/modal-auth.php
T
2026-08-23 20:59:34 +08:00

43 lines
2.1 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" 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']); ?>">
<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>