Move reCAPTCHA hook registration for consistency
[MAILPOET-6326]
This commit is contained in:
committed by
Aschepikov
parent
08bdf69b52
commit
6f396bd22c
@@ -73,9 +73,6 @@ class Hooks {
|
|||||||
/** @var HooksWooCommerce */
|
/** @var HooksWooCommerce */
|
||||||
private $hooksWooCommerce;
|
private $hooksWooCommerce;
|
||||||
|
|
||||||
/** @var ReCaptchaHooks */
|
|
||||||
private $reCaptcha;
|
|
||||||
|
|
||||||
/** @var SubscriberChangesNotifier */
|
/** @var SubscriberChangesNotifier */
|
||||||
private $subscriberChangesNotifier;
|
private $subscriberChangesNotifier;
|
||||||
|
|
||||||
@@ -88,6 +85,9 @@ class Hooks {
|
|||||||
/** @var CaptchaHooks */
|
/** @var CaptchaHooks */
|
||||||
private $captchaHooks;
|
private $captchaHooks;
|
||||||
|
|
||||||
|
/** @var ReCaptchaHooks */
|
||||||
|
private $reCaptchaHooks;
|
||||||
|
|
||||||
/** @var WooSystemInfoController */
|
/** @var WooSystemInfoController */
|
||||||
private $wooSystemInfoController;
|
private $wooSystemInfoController;
|
||||||
|
|
||||||
@@ -109,7 +109,7 @@ class Hooks {
|
|||||||
DisplayFormInWPContent $displayFormInWPContent,
|
DisplayFormInWPContent $displayFormInWPContent,
|
||||||
HooksWooCommerce $hooksWooCommerce,
|
HooksWooCommerce $hooksWooCommerce,
|
||||||
CaptchaHooks $captchaHooks,
|
CaptchaHooks $captchaHooks,
|
||||||
ReCaptchaHooks $reCaptcha,
|
ReCaptchaHooks $reCaptchaHooks,
|
||||||
SubscriberHandler $subscriberHandler,
|
SubscriberHandler $subscriberHandler,
|
||||||
SubscriberChangesNotifier $subscriberChangesNotifier,
|
SubscriberChangesNotifier $subscriberChangesNotifier,
|
||||||
WP $wpSegment,
|
WP $wpSegment,
|
||||||
@@ -132,7 +132,7 @@ class Hooks {
|
|||||||
$this->subscriberHandler = $subscriberHandler;
|
$this->subscriberHandler = $subscriberHandler;
|
||||||
$this->hooksWooCommerce = $hooksWooCommerce;
|
$this->hooksWooCommerce = $hooksWooCommerce;
|
||||||
$this->captchaHooks = $captchaHooks;
|
$this->captchaHooks = $captchaHooks;
|
||||||
$this->reCaptcha = $reCaptcha;
|
$this->reCaptchaHooks = $reCaptchaHooks;
|
||||||
$this->subscriberChangesNotifier = $subscriberChangesNotifier;
|
$this->subscriberChangesNotifier = $subscriberChangesNotifier;
|
||||||
$this->dotcomLicenseProvisioner = $dotcomLicenseProvisioner;
|
$this->dotcomLicenseProvisioner = $dotcomLicenseProvisioner;
|
||||||
$this->automateWooHooks = $automateWooHooks;
|
$this->automateWooHooks = $automateWooHooks;
|
||||||
@@ -251,44 +251,6 @@ class Hooks {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
// reCAPTCHA on WP registration form
|
|
||||||
if ($this->reCaptcha->isEnabled()) {
|
|
||||||
$this->wp->addAction(
|
|
||||||
'login_enqueue_scripts',
|
|
||||||
[$this->reCaptcha, 'enqueueScripts']
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->wp->addAction(
|
|
||||||
'register_form',
|
|
||||||
[$this->reCaptcha, 'render']
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->wp->addFilter(
|
|
||||||
'registration_errors',
|
|
||||||
[$this->reCaptcha, 'validate'],
|
|
||||||
10,
|
|
||||||
3
|
|
||||||
);
|
|
||||||
|
|
||||||
// reCAPTCHA on WC registration form
|
|
||||||
if ($this->wooHelper->isWooCommerceActive()) {
|
|
||||||
$this->wp->addAction(
|
|
||||||
'woocommerce_before_customer_login_form',
|
|
||||||
[$this->reCaptcha, 'enqueueScripts']
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->wp->addAction(
|
|
||||||
'woocommerce_register_form',
|
|
||||||
[$this->reCaptcha, 'render']
|
|
||||||
);
|
|
||||||
|
|
||||||
$this->wp->addAction(
|
|
||||||
'woocommerce_process_registration_errors',
|
|
||||||
[$this->reCaptcha, 'validate']
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Manage subscription
|
// Manage subscription
|
||||||
$this->wp->addAction(
|
$this->wp->addAction(
|
||||||
'admin_post_mailpoet_subscription_update',
|
'admin_post_mailpoet_subscription_update',
|
||||||
@@ -636,6 +598,7 @@ class Hooks {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CAPTCHA on WP & WC registration forms
|
||||||
public function setupCaptchaOnRegisterForm(): void {
|
public function setupCaptchaOnRegisterForm(): void {
|
||||||
if ($this->captchaHooks->isEnabled()) {
|
if ($this->captchaHooks->isEnabled()) {
|
||||||
$this->wp->addAction(
|
$this->wp->addAction(
|
||||||
@@ -663,6 +626,40 @@ class Hooks {
|
|||||||
3
|
3
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
} else if ($this->reCaptchaHooks->isEnabled()) {
|
||||||
|
$this->wp->addAction(
|
||||||
|
'login_enqueue_scripts',
|
||||||
|
[$this->reCaptchaHooks, 'enqueueScripts']
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->wp->addAction(
|
||||||
|
'register_form',
|
||||||
|
[$this->reCaptchaHooks, 'render']
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->wp->addFilter(
|
||||||
|
'registration_errors',
|
||||||
|
[$this->reCaptchaHooks, 'validate'],
|
||||||
|
10,
|
||||||
|
3
|
||||||
|
);
|
||||||
|
|
||||||
|
if ($this->wooHelper->isWooCommerceActive()) {
|
||||||
|
$this->wp->addAction(
|
||||||
|
'woocommerce_before_customer_login_form',
|
||||||
|
[$this->reCaptchaHooks, 'enqueueScripts']
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->wp->addAction(
|
||||||
|
'woocommerce_register_form',
|
||||||
|
[$this->reCaptchaHooks, 'render']
|
||||||
|
);
|
||||||
|
|
||||||
|
$this->wp->addAction(
|
||||||
|
'woocommerce_process_registration_errors',
|
||||||
|
[$this->reCaptchaHooks, 'validate']
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user