diff --git a/composer.json b/composer.json index 1d6aeaf..cc54eee 100644 --- a/composer.json +++ b/composer.json @@ -19,6 +19,6 @@ }, "license": "GPL-2.0+", "require": { - "drupal/captcha": "^1.0.0-alpha1" + "drupal/captcha": "~8.0" } } diff --git a/recaptcha.info.yml b/recaptcha.info.yml index e4d224f..79af4e2 100644 --- a/recaptcha.info.yml +++ b/recaptcha.info.yml @@ -2,7 +2,13 @@ name: 'reCAPTCHA' type: module description: 'Protect your website from spam and abuse while letting real people pass through with ease.' package: Spam control -core: 8.x +# core: 8.x configure: recaptcha.admin_settings_form dependencies: - captcha + +# Information added by Drupal.org packaging script on 2016-07-30 +version: '8.x-2.2' +core: '8.x' +project: 'recaptcha' +datestamp: 1469859566 diff --git a/recaptcha.module b/recaptcha.module index 380854c..78dc16e 100644 --- a/recaptcha.module +++ b/recaptcha.module @@ -78,6 +78,8 @@ function recaptcha_captcha($op, $captcha_type = '') { $noscript = $renderer->render($recaptcha_widget_noscript); } + $invisible = $config->get('widget.size') == 'invisible'; + $attributes = [ 'class' => 'g-recaptcha', 'data-sitekey' => $recaptcha_site_key, @@ -86,6 +88,9 @@ function recaptcha_captcha($op, $captcha_type = '') { 'data-size' => $config->get('widget.size'), 'data-tabindex' => $config->get('widget.tabindex'), ]; + + if($invisible) $attributes['data-callback'] = 'onSubmit'; + // Filter out empty tabindex/size. $attributes = array_filter($attributes); @@ -108,6 +113,7 @@ function recaptcha_captcha($op, $captcha_type = '') { ], ], ]; + $captcha['form']['#attached']['library'][] = 'recaptcha/invisible-recaptcha'; } else { // Fallback to Math captcha as reCAPTCHA is not configured. diff --git a/src/Form/ReCaptchaAdminSettingsForm.php b/src/Form/ReCaptchaAdminSettingsForm.php index fd2ca6d..e06f253 100644 --- a/src/Form/ReCaptchaAdminSettingsForm.php +++ b/src/Form/ReCaptchaAdminSettingsForm.php @@ -65,8 +65,8 @@ class ReCaptchaAdminSettingsForm extends ConfigFormBase { '#default_value' => $config->get('widget.theme'), '#description' => $this->t('Defines which theme to use for reCAPTCHA.'), '#options' => [ - 'light' => $this->t('Light (default)'), - 'dark' => $this->t('Dark'), + 'light' => t('Light (default)'), + 'dark' => t('Dark'), ], '#title' => $this->t('Theme'), '#type' => 'select', @@ -87,6 +87,7 @@ class ReCaptchaAdminSettingsForm extends ConfigFormBase { '#options' => [ '' => $this->t('Normal (default)'), 'compact' => $this->t('Compact'), + 'invisible' => $this->t('Invisible'), ], '#title' => $this->t('Size'), '#type' => 'select', diff --git a/src/ReCaptcha/RequestMethod/Drupal8Post.php b/src/ReCaptcha/RequestMethod/Drupal8Post.php index 96a73b7..1c375ec 100644 --- a/src/ReCaptcha/RequestMethod/Drupal8Post.php +++ b/src/ReCaptcha/RequestMethod/Drupal8Post.php @@ -22,10 +22,10 @@ class Drupal8Post implements RequestMethod { * Submit the POST request with the specified parameters. * * @param RequestParameters $params - * Request parameters. + * Request parameters * * @return string - * Body of the reCAPTCHA response. + * Body of the reCAPTCHA response */ public function submit(RequestParameters $params) {