Skip to content

Commit a88267b

Browse files
authored
Merge pull request #293 from doenietzomoeilijk/fix-recaptcha-theme
FIX, Recaptcha: Apply the theme from the config, or any theme at all
2 parents 9228782 + 32fea9a commit a88267b

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

src/Asset/ReCaptcha.php

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,16 @@ class ReCaptcha extends JavaScript
3535
/** @var string */
3636
protected $renderType;
3737

38+
/** @var string */
39+
protected $theme;
40+
3841
/**
3942
* {@inheritdoc}
4043
*/
4144
public function __toString()
4245
{
4346
$onLoad = ($this->getRenderType() == 'invisible') ? '&render=explicit&onload=invisibleRecaptchaOnLoad' : '';
44-
$theme = sprintf('<script>var RecaptchaOptions = { theme : "" };</script>', 'clean');
47+
$theme = sprintf('<script>var RecaptchaOptions = { theme : "%s" };</script>', $this->getTheme());
4548
$api = sprintf('<script src="https://www.google.com/recaptcha/api.js?hl=%s%s" async defer></script>', $this->getHtmlLang(), $onLoad);
4649

4750
return $theme . $api;
@@ -86,4 +89,23 @@ public function setRenderType($type)
8689

8790
return $this;
8891
}
92+
93+
/**
94+
* @return string
95+
*/
96+
public function getTheme()
97+
{
98+
return $this->theme;
99+
}
100+
101+
/**
102+
* @param string $theme
103+
* @return ReCaptcha
104+
*/
105+
public function setTheme($theme)
106+
{
107+
$this->theme = $theme;
108+
109+
return $this;
110+
}
89111
}

src/BoltForms.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,7 @@ private function queueReCaptcha()
276276
$reCaptcha
277277
->setHtmlLang($this->app['locale'])
278278
->setRenderType($this->config->getReCaptcha()->get('type'))
279+
->setTheme($this->config->getReCaptcha()->get('theme'))
279280
->setLocation(Target::END_OF_BODY)
280281
->setZone(Zone::FRONTEND)
281282
;

0 commit comments

Comments
 (0)