Add code to display the invisible ReCaptcha in the frontend
This commit adds the required code to display the invisible ReCaptcha in the frontend when a form is rendered and this type of captcha is selected in the admin. [MAILPOET-4145]
This commit is contained in:
@@ -216,15 +216,21 @@ class SubscriberSubscribeController {
|
||||
}
|
||||
}
|
||||
|
||||
if ($captchaSettings['type'] === Captcha::TYPE_RECAPTCHA && empty($data['recaptcha'])) {
|
||||
if (Captcha::isReCaptcha($captchaSettings['type']) && empty($data['recaptcha'])) {
|
||||
return ['error' => __('Please check the CAPTCHA.', 'mailpoet')];
|
||||
}
|
||||
|
||||
if ($captchaSettings['type'] === Captcha::TYPE_RECAPTCHA) {
|
||||
if (Captcha::isReCaptcha($captchaSettings['type'])) {
|
||||
if ($captchaSettings['type'] === Captcha::TYPE_RECAPTCHA_INVISIBLE) {
|
||||
$secretToken = $captchaSettings['recaptcha_invisible_secret_token'];
|
||||
} else {
|
||||
$secretToken = $captchaSettings['recaptcha_secret_token'];
|
||||
}
|
||||
|
||||
$response = empty($data['recaptcha']) ? $data['recaptcha-no-js'] : $data['recaptcha'];
|
||||
$response = $this->wp->wpRemotePost('https://www.google.com/recaptcha/api/siteverify', [
|
||||
'body' => [
|
||||
'secret' => $captchaSettings['recaptcha_secret_token'],
|
||||
'secret' => $secretToken,
|
||||
'response' => $response,
|
||||
],
|
||||
]);
|
||||
|
Reference in New Issue
Block a user