PluginProbe
Block Animations, Motion & Scroll Effects – Ghost Kit / 3.3.3
Block Animations, Motion & Scroll Effects – Ghost Kit v3.3.3
3.7.2 3.7.1 3.7.0 3.6.1 trunk 1.6.3 2.25.0 3.3.0 3.3.1 3.3.2 3.3.3 3.4.0 3.4.1 3.4.2 3.4.3 3.4.4 3.4.5 3.4.6 3.5.0 3.5.1 3.6.0
ghostkit / gutenberg / blocks / form / recaptcha / index.js

index.js in Block Animations, Motion & Scroll Effects – Ghost Kit 3.3.3, at gutenberg/blocks/form/recaptcha/index.js

71 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { debounce } from 'throttle-debounce';
2
3 import apiFetch from '@wordpress/api-fetch';
4 import { ExternalLink, PanelBody, TextControl } from '@wordpress/components';
5 import { useState } from '@wordpress/element';
6 import { __ } from '@wordpress/i18n';
7
8 const { GHOSTKIT } = window;
9
10 const initialOpen =
11 !GHOSTKIT.googleReCaptchaAPISiteKey ||
12 !GHOSTKIT.googleReCaptchaAPISecretKey;
13
14 const saveAPIKeys = debounce(1500, (newSiteKey, newSecretKey) => {
15 apiFetch({
16 path: '/ghostkit/v1/update_google_recaptcha_keys',
17 method: 'POST',
18 data: {
19 site_key: newSiteKey,
20 secret_key: newSecretKey,
21 },
22 });
23 });
24
25 /**
26 * Block Settings Class.
27 */
28 export default function BlockSettings() {
29 const [apiSiteKey, setApiSiteKey] = useState(
30 GHOSTKIT.googleReCaptchaAPISiteKey
31 );
32 const [apiSecretKey, setApiSecretKey] = useState(
33 GHOSTKIT.googleReCaptchaAPISecretKey
34 );
35
36 return (
37 <PanelBody
38 title={__('Google reCAPTCHA', 'ghostkit')}
39 initialOpen={initialOpen}
40 >
41 <TextControl
42 label={__('Site Key', 'ghostkit')}
43 value={apiSiteKey}
44 onChange={(value) => {
45 setApiSiteKey(value);
46 saveAPIKeys(value, apiSecretKey);
47 }}
48 />
49 <TextControl
50 label={__('Secret Key', 'ghostkit')}
51 value={apiSecretKey}
52 onChange={(value) => {
53 setApiSecretKey(value);
54 saveAPIKeys(apiSiteKey, value);
55 }}
56 />
57 <p>
58 {__(
59 'Protect your form from spam using Google reCAPTCHA v3.',
60 'ghostkit'
61 )}
62 </p>
63 <p>
64 <ExternalLink href="https://www.google.com/recaptcha/about/">
65 {__('Generate Keys', 'ghostkit')}
66 </ExternalLink>
67 </p>
68 </PanelBody>
69 );
70 }
71