hesabixWpTheme/page-lostpassword.php
2026-05-22 13:52:15 +03:30

117 lines
5.7 KiB
PHP

<?php
/**
* قالب صفحه بازیابی کلمه عبور — طرح Hesabix2
*
* @package Hesabix2
*/
if (!defined('ABSPATH')) {
exit;
}
if (is_user_logged_in()) {
wp_safe_redirect(home_url('/'));
exit;
}
$error = '';
$success = '';
if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['hesabix2_lostpassword_nonce'])) {
if (!wp_verify_nonce(sanitize_text_field(wp_unslash($_POST['hesabix2_lostpassword_nonce'])), 'hesabix2_lostpassword')) {
$error = __('خطا در اعتبارسنجی. لطفاً دوباره تلاش کنید.', 'hesabix2');
} else {
$user_login = isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : '';
$user_login = is_email($user_login) ? sanitize_email($user_login) : sanitize_text_field($user_login);
if (empty($user_login)) {
$error = __('نام کاربری یا ایمیل را وارد کنید.', 'hesabix2');
} else {
$result = retrieve_password($user_login);
if (is_wp_error($result)) {
$error = $result->get_error_message();
} else {
$success = __('اگر حسابی با این ایمیل یا نام کاربری وجود داشته باشد، لینک بازیابی رمز به ایمیل شما ارسال شده است. صندوق ورودی و پوشه اسپم را بررسی کنید.', 'hesabix2');
}
}
}
}
get_header();
?>
<main class="auth-wrap">
<div class="auth-bg">
<div class="auth-bg__gradient"></div>
<div class="auth-bg__pattern" aria-hidden="true"></div>
</div>
<div class="auth-outer">
<div class="auth-card">
<div class="auth-card__accent auth-card__accent--lost"></div>
<div class="auth-card__inner">
<a href="<?php echo esc_url(home_url('/')); ?>" class="auth-brand">
<?php
$custom_logo_id = get_theme_mod('custom_logo');
$logo = null;
if ($custom_logo_id) {
$logo = wp_get_attachment_image_src($custom_logo_id, 'medium');
}
if ($logo) : ?>
<img src="<?php echo esc_url($logo[0]); ?>" alt="<?php echo esc_attr(get_bloginfo('name')); ?>" class="auth-brand__img" width="52" height="52">
<?php else : ?>
<span class="auth-brand__letter"><?php echo esc_html(mb_substr(get_bloginfo('name'), 0, 1)); ?></span>
<?php endif; ?>
<span class="auth-brand__name"><?php echo esc_html(get_bloginfo('name')); ?></span>
</a>
<h1 class="auth-title">بازیابی کلمه عبور</h1>
<p class="auth-desc">نام کاربری یا ایمیل خود را وارد کنید تا لینک بازیابی برای شما ارسال شود.</p>
<?php if ($error) : ?>
<div class="auth-message auth-message--error" role="alert">
<span class="auth-message__icon" aria-hidden="true">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"/></svg>
</span>
<?php echo esc_html($error); ?>
</div>
<?php endif; ?>
<?php if ($success) : ?>
<div class="auth-message auth-message--success" role="status">
<span class="auth-message__icon" aria-hidden="true">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M22 11.08V12a10 10 0 11-5.93-9.14"/><path d="M22 4L12 14.01l-3-3"/></svg>
</span>
<?php echo esc_html($success); ?>
</div>
<p class="auth-back-link">
<a href="<?php echo esc_url(wp_login_url(home_url('/'))); ?>" class="auth-link auth-link--btn">بازگشت به ورود</a>
</p>
<?php else : ?>
<form method="post" action="<?php echo esc_url(get_permalink()); ?>" class="auth-form" novalidate>
<?php wp_nonce_field('hesabix2_lostpassword', 'hesabix2_lostpassword_nonce'); ?>
<div class="auth-field">
<label for="user_login" class="auth-label">نام کاربری یا ایمیل</label>
<div class="auth-input-wrap">
<span class="auth-input__icon" aria-hidden="true">
<svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2"><path d="M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z"/><path d="M22 6l-10 7L2 6"/></svg>
</span>
<input type="text" name="user_login" id="user_login" class="auth-input" value="<?php echo esc_attr(isset($_POST['user_login']) ? wp_unslash($_POST['user_login']) : ''); ?>" autocomplete="username" required placeholder="نام کاربری یا ایمیل">
</div>
</div>
<button type="submit" class="auth-submit auth-submit--lost">ارسال لینک بازیابی</button>
</form>
<?php endif; ?>
<div class="auth-links">
<a href="<?php echo esc_url(wp_login_url(get_permalink())); ?>" class="auth-link">بازگشت به ورود</a>
</div>
</div>
</div>
</div>
</main>
<?php get_footer(); ?>