WordPress integracija
Zaštitite svoje WordPress obrasce pomoću SilentShielda. Radi s Contact Form 7, WPForms, Gravity Forms i svim prilagođenim obrascima.
1. Dodajte skriptu
Dodajte ovaj kod u functions.php datoteku svoje teme ili koristite dodatak poput 'Insert Headers and Footers':
// functions.php
function silentshield_enqueue() {
wp_enqueue_script(
'silentshield',
'https://api.silentshield.io/client.js?key=YOUR_API_KEY',
array(),
null,
true
);
wp_add_inline_script('silentshield', "
document.addEventListener('DOMContentLoaded', function() {
SilentShield.init({ apiKey: 'YOUR_API_KEY' });
});
");
}
add_action('wp_enqueue_scripts', 'silentshield_enqueue');2. Provjera na poslužitelju
Dodajte provjeru noncea u svoj obrađivač obrasca. Za prilagođene obrasce dodajte ovo u svoju funkciju za obradu:
function verify_silentshield_nonce() {
$nonce = sanitize_text_field($_POST['ss_nonce'] ?? '');
if (empty($nonce)) {
wp_die('Missing verification', 'Error', array('response' => 422));
}
$response = wp_remote_post('https://api.silentshield.io/api/v1/captcha/verify-nonce', array(
'headers' => array(
'Content-Type' => 'application/json',
'X-Api-Key' => SILENTSHIELD_API_KEY,
),
'body' => wp_json_encode(array('nonce' => $nonce)),
'timeout' => 5,
));
if (is_wp_error($response)) {
return; // fail open
}
$body = json_decode(wp_remote_retrieve_body($response), true);
if (($body['verdict'] ?? '') === 'bot') {
wp_die('Bot detected', 'Forbidden', array('response' => 403));
}
}Contact Form 7
Widget automatski otkriva Contact Form 7 obrasce. Dodatna konfiguracija nije potrebna — samo dodajte skriptu i widget će zaštititi sve CF7 obrasce na stranici.
WPForms / Gravity Forms
SilentShield automatski otkriva obrasce iz WPForms, Gravity Forms i drugih popularnih dodataka za obrasce. Widget ubacuje nonce u svaki obrazac koji pronađe na stranici.
Spremanje API ključa
Dodajte svoj API ključ u wp-config.php radi sigurnosti:
// wp-config.php
define('SILENTSHIELD_API_KEY', 'your-api-key-here');