43 lines
2.0 KiB
PHP
43 lines
2.0 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'] ?? [];
|
|
if (is_string($images)) {
|
|
$images = array_filter(array_map('absint', explode(',', $images)));
|
|
}
|
|
$image_url = '';
|
|
if (is_array($images) && $images) {
|
|
$image_url = (string) wp_get_attachment_url((int) $images[array_rand($images)]);
|
|
}
|
|
$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_url !== '' ? ' 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_url !== '') : ?><div class="sign-img" style="background-image:url('<?php echo esc_url($image_url); ?>')"></div><?php endif; ?>
|
|
<?php require get_template_directory() . '/templates/parts/auth-content.php'; ?>
|
|
</div>
|
|
</div>
|
|
</div>
|