Add CAPTCHA on register forms setting
[MAILPOET-6326]
This commit is contained in:
committed by
Aschepikov
parent
74d71a54b2
commit
78ef34ba8c
@@ -12,6 +12,7 @@ import { Reinstall } from './reinstall';
|
||||
import { RecalculateSubscriberScore } from './recalculate-subscriber-score';
|
||||
import { Logging } from './logging';
|
||||
import { BounceAddress } from './bounce-address';
|
||||
import { CaptchaOnSignup } from './captcha-on-signup';
|
||||
|
||||
export function Advanced() {
|
||||
return (
|
||||
@@ -27,6 +28,7 @@ export function Advanced() {
|
||||
<ShareData />
|
||||
<Libs3rdParty />
|
||||
<Captcha />
|
||||
<CaptchaOnSignup />
|
||||
<Reinstall />
|
||||
<Logging />
|
||||
<SaveButton />
|
||||
|
@@ -0,0 +1,44 @@
|
||||
import { t } from 'common/functions';
|
||||
import { Radio } from 'common/form/radio/radio';
|
||||
import { useSelector, useSetting } from 'settings/store/hooks';
|
||||
import { Inputs, Label } from 'settings/components';
|
||||
|
||||
export function CaptchaOnSignup() {
|
||||
const [enabled, setEnabled] = useSetting(
|
||||
'captcha',
|
||||
'on_register_forms',
|
||||
'enabled',
|
||||
);
|
||||
const hasWooCommerce = useSelector('hasWooCommerce')();
|
||||
|
||||
return (
|
||||
<>
|
||||
<Label
|
||||
title={t('captchaOnRegisterTitle')}
|
||||
description={t(
|
||||
hasWooCommerce
|
||||
? 'captchaOnRegisterWooActiveDescription'
|
||||
: 'captchaOnRegisterWooInactiveDescription',
|
||||
)}
|
||||
htmlFor=""
|
||||
/>
|
||||
<Inputs>
|
||||
<Radio
|
||||
id="captcha-on-register-enabled"
|
||||
value="1"
|
||||
checked={enabled === '1'}
|
||||
onCheck={setEnabled}
|
||||
/>
|
||||
<label htmlFor="captcha-on-register-enabled">{t('yes')}</label>
|
||||
<span className="mailpoet-gap" />
|
||||
<Radio
|
||||
id="captcha-on-register-disabled"
|
||||
value=""
|
||||
checked={enabled === ''}
|
||||
onCheck={setEnabled}
|
||||
/>
|
||||
<label htmlFor="captcha-on-register-disabled">{t('no')}</label>
|
||||
</Inputs>
|
||||
</>
|
||||
);
|
||||
}
|
@@ -50,6 +50,7 @@ function asObject<T extends Schema>(schema: T) {
|
||||
function asIs<T>(value: T): T {
|
||||
return value;
|
||||
}
|
||||
|
||||
export function normalizeSettings(data: Record<string, unknown>): Settings {
|
||||
const text = asString('');
|
||||
const disabledCheckbox = asBoolean('1', '0', '0');
|
||||
@@ -135,6 +136,9 @@ export function normalizeSettings(data: Record<string, unknown>): Settings {
|
||||
recaptcha_secret_token: text,
|
||||
recaptcha_invisible_site_token: text,
|
||||
recaptcha_invisible_secret_token: text,
|
||||
on_register_forms: asObject({
|
||||
enabled: disabledRadio,
|
||||
}),
|
||||
}),
|
||||
logging: asEnum(['everything', 'errors', 'nothing'], 'errors'),
|
||||
mta_group: asEnum(['mailpoet', 'website', 'smtp'], 'website'),
|
||||
|
@@ -65,6 +65,9 @@ export type Settings = {
|
||||
recaptcha_secret_token: string;
|
||||
recaptcha_invisible_site_token: string;
|
||||
recaptcha_invisible_secret_token: string;
|
||||
on_register_forms: {
|
||||
enabled: '' | '1';
|
||||
};
|
||||
};
|
||||
logging: 'everything' | 'errors' | 'nothing';
|
||||
mta_group: 'mailpoet' | 'website' | 'smtp';
|
||||
|
@@ -109,7 +109,7 @@
|
||||
'libs3rdPartyDescription': __('E.g. Google Fonts in the Form and Email editor and DocsBot to get help. When disabled, you can still reach support at [link]www.mailpoet.com/support/[/link].'),
|
||||
'shareDataTitle': __('Share anonymous data'),
|
||||
'shareDataDescription': __('Share anonymous data and help us improve the plugin. We appreciate your help!'),
|
||||
'captchaTitle': __('Protect your forms against spam signups'),
|
||||
'captchaTitle': __('Protect your MailPoet forms against spam signups'),
|
||||
'captchaDescription': __('Built-in CAPTCHA protects your subscription forms against bots. Alternatively, use reCAPTCHA by Google.'),
|
||||
'reCaptchaDescription': __('Please use the same reCAPTCHA type as in Google reCAPTCHA Settings.'),
|
||||
'signupForCaptchaKey': __('Sign up for an API key pair here.'),
|
||||
@@ -120,6 +120,9 @@
|
||||
'yourReCaptchaKey': __('Your reCAPTCHA Site Key'),
|
||||
'yourReCaptchaSecret': __('Your reCAPTCHA Secret Key'),
|
||||
'fillReCaptchaKeys': __('Please fill the reCAPTCHA keys.'),
|
||||
'captchaOnRegisterTitle': __('Protect registration forms'),
|
||||
'captchaOnRegisterWooInactiveDescription': __('Protect WordPress registration pages with a CAPTCHA.'),
|
||||
'captchaOnRegisterWooActiveDescription': __('Protect WordPress and WooCommerce registration pages with a CAPTCHA.'),
|
||||
'disable': __('Disable'),
|
||||
'recalculateSubscribersScoreTitle': __('Recalculate Subscriber Scores'),
|
||||
'recalculateSubscribersScoreDescription': __('MailPoet will recalculate subscriber engagement scores for all subscribers. This may take some time to complete.'),
|
||||
|
Reference in New Issue
Block a user