WordPress Configuration

Customize moderation behavior with data attributes or PHP hooks.

Data Attribute Configuration

Add data attributes to the script tag to configure Babel Shield:

Attribute Default Description
data-api-token (required) Your Babel Shield API token
data-feedback-mode inline Feedback display: inline, modal, or silent
data-blocked-message (default) Custom message shown when content is blocked
data-feedback-container (auto) CSS selector for a custom feedback container
data-debug false Enable console debug logging
data-fail-open true Allow form submission if the API is unavailable
data-api-url (production) Custom API endpoint URL

Security: data-api-url controls where form data is sent. Only use this on pages you fully control.

Excluding Forms via PHP

Using a Filter

Use the script_loader_tag filter or a form-specific hook to add data-babel-shield-ignore to forms you want to exclude:

// Exclude a specific form by adding the attribute in a template or shortcode output
function my_exclude_specific_form($form_html) {
  $form_html = str_replace('<form ', '<form data-babel-shield-ignore ', $form_html);
  return $form_html;
}

In Theme Templates

Add data-babel-shield-ignore directly in your theme's template files:

<form data-babel-shield-ignore action="<?php echo esc_url(admin_url('admin-post.php')); ?>" method="post">
  <!-- This form is NOT moderated -->
</form>

For Comment Forms

To exclude comment forms from moderation:

function my_exclude_comment_form($comment_field) {
  return str_replace('<textarea', '<textarea data-babel-shield-ignore', $comment_field);
}
add_filter('comment_form_field_comment', 'my_exclude_comment_form');

Excluding Fields

Add data-babel-shield-ignore to individual form elements to skip them during moderation:

<input type="text"
       name="internal_ref"
       data-babel-shield-ignore>
<textarea name="admin_notes"
          data-babel-shield-ignore></textarea>

All other fields in the form are still checked.

Plugin-Specific Notes

Contact Form 7

Contact Form 7 always uses AJAX submission. Babel Shield handles this automatically -- it intercepts the submit event, moderates the content, and re-triggers the AJAX submission for approved content.

WPForms

Both standard and AJAX form submissions are supported. AJAX forms are detected via the .wpforms-ajax-form class. No additional configuration is needed.

Gravity Forms

Multi-page forms: Moderation fires only on the final page submit. Page-to-page transitions are allowed without moderation.

AJAX forms: Detected via the gform_ajax hidden input. Approved content is re-submitted through the original Gravity Forms AJAX handler.

System Fields Removed Automatically

The WordPress adapter strips these system fields from the moderation payload:

Pattern Source Example
_wpnonce* WordPress core _wpnonce, _wpnonce_field
_wp_http_referer WordPress core Referrer tracking
wpforms[id|author_hash|...] WPForms Internal form metadata
_wpcf7* Contact Form 7 CF7 internal fields
is_submit_* Contact Form 7 Submission flags
gform_* Gravity Forms GF internal fields
state_N Gravity Forms Encrypted state fields

Testing Your Integration

  1. Enable debug mode by adding data-debug="true" to the script tag
  2. Submit a clean message and check the browser console for [BabelShield] log entries
  3. Submit content that should be flagged and verify the feedback message appears
  4. Run BabelShield.diagnose() in the console -- check that adapter.name is wordpress and forms.protected shows the expected count
  5. Verify WooCommerce checkout is not affected (if applicable)

Next Steps