Repository navigation
Import forms from Contact Form 7 - #5
Merged
Merged
Conversation
The single biggest barrier to switching form plugins is the fifteen forms
somebody already built. Forms → Import now lists every wpcf7_contact_form
post on the site — read from the database directly, so it works after CF7
has been deactivated — and turns each one into an ordinary AllTerrain form:
tags become fields with their labels read from the surrounding markup, the
mail template becomes a notification with [your-name] rewritten onto
{field:…} merge tags, Mail (2) comes along only when it was switched on,
and the thank-you message becomes the confirmation. The source is never
modified, so importing is safe to try and safe to repeat.
The registry is a filter (atf_importers) that the built-in importer uses
exactly as a third-party source would, plus atf_imported_schema to correct
a mapping before it saves and atf_form_imported after the fact. WPForms
and Gravity Forms follow in their own changes.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0119U4sRRWGcTQdwYreTwpAp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The first of the three importers: Contact Form 7, the most-installed form plugin there is, and therefore the plugin most of our potential users are switching away from.
What it does
Forms → Import (a plain admin page under the Forms menu; URL-reachable inside the OpenStation shell like every other Forms page) lists every CF7 form on the site, with an Import button per form and an import-all button per source. Each import creates a new AllTerrain form and never touches the original — importing is safe to try, safe to repeat, and reversible by deleting the copy.
The importer reads CF7's data, not its API:
wpcf7_contact_formposts and their_form/_mail/_mail_2/_messagesmeta. That is deliberate — the moment somebody most wants to import is right after deactivating the old plugin, exactly when its classes are gone and its posts are not.What converts, and how faithfully
text/email/url/tel/textarea/number/range/date/hidden/filemap one to one;select(andmultiple),checkbox,radiocarry their choices including thelabel|valuepipe syntax; anexclusivecheckbox group becomes the radio group it behaves as;acceptancebecomes a consent field with its tag content as the consent line and CF7's required-by-default semantics preserved. The*becomes required;placeholder/watermarkdecide whether the first quoted value is a default or a hint;min/max/minlength/maxlength/step/filetypesall survive.<label> Question [tag] </label>markup CF7's own generator writes, so the question imports as the author wrote it; where the markup doesn't cooperate, the field name is humanised (your-name→ "Your name").[your-name]rewritten onto{field:…}merge tags and the[_site_*]/[_date]/[_remote_ip]specials onto their equivalents. TheName <address>sender splits into from-name and from-email; aReply-To:header becomes the reply-to; attachments switch on file attachment. Mail (2) imports only when CF7 had it switched on — importing a disabled autoresponder as a live one would e-mail visitors nobody meant to e-mail.mail_sent_okbecomes the confirmation.One conversion subtlety worth knowing about: CF7's default plain-text body reads
[your-name] <[your-email]>, and a notification message is kses-filtered on save — which reads<…>as a bogus tag and would delete the visitor's address outright. Plain-text bodies get their angle brackets entity-encoded on the way in; HTML bodies are left for kses to judge. (Verified against a live kses round-trip.)The registry is the API
Importers register on a new
atf_importersfilter — label plus three callables (available,forms,import) — and the built-in CF7 importer uses that filter exactly as a third-party source would.atf_imported_schemalets a site correct a mapping before the form saves;atf_form_importedfires after. All three are documented indocs/hooks-reference.mdas Experimental; the readme gains a "Switching? Bring your forms with you" section and an FAQ entry.Verification
wpcf7_contact_formpost (asserting the source is untouched andatf_form_importedfires), capability gating, and registry validation of malformed importers.{field:…}tags, reply-to and entity-encoded address line; confirmation carried over.WPForms and Gravity Forms follow, one PR each.
🤖 Generated with Claude Code
https://claude.ai/code/session_0119U4sRRWGcTQdwYreTwpAp