diff --git a/classes/MagicForm.php b/classes/MagicForm.php index 4855b0b..622ddde 100644 --- a/classes/MagicForm.php +++ b/classes/MagicForm.php @@ -25,8 +25,9 @@ abstract class MagicForm extends ComponentBase public function onRun() { - $this->page['recaptcha_enabled'] = $this->isReCaptchaEnabled(); - $this->page['recaptcha_misconfigured'] = $this->isReCaptchaMisconfigured(); + $this->recaptcha_enabled = $this->isReCaptchaEnabled(); + $this->page['recaptcha_enabled'] = $this->page['recaptcha_enabled'] || $this->isReCaptchaEnabled(); + $this->page['recaptcha_misconfigured'] = $this->page['recaptcha_misconfigured'] || $this->isReCaptchaMisconfigured(); if ($this->isReCaptchaEnabled()) { $this->loadReCaptcha(); diff --git a/classes/ReCaptcha.php b/classes/ReCaptcha.php index 5181f98..fe22610 100644 --- a/classes/ReCaptcha.php +++ b/classes/ReCaptcha.php @@ -26,11 +26,11 @@ public function init() { } private function isReCaptchaEnabled() { - return ($this->property('recaptcha_enabled') && Settings::get('recaptcha_site_key') != '' && Settings::get('recaptcha_secret_key') != ''); + return $this->property('recaptcha_enabled') && !$this->isReCaptchaMisconfigured(); } private function isReCaptchaMisconfigured() { - return ($this->property('recaptcha_enabled') && (Settings::get('recaptcha_site_key') == '' || Settings::get('recaptcha_secret_key') == '')); + return Settings::get('recaptcha_site_key') == '' || Settings::get('recaptcha_secret_key') == ''; } private function getReCaptchaLang($lang='') { diff --git a/classes/SharedProperties.php b/classes/SharedProperties.php index 0c56430..3f04001 100644 --- a/classes/SharedProperties.php +++ b/classes/SharedProperties.php @@ -5,6 +5,7 @@ use Lang; trait SharedProperties { + public $recaptcha_enabled = false; public function defineProperties() { return [ diff --git a/components/partials/recaptcha.htm b/components/partials/recaptcha.htm index b677c50..74e6252 100644 --- a/components/partials/recaptcha.htm +++ b/components/partials/recaptcha.htm @@ -1,5 +1,5 @@ -{% if (recaptcha_enabled) %} +{% if (__SELF__.recaptcha_enabled) %}
{% elseif (recaptcha_misconfigured) %}