Files
ogre-captcha/inc/location/woocommerce/class-login.php
T
2026-06-09 12:56:06 -05:00

51 lines
1.2 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;
defined('ABSPATH') || exit;
final class Login extends Location {
protected function __construct() {
parent::__construct(Settings::LOCATION_WC_LOGIN);
}
#[Override]
public function enabled(): bool
{
return is_user_logged_in() ? false : parent::enabled();
}
#[Override]
public function activate(): void
{
add_action('woocommerce_login_form_start', [$this, 'header']);
add_action('woocommerce_login_form', [$this, 'render']);
add_action('woocommerce_login_form_end', [$this, 'footer']);
if (isset($_POST['woocommerce-login-nonce'])) {
add_filter('woocommerce_process_login_errors', [$this, 'process_form'], 10, 3);
}
}
public function process_form(WP_Error $validation_error, string $user_login, string $user_password):WP_Error {
$this->process($validation_error);
return $validation_error;
}
}
Login::instance();