<?php
/**
 * Expired Password Reset Form Partial
 *
 * Displayed on the login page when a user logs in with an expired password.
 *
 * @package GuardDog
 * @since 1.9.1
 */

if (!defined('ABSPATH')) exit; // Exit if accessed directly

// phpcs:disable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
// These are local variables in a template file, not global variables
// The Plugin Checker incorrectly flags local template variables as globals
// These variables are scoped to this template file and do not pollute the global namespace

?>

<div id="guard-dog-password-reset-container">
    <p class="message">
        <?php esc_html_e('Your password has expired. Please create a new password to continue.', 'guard-dog'); ?>
    </p>

    <form name="resetpasswordform" id="resetpasswordform" action="<?php echo esc_url(site_url('wp-login.php', 'login_post')); ?>" method="post" autocomplete="off">
        <p>
            <label for="pass1"><?php esc_html_e('New Password', 'guard-dog'); ?></label>
            <input type="password" name="pass1" id="pass1" class="input password-input" size="20" autocomplete="new-password" spellcheck="false" />
        </p>

        <p>
            <label for="pass2"><?php esc_html_e('Confirm New Password', 'guard-dog'); ?></label>
            <input type="password" name="pass2" id="pass2" class="input password-input" size="20" autocomplete="new-password" spellcheck="false" />
        </p>

        <div id="guard-dog-password-requirements" class="guard-dog-password-requirements">
            <p class="description"><?php esc_html_e('Password Requirements:', 'guard-dog'); ?></p>
            <ul class="guard-dog-password-checklist">
                <?php
                $min_length = get_option('guard_dog_password_min_length', 12);
                ?>
                <li class="requirement" data-requirement="length">
                    <span class="dashicons dashicons-no"></span>
                    <?php
                    // Translators: %d is the minimum password length.
                    printf(esc_html__('At least %d characters', 'guard-dog'), (int) $min_length);
                    ?>
                </li>
                <?php if (get_option('guard_dog_password_require_uppercase', true)) : ?>
                <li class="requirement" data-requirement="uppercase">
                    <span class="dashicons dashicons-no"></span>
                    <?php esc_html_e('One uppercase letter', 'guard-dog'); ?>
                </li>
                <?php endif; ?>
                <?php if (get_option('guard_dog_password_require_lowercase', true)) : ?>
                <li class="requirement" data-requirement="lowercase">
                    <span class="dashicons dashicons-no"></span>
                    <?php esc_html_e('One lowercase letter', 'guard-dog'); ?>
                </li>
                <?php endif; ?>
                <?php if (get_option('guard_dog_password_require_numbers', true)) : ?>
                <li class="requirement" data-requirement="number">
                    <span class="dashicons dashicons-no"></span>
                    <?php esc_html_e('One number', 'guard-dog'); ?>
                </li>
                <?php endif; ?>
                <?php if (get_option('guard_dog_password_require_special', true)) : ?>
                <li class="requirement" data-requirement="special">
                    <span class="dashicons dashicons-no"></span>
                    <?php esc_html_e('One special character', 'guard-dog'); ?>
                </li>
                <?php endif; ?>
                <li class="requirement" data-requirement="match">
                    <span class="dashicons dashicons-no"></span>
                    <?php esc_html_e('Passwords match', 'guard-dog'); ?>
                </li>
            </ul>
        </div>

        <input type="hidden" name="log" value="<?php echo esc_attr($username); ?>" />
        <input type="hidden" name="redirect_to" value="<?php echo esc_attr($redirect_to); ?>" />
        <input type="hidden" name="rememberme" value="<?php echo esc_attr($rememberme ? 'forever' : ''); ?>" />
        <input type="hidden" name="guard_dog_expired_password_reset" value="1" />
        <?php wp_nonce_field('guard_dog_password_reset_' . $user_id, 'guard_dog_password_reset_nonce'); ?>

        <p class="submit">
            <input type="submit" name="wp-submit" id="wp-submit" class="button button-primary button-large" value="<?php esc_attr_e('Update Password', 'guard-dog'); ?>" />
        </p>
    </form>
</div>

<p id="backtologin">
    <a href="<?php echo esc_url(wp_login_url()); ?>">
        <?php esc_html_e('&larr; Back to Log In', 'guard-dog'); ?>
    </a>
</p>

<?php
// phpcs:enable WordPress.NamingConventions.PrefixAllGlobals.NonPrefixedVariableFound
?>
