365 lines
18 KiB
PHP
365 lines
18 KiB
PHP
<?php
|
|
/**
|
|
* پورتال مشتریان — ورود، عضویت و بازیابی رمز (مجتمع)
|
|
*
|
|
* @package Hesabix2
|
|
*/
|
|
|
|
if ( ! defined( 'ABSPATH' ) ) {
|
|
exit;
|
|
}
|
|
|
|
if ( ! function_exists( 'hesabix2_portal_auth_safe_redirect_target' ) ) {
|
|
/**
|
|
* مقصد بازگشت را به آدرسهای امن همین سایت محدود میکند.
|
|
*
|
|
* @param mixed $raw مقدار خام query string.
|
|
* @return string
|
|
*/
|
|
function hesabix2_portal_auth_safe_redirect_target( $raw ) {
|
|
$fallback = home_url( '/' );
|
|
$target = is_string( $raw ) ? trim( wp_unslash( $raw ) ) : '';
|
|
if ( '' === $target ) {
|
|
return $fallback;
|
|
}
|
|
|
|
$target = wp_validate_redirect( esc_url_raw( $target ), $fallback );
|
|
|
|
$home_host = wp_parse_url( home_url( '/' ), PHP_URL_HOST );
|
|
$target_host = wp_parse_url( $target, PHP_URL_HOST );
|
|
if ( $target_host && $home_host && strtolower( (string) $target_host ) !== strtolower( (string) $home_host ) ) {
|
|
return $fallback;
|
|
}
|
|
|
|
return $target;
|
|
}
|
|
}
|
|
|
|
$explicit_redirect = isset( $_GET['redirect_to'] ) && '' !== trim( wp_unslash( (string) $_GET['redirect_to'] ) );
|
|
$redirect_to = hesabix2_portal_auth_safe_redirect_target( $_GET['redirect_to'] ?? '' );
|
|
|
|
if ( is_user_logged_in() ) {
|
|
$dest = function_exists( 'hpauth_resolve_post_login_redirect' )
|
|
? hpauth_resolve_post_login_redirect( $redirect_to, $explicit_redirect )
|
|
: $redirect_to;
|
|
wp_safe_redirect( $dest );
|
|
exit;
|
|
}
|
|
|
|
$initial_tab = isset( $_GET['hpauth'] ) ? sanitize_key( wp_unslash( $_GET['hpauth'] ) ) : 'login';
|
|
if ( ! in_array( $initial_tab, array( 'login', 'register', 'forgot' ), true ) ) {
|
|
$initial_tab = 'login';
|
|
}
|
|
|
|
$back_url = hesabix2_portal_auth_back_url( $redirect_to );
|
|
$back_label = hesabix2_portal_auth_back_label( $back_url );
|
|
$terms_url = hesabix2_portal_auth_terms_url();
|
|
|
|
get_header();
|
|
?>
|
|
|
|
<main class="hpauth-wrap" id="hpauth-app" data-initial-tab="<?php echo esc_attr( $initial_tab ); ?>" data-redirect-to="<?php echo esc_attr( $redirect_to ); ?>" data-had-redirect="<?php echo $explicit_redirect ? '1' : '0'; ?>">
|
|
<header class="hpauth-topbar">
|
|
<a href="<?php echo esc_url( $back_url ); ?>" class="hpauth-back hpauth-back--topbar">
|
|
<?php hesabix2_portal_auth_icon_back(); ?>
|
|
<span><?php echo esc_html( $back_label ); ?></span>
|
|
</a>
|
|
</header>
|
|
|
|
<div class="hpauth-layout">
|
|
<aside class="hpauth-panel hpauth-panel--benefits" aria-label="<?php esc_attr_e( 'مزایای پورتال مشتریان', 'hesabix2' ); ?>">
|
|
<div class="hpauth-panel__inner">
|
|
<a href="<?php echo esc_url( $back_url ); ?>" class="hpauth-brand">
|
|
<?php
|
|
$custom_logo_id = get_theme_mod( 'custom_logo' );
|
|
$logo = $custom_logo_id ? wp_get_attachment_image_src( $custom_logo_id, 'medium' ) : null;
|
|
if ( $logo ) :
|
|
?>
|
|
<img src="<?php echo esc_url( $logo[0] ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" class="hpauth-brand__img" width="56" height="56" />
|
|
<?php else : ?>
|
|
<span class="hpauth-brand__letter"><?php echo esc_html( mb_substr( get_bloginfo( 'name' ), 0, 1 ) ); ?></span>
|
|
<?php endif; ?>
|
|
<span class="hpauth-brand__name"><?php echo esc_html( get_bloginfo( 'name' ) ); ?></span>
|
|
</a>
|
|
|
|
<h1 class="hpauth-panel__title"><?php esc_html_e( 'پورتال مشتریان', 'hesabix2' ); ?></h1>
|
|
<p class="hpauth-panel__lead">
|
|
<?php esc_html_e( 'برای استفاده از خدمات وبسایت — انجمن، فروشگاه، مطالب آموزشی اختصاصی و پشتیبانی — عضو پورتال مشتریان شوید.', 'hesabix2' ); ?>
|
|
</p>
|
|
|
|
<ul class="hpauth-benefits">
|
|
<li class="hpauth-benefits__item">
|
|
<span class="hpauth-benefits__icon" aria-hidden="true">
|
|
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M21 15a2 2 0 01-2 2H7l-4 4V5a2 2 0 012-2h14a2 2 0 012 2z"/></svg>
|
|
</span>
|
|
<span><?php esc_html_e( 'انجمن تخصصی و پرسشوپاسخ', 'hesabix2' ); ?></span>
|
|
</li>
|
|
<li class="hpauth-benefits__item">
|
|
<span class="hpauth-benefits__icon" aria-hidden="true">
|
|
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><circle cx="9" cy="21" r="1"/><circle cx="20" cy="21" r="1"/><path d="M1 1h4l2.68 13.39a2 2 0 002 1.61h9.72a2 2 0 002-1.61L23 6H6"/></svg>
|
|
</span>
|
|
<span><?php esc_html_e( 'خرید از فروشگاه و پیگیری سفارش', 'hesabix2' ); ?></span>
|
|
</li>
|
|
<li class="hpauth-benefits__item">
|
|
<span class="hpauth-benefits__icon" aria-hidden="true">
|
|
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 19.5A2.5 2.5 0 016.5 17H20"/><path d="M6.5 2H20v20H6.5A2.5 2.5 0 014 19.5v-15A2.5 2.5 0 016.5 2z"/></svg>
|
|
</span>
|
|
<span><?php esc_html_e( 'مطالب آموزشی و مستندات اختصاصی', 'hesabix2' ); ?></span>
|
|
</li>
|
|
<li class="hpauth-benefits__item">
|
|
<span class="hpauth-benefits__icon" aria-hidden="true">
|
|
<svg width="22" height="22" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z"/></svg>
|
|
</span>
|
|
<span><?php esc_html_e( 'حساب یکپارچه در تمام بخشها', 'hesabix2' ); ?></span>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</aside>
|
|
|
|
<section class="hpauth-panel hpauth-panel--form" aria-label="<?php esc_attr_e( 'فرم احراز هویت', 'hesabix2' ); ?>">
|
|
<div class="hpauth-panel__inner">
|
|
<a href="<?php echo esc_url( $back_url ); ?>" class="hpauth-back hpauth-back--form">
|
|
<?php hesabix2_portal_auth_icon_back(); ?>
|
|
<span><?php echo esc_html( $back_label ); ?></span>
|
|
</a>
|
|
|
|
<nav class="hpauth-tabs" role="tablist" aria-label="<?php esc_attr_e( 'نوع عملیات', 'hesabix2' ); ?>">
|
|
<button type="button" class="hpauth-tabs__btn" role="tab" data-tab="login" aria-selected="false" id="hpauth-tab-login">
|
|
<?php esc_html_e( 'ورود', 'hesabix2' ); ?>
|
|
</button>
|
|
<button type="button" class="hpauth-tabs__btn" role="tab" data-tab="register" aria-selected="false" id="hpauth-tab-register">
|
|
<?php esc_html_e( 'عضویت', 'hesabix2' ); ?>
|
|
</button>
|
|
<button type="button" class="hpauth-tabs__btn" role="tab" data-tab="forgot" aria-selected="false" id="hpauth-tab-forgot">
|
|
<?php esc_html_e( 'بازیابی رمز', 'hesabix2' ); ?>
|
|
</button>
|
|
</nav>
|
|
|
|
<div class="hpauth-alert" id="hpauth-alert" role="alert" aria-live="polite" aria-atomic="true" hidden></div>
|
|
|
|
<!-- ورود -->
|
|
<div class="hpauth-view" data-view="login" role="tabpanel" aria-labelledby="hpauth-tab-login" hidden>
|
|
<h2 class="hpauth-view__title"><?php esc_html_e( 'ورود به پورتال', 'hesabix2' ); ?></h2>
|
|
<p class="hpauth-view__desc" data-login-desc>
|
|
<?php
|
|
echo esc_html(
|
|
class_exists( 'Hpauth_Identifier' ) && Hpauth_Identifier::email_login_allowed()
|
|
? __( 'شماره موبایل یا ایمیل خود را وارد کنید.', 'hesabix2' )
|
|
: __( 'شماره موبایل خود را وارد کنید.', 'hesabix2' )
|
|
);
|
|
?>
|
|
</p>
|
|
|
|
<div class="hpauth-mode">
|
|
<button type="button" class="hpauth-mode__btn is-active" data-login-mode="password"><?php esc_html_e( 'رمز عبور', 'hesabix2' ); ?></button>
|
|
<button type="button" class="hpauth-mode__btn" data-login-mode="otp"><?php esc_html_e( 'کد یکبارمصرف', 'hesabix2' ); ?></button>
|
|
</div>
|
|
|
|
<form class="hpauth-form" id="hpauth-form-login-password" data-form="login-password" novalidate>
|
|
<?php hesabix2_portal_auth_identifier_field( 'hpauth-login-identifier' ); ?>
|
|
<div class="hpauth-field" data-login-password-field>
|
|
<div class="hpauth-field__head">
|
|
<label class="hpauth-label" for="hpauth-login-password"><?php esc_html_e( 'رمز عبور', 'hesabix2' ); ?></label>
|
|
<button type="button" class="hpauth-link" data-switch-tab="forgot"><?php esc_html_e( 'فراموشی رمز؟', 'hesabix2' ); ?></button>
|
|
</div>
|
|
<?php hesabix2_portal_auth_password_field( 'hpauth-login-password', 'password' ); ?>
|
|
</div>
|
|
<?php hesabix2_portal_auth_captcha_fields( 'login-pw' ); ?>
|
|
<label class="hpauth-check">
|
|
<input type="checkbox" name="remember" value="1" checked />
|
|
<span><?php esc_html_e( 'مرا به خاطر بسپار', 'hesabix2' ); ?></span>
|
|
</label>
|
|
<?php hesabix2_portal_auth_submit_button( __( 'ورود', 'hesabix2' ) ); ?>
|
|
</form>
|
|
|
|
<form class="hpauth-form" id="hpauth-form-login-otp" data-form="login-otp" hidden novalidate>
|
|
<?php hesabix2_portal_auth_identifier_field( 'hpauth-login-otp-identifier' ); ?>
|
|
<div class="hpauth-channel" data-otp-channel-wrap hidden>
|
|
<span class="hpauth-label"><?php esc_html_e( 'دریافت کد از طریق', 'hesabix2' ); ?></span>
|
|
<div class="hpauth-channel__opts" data-otp-channel-opts role="group"></div>
|
|
</div>
|
|
<?php hesabix2_portal_auth_captcha_fields( 'login-otp' ); ?>
|
|
<?php
|
|
hesabix2_portal_auth_submit_button(
|
|
__( 'ارسال کد', 'hesabix2' ),
|
|
'hpauth-submit--secondary',
|
|
'button',
|
|
array( 'data-action' => 'send-login-otp' )
|
|
);
|
|
?>
|
|
<div class="hpauth-otp-block" data-otp-block hidden>
|
|
<label class="hpauth-label"><?php esc_html_e( 'کد ۶ رقمی پیامک', 'hesabix2' ); ?></label>
|
|
<div class="hpauth-otp-inputs" data-otp-inputs>
|
|
<?php for ( $i = 0; $i < 6; $i++ ) : ?>
|
|
<input type="text" class="hpauth-otp-digit" maxlength="1" inputmode="numeric" pattern="[0-9]" aria-label="<?php echo esc_attr( sprintf( __( 'رقم %d', 'hesabix2' ), $i + 1 ) ); ?>" />
|
|
<?php endfor; ?>
|
|
</div>
|
|
<p class="hpauth-otp-timer" data-otp-timer hidden></p>
|
|
<?php hesabix2_portal_auth_submit_button( __( 'تأیید و ورود', 'hesabix2' ) ); ?>
|
|
</div>
|
|
</form>
|
|
|
|
<p class="hpauth-switch">
|
|
<?php esc_html_e( 'حساب ندارید؟', 'hesabix2' ); ?>
|
|
<button type="button" class="hpauth-link" data-switch-tab="register"><?php esc_html_e( 'عضویت در پورتال', 'hesabix2' ); ?></button>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- عضویت -->
|
|
<div class="hpauth-view" data-view="register" role="tabpanel" aria-labelledby="hpauth-tab-register" hidden>
|
|
<h2 class="hpauth-view__title"><?php esc_html_e( 'عضویت در پورتال', 'hesabix2' ); ?></h2>
|
|
<p class="hpauth-view__desc"><?php esc_html_e( 'با شماره موبایل خود ثبتنام کنید.', 'hesabix2' ); ?></p>
|
|
|
|
<form class="hpauth-form" id="hpauth-form-register" data-form="register" novalidate>
|
|
<input type="hidden" name="verification_token" id="hpauth-reg-verification-token" value="" />
|
|
|
|
<div class="hpauth-field" data-reg-step="mobile">
|
|
<label class="hpauth-label" for="hpauth-reg-mobile"><?php esc_html_e( 'شماره موبایل', 'hesabix2' ); ?> <span class="hpauth-required">*</span></label>
|
|
<input type="tel" class="hpauth-input" id="hpauth-reg-mobile" name="mobile" inputmode="numeric" autocomplete="tel" placeholder="09123456789" required dir="ltr" />
|
|
</div>
|
|
<?php hesabix2_portal_auth_captcha_fields( 'register-otp' ); ?>
|
|
<?php
|
|
hesabix2_portal_auth_submit_button(
|
|
__( 'ارسال کد تأیید', 'hesabix2' ),
|
|
'hpauth-submit--secondary',
|
|
'button',
|
|
array( 'data-action' => 'send-register-otp' )
|
|
);
|
|
?>
|
|
|
|
<div class="hpauth-otp-block" data-reg-otp-block hidden>
|
|
<label class="hpauth-label"><?php esc_html_e( 'کد ۶ رقمی پیامک', 'hesabix2' ); ?></label>
|
|
<div class="hpauth-otp-inputs" data-reg-otp-inputs>
|
|
<?php for ( $i = 0; $i < 6; $i++ ) : ?>
|
|
<input type="text" class="hpauth-otp-digit" maxlength="1" inputmode="numeric" pattern="[0-9]" />
|
|
<?php endfor; ?>
|
|
</div>
|
|
<?php
|
|
hesabix2_portal_auth_submit_button(
|
|
__( 'تأیید موبایل', 'hesabix2' ),
|
|
'hpauth-submit--secondary',
|
|
'button',
|
|
array( 'data-action' => 'verify-register-otp' )
|
|
);
|
|
?>
|
|
</div>
|
|
|
|
<div class="hpauth-reg-details" data-reg-details hidden>
|
|
<div class="hpauth-field-row">
|
|
<div class="hpauth-field">
|
|
<label class="hpauth-label" for="hpauth-reg-first"><?php esc_html_e( 'نام', 'hesabix2' ); ?></label>
|
|
<input type="text" class="hpauth-input" id="hpauth-reg-first" name="first_name" autocomplete="given-name" />
|
|
</div>
|
|
<div class="hpauth-field">
|
|
<label class="hpauth-label" for="hpauth-reg-last"><?php esc_html_e( 'نام خانوادگی', 'hesabix2' ); ?></label>
|
|
<input type="text" class="hpauth-input" id="hpauth-reg-last" name="last_name" autocomplete="family-name" />
|
|
</div>
|
|
</div>
|
|
<div class="hpauth-field">
|
|
<label class="hpauth-label" for="hpauth-reg-email"><?php esc_html_e( 'ایمیل (اختیاری)', 'hesabix2' ); ?></label>
|
|
<input type="email" class="hpauth-input" id="hpauth-reg-email" name="email" autocomplete="email" placeholder="example@domain.com" dir="ltr" />
|
|
</div>
|
|
<div class="hpauth-field">
|
|
<label class="hpauth-label" for="hpauth-reg-password"><?php esc_html_e( 'رمز عبور', 'hesabix2' ); ?> <span class="hpauth-required">*</span></label>
|
|
<?php
|
|
hesabix2_portal_auth_password_field(
|
|
'hpauth-reg-password',
|
|
'password',
|
|
array(
|
|
'autocomplete' => 'new-password',
|
|
'placeholder' => __( 'حداقل ۸ کاراکتر', 'hesabix2' ),
|
|
)
|
|
);
|
|
?>
|
|
<div class="hpauth-password-strength" data-password-strength aria-hidden="true">
|
|
<span class="hpauth-password-strength__bar"></span>
|
|
</div>
|
|
</div>
|
|
<?php hesabix2_portal_auth_captcha_fields( 'register' ); ?>
|
|
<p class="hpauth-hint hpauth-hint--muted"><?php esc_html_e( 'پس از تأیید پیامک، تکمیل این بخش برای ساخت حساب پورتال کافی است.', 'hesabix2' ); ?></p>
|
|
<p class="hpauth-legal">
|
|
<?php
|
|
printf(
|
|
/* translators: %s: link to terms page */
|
|
wp_kses_post( __( 'با عضویت، <a href="%s" target="_blank" rel="noopener noreferrer">شرایط استفاده</a> از پورتال مشتریان را میپذیرید.', 'hesabix2' ) ),
|
|
esc_url( $terms_url )
|
|
);
|
|
?>
|
|
</p>
|
|
<?php hesabix2_portal_auth_submit_button( __( 'ثبتنام', 'hesabix2' ), 'hpauth-submit--register' ); ?>
|
|
</div>
|
|
</form>
|
|
|
|
<p class="hpauth-switch">
|
|
<?php esc_html_e( 'قبلاً عضو شدهاید؟', 'hesabix2' ); ?>
|
|
<button type="button" class="hpauth-link" data-switch-tab="login"><?php esc_html_e( 'ورود به پورتال', 'hesabix2' ); ?></button>
|
|
</p>
|
|
</div>
|
|
|
|
<!-- بازیابی -->
|
|
<div class="hpauth-view" data-view="forgot" role="tabpanel" aria-labelledby="hpauth-tab-forgot" hidden>
|
|
<h2 class="hpauth-view__title"><?php esc_html_e( 'بازیابی رمز عبور', 'hesabix2' ); ?></h2>
|
|
<p class="hpauth-view__desc">
|
|
<?php
|
|
echo esc_html(
|
|
class_exists( 'Hpauth_Identifier' ) && Hpauth_Identifier::email_login_allowed()
|
|
? __( 'کد بازیابی به موبایل یا ایمیل شما ارسال میشود.', 'hesabix2' )
|
|
: __( 'کد بازیابی به موبایل شما ارسال میشود.', 'hesabix2' )
|
|
);
|
|
?>
|
|
</p>
|
|
|
|
<form class="hpauth-form" id="hpauth-form-forgot" data-form="forgot" novalidate>
|
|
<div data-forgot-step="1">
|
|
<?php hesabix2_portal_auth_identifier_field( 'hpauth-forgot-identifier' ); ?>
|
|
<div class="hpauth-channel" data-forgot-channel-wrap hidden>
|
|
<span class="hpauth-label"><?php esc_html_e( 'دریافت کد از طریق', 'hesabix2' ); ?></span>
|
|
<div class="hpauth-channel__opts" data-forgot-channel-opts role="group"></div>
|
|
</div>
|
|
</div>
|
|
<?php hesabix2_portal_auth_captcha_fields( 'forgot' ); ?>
|
|
<?php
|
|
hesabix2_portal_auth_submit_button(
|
|
__( 'ارسال کد بازیابی', 'hesabix2' ),
|
|
'hpauth-submit--secondary',
|
|
'button',
|
|
array(
|
|
'data-action' => 'send-forgot-otp',
|
|
'data-forgot-step' => '1',
|
|
)
|
|
);
|
|
?>
|
|
|
|
<div class="hpauth-otp-block" data-forgot-step="2" hidden>
|
|
<label class="hpauth-label"><?php esc_html_e( 'کد ۶ رقمی', 'hesabix2' ); ?></label>
|
|
<div class="hpauth-otp-inputs" data-forgot-otp-inputs>
|
|
<?php for ( $i = 0; $i < 6; $i++ ) : ?>
|
|
<input type="text" class="hpauth-otp-digit" maxlength="1" inputmode="numeric" pattern="[0-9]" />
|
|
<?php endfor; ?>
|
|
</div>
|
|
<div class="hpauth-field">
|
|
<label class="hpauth-label" for="hpauth-forgot-new"><?php esc_html_e( 'رمز عبور جدید', 'hesabix2' ); ?></label>
|
|
<?php
|
|
hesabix2_portal_auth_password_field(
|
|
'hpauth-forgot-new',
|
|
'new_password',
|
|
array( 'autocomplete' => 'new-password' )
|
|
);
|
|
?>
|
|
</div>
|
|
<?php hesabix2_portal_auth_captcha_fields( 'forgot-reset' ); ?>
|
|
<?php hesabix2_portal_auth_submit_button( __( 'تغییر رمز و ورود', 'hesabix2' ) ); ?>
|
|
</div>
|
|
</form>
|
|
|
|
<p class="hpauth-switch">
|
|
<?php esc_html_e( 'رمز را به خاطر آوردید؟', 'hesabix2' ); ?>
|
|
<button type="button" class="hpauth-link" data-switch-tab="login"><?php esc_html_e( 'ورود', 'hesabix2' ); ?></button>
|
|
</p>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
</div>
|
|
</main>
|
|
|
|
<?php get_footer(); ?>
|