Integrazione WordPress

Protegga i Suoi moduli WordPress con SilentShield. Compatibile con Contact Form 7, WPForms, Gravity Forms e qualsiasi modulo personalizzato.

1. Aggiungere lo script

Aggiunga questo codice al file functions.php del Suo tema o utilizzi un plugin come « Insert Headers and Footers »:

functions.phpphp
// 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. Verifica lato server

Aggiunga la verifica del Nonce al Suo gestore di moduli. Per i moduli personalizzati, aggiunga questo alla Sua funzione di elaborazione:

PHPphp
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

Il Widget rileva automaticamente i moduli di Contact Form 7. Non è necessaria alcuna configurazione aggiuntiva — basta aggiungere lo script e il Widget proteggerà tutti i moduli CF7 sulla pagina.

WPForms / Gravity Forms

SilentShield rileva automaticamente i moduli di WPForms, Gravity Forms e altri plugin di moduli popolari. Il Widget inietta il Nonce in qualsiasi modulo trovato sulla pagina.

Archiviazione dell'API Key

Aggiunga la Sua API Key in wp-config.php per maggiore sicurezza:

wp-config.phpphp
// wp-config.php
define('SILENTSHIELD_API_KEY', 'your-api-key-here');