for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace GeminiLabs\SiteReviews\Modules;
use GeminiLabs\SiteReviews\Modules\Html\Builder;
use GeminiLabs\SiteReviews\Modules\Html\Field;
use GeminiLabs\SiteReviews\Modules\Style;
class Honeypot
{
/**
* @param string $formId
* @return string
*/
public function build($formId)
$honeypot = new Field([
'class' => 'glsr-input glsr-input-text',
'label' => esc_html__('Your review', 'site-reviews'),
esc_html__
If this is a false-positive, you can also ignore this issue in your code via the ignore-call annotation
ignore-call
'label' => /** @scrutinizer ignore-call */ esc_html__('Your review', 'site-reviews'),
'name' => $this->hash($formId),
'type' => 'text',
]);
$honeypot->id = $honeypot->id.'-'.$formId;
return glsr(Builder::class)->div([
'class' => glsr(Style::class)->classes('field'),
'style' => 'display:none;',
'text' => $honeypot->getFieldLabel().$honeypot->getField(),
}
public function hash($formId)
require_once ABSPATH.WPINC.'/pluggable.php';
GeminiLabs\SiteReviews\Modules\WPINC
return substr(wp_hash($formId, 'nonce'), -12, 8);
wp_hash
return substr(/** @scrutinizer ignore-call */ wp_hash($formId, 'nonce'), -12, 8);
* @param string $hash
* @return bool
public function verify($hash, $formId)
return hash_equals($this->hash($formId), $hash);