Add woocommerce form locations
Validate Build / validate-build (push) Failing after 27s

This commit is contained in:
Cooper Dalrymple
2026-06-04 17:50:11 -05:00
parent 1130a6d00f
commit edf9804cdb
6 changed files with 257 additions and 3 deletions
+48
View File
@@ -0,0 +1,48 @@
<?php
/**
* @package ogre-captcha
* @author cleverogre
* @copyright 2026 CleverOgre
* @license GLP-3.0-or-later
* @version 0.0.0
* @since 0.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', [$this, 'render']);
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();