Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hide in bootstrap4 #3197

Merged
merged 10 commits into from
Jul 11, 2020
8 changes: 8 additions & 0 deletions app/Config/Honeypot.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@ class Honeypot extends BaseConfig
* @var boolean
*/
public $hidden = true;
/**
* Hide the Honypot. The default is style, but if the CSP is enabled, it is better to use class.
* Example:
* public $hiddenBy = 'class="hidden"';
*
* @var string
*/
public $hiddenBy = 'style="display:none"';
michalsn marked this conversation as resolved.
Show resolved Hide resolved
/**
* Honeypot Label Content
*
Expand Down
6 changes: 5 additions & 1 deletion system/Honeypot/Honeypot.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ function __construct(BaseConfig $config)
{
throw HoneypotException::forNoHiddenValue();
}
if ($this->config->hiddenBy === '')
michalsn marked this conversation as resolved.
Show resolved Hide resolved
{
throw HoneypotException::forNoHiddenValue();
}

if ($this->config->template === '')
{
Expand Down Expand Up @@ -124,7 +128,7 @@ protected function prepareTemplate(string $template): string

if ($this->config->hidden)
{
$template = '<div style="display:none">' . $template . '</div>';
$template = '<div ' . $this->config->hiddenBy . '>' . $template . '</div>';
michalsn marked this conversation as resolved.
Show resolved Hide resolved
}
return $template;
}
Expand Down