Adds first options to offer reCAPTCHA #388
This commit is contained in:
parent
963547a6ab
commit
6f38f06df0
|
@ -2,7 +2,7 @@ const { registerBlockType } = wp.blocks;
|
|||
|
||||
const { __ } = wp.i18n;
|
||||
|
||||
const { Button, TextControl, TextareaControl, ColorPicker, BaseControl, CheckboxControl, FontSizePicker, HorizontalRule, Spinner, ToggleControl, Placeholder, PanelBody, ToolbarGroup, ToolbarButton } = wp.components;
|
||||
const { Button, ExternalLink, TextControl, TextareaControl, ColorPicker, BaseControl, CheckboxControl, FontSizePicker, HorizontalRule, Spinner, ToggleControl, Placeholder, PanelBody, ToolbarGroup, ToolbarButton } = wp.components;
|
||||
|
||||
const { InspectorControls, BlockControls } = wp.editor;
|
||||
|
||||
|
@ -142,6 +142,18 @@ registerBlockType('tainacan/item-submission-form', {
|
|||
metadataSectionLabel: {
|
||||
type: String,
|
||||
default: __( 'Metadata', 'tainacan' )
|
||||
},
|
||||
useCaptcha: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
captchaSiteKey: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
captchaSecretKey: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
},
|
||||
supports: {
|
||||
|
@ -179,7 +191,10 @@ registerBlockType('tainacan/item-submission-form', {
|
|||
documentSectionLabel,
|
||||
attachmentsSectionLabel,
|
||||
thumbnailSectionLabel,
|
||||
metadataSectionLabel
|
||||
metadataSectionLabel,
|
||||
useCaptcha,
|
||||
captchaSiteKey,
|
||||
captchaSecretKey
|
||||
} = attributes;
|
||||
|
||||
const fontSizes = [
|
||||
|
@ -287,6 +302,43 @@ registerBlockType('tainacan/item-submission-form', {
|
|||
: null }
|
||||
|
||||
<div>
|
||||
<InspectorControls>
|
||||
<PanelBody
|
||||
title={ __('Security', 'tainacan') }
|
||||
initialOpen={ true } >
|
||||
<ToggleControl
|
||||
label={__('Use reCAPTCHA', 'tainacan')}
|
||||
help={ !useCaptcha ? __('Show reCAPTCHA input at the end of the form to prevent bots.', 'tainacan') : __('Do not show reCAPTCHA input at the end of the form.', 'tainacan')}
|
||||
checked={ useCaptcha }
|
||||
onChange={ ( isChecked ) => {
|
||||
useCaptcha = isChecked;
|
||||
setAttributes({ useCaptcha: isChecked });
|
||||
}
|
||||
}
|
||||
/>
|
||||
{ useCaptcha ? (
|
||||
<div>
|
||||
<TextControl
|
||||
label={ __('The reCAPTCHA site key', 'tainacan') }
|
||||
value={ captchaSiteKey }
|
||||
onChange={ ( updatedKey ) =>{
|
||||
captchaSiteKey = updatedKey;
|
||||
setAttributes({ captchaSiteKey: updatedKey });
|
||||
} }
|
||||
/>
|
||||
<TextControl
|
||||
label={ __('The reCAPTCHA site secret', 'tainacan') }
|
||||
value={ captchaSecretKey }
|
||||
onChange={ ( updatedKey ) =>{
|
||||
captchaSecretKey = updatedKey;
|
||||
setAttributes({ captchaSecretKey: updatedKey });
|
||||
} }
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
: null }
|
||||
</PanelBody>
|
||||
</InspectorControls>
|
||||
<InspectorControls>
|
||||
<PanelBody
|
||||
title={ __('Submission feedback', 'tainacan') }
|
||||
|
@ -802,7 +854,10 @@ registerBlockType('tainacan/item-submission-form', {
|
|||
secondaryColor,
|
||||
enabledMetadata,
|
||||
sentFormHeading,
|
||||
sentFormMessage
|
||||
sentFormMessage,
|
||||
useCaptcha,
|
||||
captchaSiteKey,
|
||||
captchaSecretKey
|
||||
} = attributes;
|
||||
|
||||
return <div
|
||||
|
@ -837,7 +892,10 @@ registerBlockType('tainacan/item-submission-form', {
|
|||
document-section-label={ documentSectionLabel }
|
||||
thumbnail-section-label={ thumbnailSectionLabel }
|
||||
attachments-section-label={ attachmentsSectionLabel }
|
||||
metadata-section-label={ metadataSectionLabel }>
|
||||
metadata-section-label={ metadataSectionLabel }
|
||||
use-captcha={ useCaptcha.toString() }
|
||||
captcha-site-key={ captchaSiteKey }
|
||||
captcha-secret-key={ captchaSecretKey }>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
|
|
@ -17,7 +17,10 @@
|
|||
:document-section-label="$root.documentSectionLabel"
|
||||
:thumbnail-section-label="$root.thumbnailSectionLabel"
|
||||
:attachments-section-label="$root.attachmentsSectionLabel"
|
||||
:metadata-section-label="$root.metadataSectionLabel" />
|
||||
:metadata-section-label="$root.metadataSectionLabel"
|
||||
:use-captcha="$root.useCaptcha ? $root.useCaptcha : false"
|
||||
:captcha-site-key="$root.captchaSiteKey"
|
||||
:captcha-secret-key="$root.captchaSecretKey" />
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
|
|
@ -115,7 +115,10 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
documentSectionLabel: '',
|
||||
thumbnailSectionLabel: '',
|
||||
attachmentsSectionLabel: '',
|
||||
metadataSectionLabel: ''
|
||||
metadataSectionLabel: '',
|
||||
useCaptcha: false,
|
||||
captchaSiteKey: '',
|
||||
captchaSecretKey: ''
|
||||
},
|
||||
beforeMount () {
|
||||
// Collection source settings
|
||||
|
@ -161,6 +164,14 @@ document.addEventListener("DOMContentLoaded", () => {
|
|||
// List of metadata
|
||||
if (this.$el.attributes['enabled-metadata'] != undefined && this.$el.attributes['enabled-metadata'].value)
|
||||
this.enabledMetadata = this.$el.attributes['enabled-metadata'].value.split(',');
|
||||
|
||||
// Captcha
|
||||
if (this.$el.attributes['use-captcha'] != undefined)
|
||||
this.useCaptcha = this.isParameterTrue('use-captcha');
|
||||
if (this.$el.attributes['captcha-site-key'] != undefined)
|
||||
this.captchaSiteKey = this.$el.attributes['captcha-site-key'].value;
|
||||
if (this.$el.attributes['captcha-secret-key'] != undefined)
|
||||
this.captchaSecretKey = this.$el.attributes['captcha-secret-key'].value;
|
||||
},
|
||||
methods: {
|
||||
isParameterTrue(parameter) {
|
||||
|
|
|
@ -413,7 +413,10 @@ export default {
|
|||
documentSectionLabel: String,
|
||||
thumbnailSectionLabel: String,
|
||||
attachmentsSectionLabel: String,
|
||||
metadataSectionLabel: String
|
||||
metadataSectionLabel: String,
|
||||
useCaptcha: Boolean,
|
||||
captchaSiteKey: String,
|
||||
captchaSecretKey: String
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
|
|
Loading…
Reference in New Issue