Add floating mode support

This commit is contained in:
Cooper Dalrymple
2026-06-09 12:53:19 -05:00
parent 401676e7f3
commit 6a6e8f3960
15 changed files with 341 additions and 22 deletions
@@ -13,6 +13,7 @@ namespace Ogre\Captcha\Location\WooCommerce;
use Override;
use Ogre\Captcha\Location;
use Ogre\Captcha\Settings;
use Ogre\Captcha\Widget;
use WP_Error;
defined('ABSPATH') || exit;
@@ -33,9 +34,17 @@ final class Checkout extends Location {
public function activate(): void
{
add_action('woocommerce_after_checkout_billing_form', [$this, 'render']);
add_filter('woocommerce_order_button_html', [$this, 'submit_button'], 10, 1);
add_action('woocommerce_after_checkout_validation', [$this, 'process_form'], 10, 2);
}
public function submit_button(string $html):string {
if (Settings::is_widget_floating()) {
$html = Widget::set_button_floating($html);
}
return $html;
}
public function process_form(array $data, WP_Error $errors) {
$this->process($errors);
}
+2
View File
@@ -32,7 +32,9 @@ final class Login extends Location {
#[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);
}
@@ -33,7 +33,9 @@ final class LostPassword extends Location {
#[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']);
}
@@ -32,7 +32,9 @@ final class Register extends Location {
#[Override]
public function activate(): void
{
add_action('woocommerce_register_form_start', [$this, 'header']);
add_action('woocommerce_register_form', [$this, 'render']);
add_action('woocommerce_register_form_end', [$this, 'footer']);
if (isset($_POST['woocommerce-register-nonce'])) {
add_filter('woocommerce_process_registration_errors', [$this, 'process_form'], 10, 4);
}