File: /mnt/data/dreamssalon-wp-market/wp-content/themes/dreamsalon/change-password.php
<?php
/**
* Template Name: Change Password Template
*
* Custom template for resetting user password.
*
* @package Dreamsalon
*/
$error_message = '';
$success_message = '';
if (isset($_GET['key']) && isset($_GET['login'])) {
$reset_key = sanitize_text_field($_GET['key']);
$login = sanitize_user($_GET['login']);
$user = check_password_reset_key($reset_key, $login);
if (is_wp_error($user)) {
$error_message = __('This password reset link is invalid or has expired.', 'dreamsalon');
$user = false;
}
// Handle form submit
$method = strtoupper((string) filter_input(INPUT_SERVER, 'REQUEST_METHOD', FILTER_SANITIZE_FULL_SPECIAL_CHARS));
if ( $user && 'POST' === $method && isset($_POST['change_password_nonce']) && wp_verify_nonce( sanitize_text_field( wp_unslash( filter_input(INPUT_POST, 'change_password_nonce', FILTER_SANITIZE_STRING) ) ), 'change_password_nonce') ) {
$password = isset($_POST['password']) ? sanitize_text_field( wp_unslash( filter_input(INPUT_POST, 'password', FILTER_SANITIZE_STRING) ) ) : '';
$confirm_password = isset($_POST['confirm_password']) ? sanitize_text_field( wp_unslash( filter_input(INPUT_POST, 'confirm_password', FILTER_SANITIZE_STRING) ) ) : '';
if (empty($password) || empty($confirm_password)) {
$error_message = __('Please fill in all fields.', 'dreamsalon');
} elseif ($password !== $confirm_password) {
$error_message = __('Passwords do not match.', 'dreamsalon');
} else {
reset_password($user, $password);
$success_message = __('Your password has been reset successfully. You can now log in.', 'dreamsalon');
}
}
} else {
$error_message = __('Invalid password reset link.', 'dreamsalon');
}
if ( in_array( 'redux-framework/redux-framework.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ), true ) ) {
$main_logo = dreamsalon_fl_framework_getoptions( 'frontend_logo' );
if ( ! empty( $main_logo ) && isset( $main_logo['url'] ) ) {
$main_logo_url = $main_logo['url'];
}
$logo_dark = dreamsalon_fl_framework_getoptions( 'logo_dark' );
if ( ! empty( $logo_dark ) && isset( $logo_dark['url'] ) ) {
$logo_dark_url = $logo_dark['url'];
}
} else {
$main_logo_url = get_template_directory_uri() . '/assets/images/logo.svg';
$logo_dark_url = get_template_directory_uri() . '/assets/images/logo-dark.svg';
}
$sign_page_id = dreamsalon_fl_framework_getoptions( 'header_login_link' );
$sign_page_url = ! empty( $sign_page_id ) ? get_permalink( $sign_page_id ) : home_url( '/' );
get_template_part( 'templates/header/header', 'none' );
?>
<div class="bg-light-2001">
<!-- Main Wrapper -->
<div class="main-wrapper authentication-wrapper">
<div class="container-fuild">
<div class="w-100 overflow-hidden position-relative flex-wrap d-block vh-100">
<div class="row justify-content-center align-items-center vh-100 overflow-auto flex-wrap ">
<div class="col-xxl-4 col-xl-4 col-lg-6 col-md-6 col-11 mx-auto">
<div class="p-4 text-center">
<img src="<?php echo esc_url( $logo_dark_url ); ?>" alt="<?php esc_attr_e( 'Logo', 'dreamsalon' ); ?>" class="img-fluid">
</div>
<div class="card authentication-card">
<div class="card-header">
<div class="text-center">
<h5 class="mb-1"><?php esc_html_e('Change Password', 'dreamsalon'); ?></h5>
<p><?php esc_html_e('Enter details to change your password.', 'dreamsalon'); ?></p>
</div>
</div>
<div class="card-body">
<?php if (!empty($error_message)) : ?>
<div class="alert alert-danger"><?php echo esc_html($error_message); ?></div>
<?php endif; ?>
<?php if (!empty($success_message)) : ?>
<div class="alert alert-success"><?php echo esc_html($success_message); ?></div>
<div class="text-center mt-3">
<a href="<?php echo esc_url( $sign_page_url ); ?>" class="btn btn-outline-primary">
<?php esc_html_e('Go to Login', 'dreamsalon'); ?>
</a>
</div>
<?php else : ?>
<form method="post">
<?php wp_nonce_field('change_password_nonce', 'change_password_nonce'); ?>
<div class="mb-3">
<label class="form-label"><?php esc_html_e('Password', 'dreamsalon'); ?></label>
<div class="input-icon">
<span class="input-icon-addon"><i class="isax isax-lock"></i></span>
<input type="password" name="password" class="form-control form-control-lg pass-input" placeholder="<?php esc_attr_e('Enter Password', 'dreamsalon'); ?>" required>
<span class="input-icon-addon toggle-password">
<i class="isax isax-eye-slash"></i>
</span>
</div>
</div>
<div class="mb-4">
<label class="form-label"><?php esc_html_e('Confirm Password', 'dreamsalon'); ?></label>
<div class="input-icon">
<span class="input-icon-addon"><i class="isax isax-lock"></i></span>
<input type="password" name="confirm_password" class="form-control form-control-lg pass-input" placeholder="<?php esc_attr_e('Confirm Password', 'dreamsalon'); ?>" required>
<span class="input-icon-addon toggle-password">
<i class="isax isax-eye-slash"></i>
</span>
</div>
</div>
<div class="mb-0">
<button type="submit" class="btn btn-xl btn-primary d-flex align-items-center justify-content-center w-100">
<?php esc_html_e('Change Password', 'dreamsalon'); ?>
<i class="isax isax-arrow-right-3 ms-2"></i>
</button>
</div>
</form>
<?php endif; ?>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="coprright-footer">
<div class="fs-14">
<?php
$cr = dreamsalon_fl_framework_getoptions( 'footer_copyright_text' );
if ( ! empty( $cr ) ) {
echo wp_kses_post( $cr );
}
?>
</div>
</div>
</div>
<!-- /Main Wrapper -->
<!-- Cursor -->
<div class="xb-cursor tx-js-cursor">
<div class="xb-cursor-wrapper">
<div class="xb-cursor--follower xb-js-follower"></div>
</div>
</div>
<!-- /Cursor -->
</div>
<?php get_template_part( 'templates/footer/footer', 'none' ); ?>