Skip to content

feat: opt-in ALTCHA with global + per-form settings#1

Merged
oxyc merged 1 commit into
mainfrom
feat/settings-opt-in
Jun 2, 2026
Merged

feat: opt-in ALTCHA with global + per-form settings#1
oxyc merged 1 commit into
mainfrom
feat/settings-opt-in

Conversation

@oxyc
Copy link
Copy Markdown
Member

@oxyc oxyc commented Jun 2, 2026

Summary

Makes ALTCHA protection opt-in with admin UI, instead of protecting every Gravity Form by default.

Previously the plugin was opt-out — every form was protected, configurable only via the should_protect filter. This adds a Gravity Forms add-on (GFAddOn) that surfaces the configuration as admin settings and flips the default:

  • Global "Enable for all forms" toggle — Forms → Settings → ALTCHA. Off by default.
  • Per-form "Enable ALTCHA for this form" toggle — each form's Settings → ALTCHA tab.

A form is protected when the global toggle is on or that form's own toggle is on (Settings::isEnabledForForm()). The genero/gravityforms_altcha/should_protect filter still overrides the saved settings for programmatic control.

Version bumped to 0.2.0.

⚠️ Behavior change

This flips the default from opt-out to opt-in. After upgrading, no form is protected until a toggle is enabled. Sites relying on universal coverage should turn on "Enable for all forms" after updating.

Changes

  • src/Settings.php (new) — GFAddOn with global + per-form toggle fields and the isEnabledForForm() resolver.
  • src/Plugin.php — register the add-on on gform_loaded; version → 0.2.0.
  • src/Integration.phpshouldProtect() now defaults to the saved settings instead of hardcoded true.
  • README.md — documents the settings and the filter's new role as an override.

Testing

Verified against a live WordPress + Gravity Forms 2.9 install:

  • Opt-in resolver logic (no settings / per-form off / per-form on / global on) via WP-CLI.
  • php -l clean, Pint passes, 6/6 PHPUnit unit tests pass.
  • E2E (in the consuming site): valid proof accepted, missing proof rejected, forged-but-well-formed proof rejected by verifySolution(), and no widget rendered when a form has ALTCHA disabled.

🤖 Generated with Claude Code

Previously the plugin protected every Gravity Form by default (opt-out),
configurable only through the `should_protect` filter. This adds a Gravity
Forms add-on exposing the configuration as admin UI and flips the default to
opt-in:

- Global "Enable for all forms" toggle (Forms → Settings → ALTCHA), off by
  default.
- Per-form "Enable ALTCHA for this form" toggle (form Settings → ALTCHA tab).

A form is protected when the global toggle is on, or that form's own toggle is
on. The `genero/gravityforms_altcha/should_protect` filter still overrides the
saved settings for programmatic control.

Bumps version to 0.2.0.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@oxyc oxyc merged commit d4fa6a2 into main Jun 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant