52 lines
1.3 KiB
PHP
52 lines
1.3 KiB
PHP
<?php
|
|
/**
|
|
* @package ogre-captcha
|
|
* @author cleverogre
|
|
* @copyright 2026 CleverOgre
|
|
* @license GLP-3.0-or-later
|
|
* @version 1.2.0
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
namespace Ogre\Captcha\Location\WooCommerce;
|
|
|
|
use Override;
|
|
use Ogre\Captcha\Location;
|
|
use Ogre\Captcha\Settings;
|
|
use WP_Error;
|
|
use WP_User;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
final class LostPassword extends Location {
|
|
|
|
protected function __construct() {
|
|
parent::__construct(Settings::LOCATION_WC_LOST_PASSWORD);
|
|
}
|
|
|
|
#[Override]
|
|
public function enabled(): bool
|
|
{
|
|
return is_user_logged_in() ? false : parent::enabled();
|
|
}
|
|
|
|
#[Override]
|
|
public function activate(): void
|
|
{
|
|
add_action('woocommerce_before_lost_password_form', [$this, 'header']);
|
|
add_action('woocommerce_lostpassword_form', [$this, 'render']);
|
|
add_action('woocommerce_after_lost_password_form', [$this, 'footer']);
|
|
if (isset($_POST['woocommerce-lost-password-nonce'])) {
|
|
add_action('lostpassword_post', [$this, 'process_form']);
|
|
}
|
|
}
|
|
|
|
public function process_form(WP_Error $errors, WP_User|bool $user_data) {
|
|
$this->process($errors);
|
|
// NOTE: Potentially use `allow_password_reset` to display error message?
|
|
}
|
|
|
|
}
|
|
|
|
LostPassword::instance();
|