73 lines
3.4 KiB
PHP
73 lines
3.4 KiB
PHP
<?php
|
|
/**
|
|
* Template Name: AKSRT - 登录注册
|
|
* Template Post Type: page
|
|
*
|
|
* @package AKSRT
|
|
*/
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
$allowed_tabs = ['signin', 'signup', 'resetpassword', 'bind', 'oauth'];
|
|
$tab = isset($_GET['tab']) ? sanitize_key(wp_unslash((string) $_GET['tab'])) : 'signin';
|
|
$tab = in_array($tab, $allowed_tabs, true) ? $tab : 'signin';
|
|
$wechat = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_weixingzh_settings() : [];
|
|
if (!isset($_GET['tab']) && !empty($wechat['priority']) && class_exists('\AKSRT\Auth\WeixinGzh') && \AKSRT\Auth\WeixinGzh::is_enabled()) {
|
|
$tab = 'oauth';
|
|
}
|
|
$interim = isset($_REQUEST['interim-login']);
|
|
$redirect_to = !empty($_GET['redirect_to']) ? esc_url_raw(wp_unslash((string) $_GET['redirect_to'])) : home_url('/');
|
|
$obk = !empty($_GET['obk']) ? sanitize_text_field(wp_unslash((string) $_GET['obk'])) : '';
|
|
if (is_user_logged_in() && $tab !== 'bind' && $tab !== 'oauth') {
|
|
wp_safe_redirect($redirect_to);
|
|
exit;
|
|
}
|
|
if (class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::close_sign() && !$interim) {
|
|
wp_safe_redirect(home_url('/'));
|
|
exit;
|
|
}
|
|
if ($tab === 'signup' && class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::registration_enabled()) {
|
|
$tab = 'signin';
|
|
}
|
|
|
|
remove_action('wp_footer', 'aksrt_render_footer_tabbar', 20);
|
|
remove_action('wp_footer', 'aksrt_render_float_buttons', 30);
|
|
$ui = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::sign_page_ui() : [];
|
|
$images = $ui['background'] ?? [];
|
|
if (is_string($images)) {
|
|
$images = array_filter(array_map('absint', explode(',', $images)));
|
|
}
|
|
$background_url = is_array($images) && $images ? (string) wp_get_attachment_url((int) $images[array_rand($images)]) : '';
|
|
$theme_mode = (string) ($ui['theme_mode'] ?? 'no');
|
|
$position = (string) ($ui['card_position'] ?? 'right');
|
|
$aksrt_auth_context = [
|
|
'surface' => 'page',
|
|
'tab' => $tab,
|
|
'show_logo' => !empty($ui['show_logo']),
|
|
'redirect_to' => $redirect_to,
|
|
'obk' => $obk,
|
|
];
|
|
?>
|
|
<!doctype html>
|
|
<html <?php language_attributes(); ?>>
|
|
<head>
|
|
<meta charset="<?php bloginfo('charset'); ?>">
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<meta name="robots" content="noindex,nofollow">
|
|
<title><?php echo esc_html__('登录 / 注册', 'aksrt') . ' - ' . esc_html(get_bloginfo('name')); ?></title>
|
|
<?php wp_head(); ?>
|
|
</head>
|
|
<body <?php body_class('page-template-user-sign ' . ($theme_mode !== 'no' ? $theme_mode : '')); ?>>
|
|
<?php wp_body_open(); ?>
|
|
<div class="sign-page-background"<?php echo $background_url !== '' ? ' style="background-image:url(\'' . esc_url($background_url) . '\')"' : ''; ?>></div>
|
|
<?php if (!empty($ui['show_header']) && !$interim) : ?><header class="sign-topbar"><a href="<?php echo esc_url(home_url('/')); ?>"><?php echo esc_html(get_bloginfo('name')); ?></a><a href="<?php echo esc_url(home_url('/')); ?>"><?php esc_html_e('返回首页', 'aksrt'); ?></a></header><?php endif; ?>
|
|
<main class="sign-page sign-card-position-<?php echo esc_attr($position); ?>">
|
|
<div class="sign-page-card">
|
|
<?php require get_template_directory() . '/templates/parts/auth-content.php'; ?>
|
|
</div>
|
|
</main>
|
|
<?php if (!$interim) : ?><footer class="sign-page-footer"><?php echo !empty($ui['footer']) ? wp_kses_post((string) $ui['footer']) : '© ' . esc_html(wp_date('Y')) . ' ' . esc_html(get_bloginfo('name')); ?></footer><?php endif; ?>
|
|
<?php wp_footer(); ?>
|
|
</body>
|
|
</html>
|