Skip to content

Offer the import instead of waiting to be found - #11

Merged
AllTerrainDeveloper merged 1 commit into
mainfrom
feature/one-click-import
Aug 18, 2026
Merged

AllTerrainDeveloper merged 1 commit into
mainfrom
feature/one-click-import

Conversation

@AllTerrainDeveloper

Copy link
Copy Markdown
Owner

Yes — and it should have worked this way from the start. An importer nobody finds is an importer nobody uses, and the moment it is worth the most is the one nobody goes looking for it: just after activating this plugin on a site that already has fifteen forms in another one.

What it does now

The plugin looks for them itself and says so, with one button that brings all of them over — from every source at once:

AllTerrain Forms found 3 forms in Contact Form 7.
Each one is copied with its fields, notification emails and thank-you message. The originals are never changed.
[ Import all 3 forms ] [ Choose which ] · Not now

With more than one source it counts them out instead, because "4 forms in other plugins" leaves you wondering which — and which is the reason you would click:

AllTerrain Forms found 4 forms in other plugins.
3 from Contact Form 7 and 1 from WPForms. Each one is copied with…

The Import page gains the same one-click button above its per-source lists (Import all 4 forms), since somebody arriving there after switching plugins usually wants all of it; picking through the lists is the exception.

What keeps it from being the kind of notice people install plugins to hide

  1. Only where it is relevant — this plugin's own screens and the Plugins screen, which is where an activation lands. Not the Dashboard, not everybody's Posts list. And never on the Import page itself, where a notice pointing at the page you are on is just noise.
  2. "Not now" is remembered, per user, for good — a real answer stored in user meta, not the X in the corner that forgets on reload. Per user rather than per site, because one administrator dismissing it must not answer for the person who actually built those forms.
  3. It stops offering the moment anything has been imported, even if forms remain. The notice exists to introduce a feature; by then you have been on the Import page and know where it is.
  4. atf_show_import_notice turns the whole thing off for a site that would rather introduce it its own way.

Cost of the detection

Answering "is there anything to import" costs a query per source, plus a SHOW TABLES for Gravity Forms, and it is asked on ordinary admin page loads. So the survey is cached for twelve hours and dropped whenever it could be wrong: a form imported, or a plugin activated or deactivated.

atf_import_all() takes the importer ids once up front rather than re-reading the survey inside its loop — each successful import invalidates the cache, so re-reading would re-run every source's query for every form.

Verified against your real site

Rendered on the 8889 site through the actual admin_notices path, with its own data:

ONE SOURCE:  AllTerrain Forms found 3 forms in Contact Form 7.
             Each one is copied with its fields, notification emails and thank-you message.…
             Import all 3 forms · Choose which · Not now

TWO SOURCES: AllTerrain Forms found 4 forms in other plugins.
             3 from Contact Form 7 and 1 from WPForms. Each one is copied…
             Import all 4 forms · Choose which · Not now

That run is also what caught the copy bug in my first draft, which said "in other plugins" even when every form came from one.

11 new PHPUnit tests (567 green): counts per source with empty sources omitted; the cache holding and being dropped; atf_import_all() taking everything from two sources at once and leaving both originals untouched; and the notice decision asserted from both sides — shown when forms exist, silent when dismissed (and still shown to a different administrator), silent after the first import, silent without the capability, silent behind the filter, and on the right screens only. PHPCS: 0 errors.

readme.txt and docs/hooks-reference.md updated for the new behaviour and filter.

🤖 Generated with Claude Code

https://claude.ai/code/session_0119U4sRRWGcTQdwYreTwpAp

An importer nobody finds is an importer nobody uses, and the moment it
is worth the most is the one nobody goes looking for it: just after
activating this plugin on a site that already has fifteen forms in
another one. So the plugin looks for them itself and says so --
"AllTerrain Forms found 6 forms in Contact Form 7" -- with one button
that brings all of them over, from every source at once.

Three rules keep that from becoming the kind of notice people install
other plugins to hide. It appears only where it is relevant: this
plugin's screens and the Plugins screen, where an activation lands.
"Not now" is remembered per user, for good, because one administrator
dismissing it must not answer for the person who actually built those
forms. And it stops offering the moment anything has been imported --
by then the Import page is somewhere you go, not something that asks.

The survey behind it costs a query per source, so it is cached for
twelve hours and forgotten whenever a form is imported or a plugin is
switched on or off. `atf_show_import_notice` turns the whole thing off
for a site that would rather introduce it its own way.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0119U4sRRWGcTQdwYreTwpAp
@AllTerrainDeveloper
AllTerrainDeveloper merged commit da2f6aa into main Aug 18, 2026
3 checks passed
@AllTerrainDeveloper
AllTerrainDeveloper deleted the feature/one-click-import branch August 18, 2026 11:49
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