Skip to content

Add a status panel and a Send emails switch - #220

Merged
Ninodevo merged 3 commits into
trunkfrom
add/152-status-panel-email-switch
Oct 13, 2026
Merged

Ninodevo merged 3 commits into
trunkfrom
add/152-status-panel-email-switch

Conversation

@Ninodevo

@Ninodevo Ninodevo commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A partner asked in #152 for a clear view of what Safety Net has on and off, and for a way to turn emails on while testing. This adds both. The WooCommerce API switch for 3PLs is not part of this PR.

  • Status panel: a Status table at the top of Tools > Safety Net (includes/status.php). It has one row per protection, each with an icon plus screen reader text, a one-line explanation and a link to where it changes:

    • environment and emails;
    • the email log;
    • users, orders and subscriptions (deleted, or kept and until when);
    • scrubbed options;
    • deactivated plugins, naming any that are active again;
    • payment gateway plugins;
    • renewal actions (only where WooCommerce Subscriptions runs);
    • WooCommerce webhooks active again;
    • WooCommerce REST API keys, plus administrators' application passwords, which still let apps such as a 3PL use the REST API;
    • search engines and transients.

    Queries are guarded, so the panel renders cleanly without WooCommerce or the email log table, on multisite subsites, and before the first run. are_renewals_paused() is shared with the existing notice.

  • Send emails switch: on Email Log > Settings, under its own "Sending emails" heading.

    • It is off by default, with a red warning, and switching it on asks for confirmation first.
    • While it's on, stop_emails() lets every email through, unless another pre_wp_mail filter already decided. Those emails are logged as "Let through: emails switched on" with their real Sent/Failed result. Core's password-change and email-change notices are sent too.
    • Every wp-admin page, network admin included, shows a red notice with a link to the switch and wp option update safety_net_send_emails_toggle off (with --url on multisite).
    • The REST status route gets emails_enabled.
  • Safe on copies: the switch is bound to the site's address, stored as a hash of the stored home and WP_HOME, so search-replace can't rewrite it. Copies and databases pushed to another address start with emails off, and the switch shows "Switched on for another address". It is also held off, disabled in the form, while SAFETY_NET_DELETE_DATA keeps customer data, like the renewal pause.

  • Version 1.12.0, in its own commit.

Refs #152.

Notes

  • The block editors and WooCommerce > Settings > Payments hide ordinary admin notices, so the "emails are switched on" warning doesn't show on those screens. The README says so.
  • On a copy, wp option update safety_net_send_emails_toggle on changes nothing, because WP-CLI sees the stored value is already "on" and skips the save. Emails stay off. The README says to switch it on in Settings, or run … off first.
  • Application passwords are counted only where WordPress makes them available, which means HTTPS or a local environment.
  • Trunk, with Keep reset links working in Send to me copies #219, is merged in: emails let through by the switch get the same key handling as other emails Safety Net lets through.

Test plan

  • New status-and-switch scenario (single-site), ST1–ST11 and SW1–SW11:
    • every status row in a fresh site and after changes: a denylisted plugin active again, a webhook re-enabled, an API key created after the run, emails on, logging off;
    • escaping, and multisite without errors;
    • the switch's default, the Settings markup with its confirm text and assets, saving it on and off, and every email path while it's on;
    • the notice on several admin pages, only for administrators;
    • REST emails_enabled;
    • the address binding: a simulated copy, switching on again on the copy, the WP-CLI case, and "on" stored without an address;
    • application passwords counted per administrator.
  • woocommerce-keep-data KD23: with the switch stored on, emails stay under the keep rules; the field is disabled and saving keeps the stored value; no notice; the panel says it is held off.
  • woocommerce-hpos ST12, multisite-network-woocommerce M15/M17 and production: the panel and the switch where WooCommerce runs and on multisite; production has neither.
  • Each new guard was checked by breaking it in a copy of the plugin: the test aimed at it failed.
  • Full suite on PHP 8.3, after merging trunk: 304 passed, 0 failed. phpcs: no new messages compared with trunk. npm run test:archive passes.

Ninodevo and others added 2 commits October 13, 2026 11:48
#152 asked for a clear view of what Safety Net has on and off, and for a
way to turn emails on while testing.

- Tools > Safety Net starts with a Status table: environment, emails,
  email log, users and orders, scrubbed options, deactivated plugins
  (and any active again), payment gateways, renewal actions, webhooks
  active again, WooCommerce REST API keys and administrators' application
  passwords, search engines and transients. Each row has an icon with
  screen reader text, what it means and where to change it.
- Email Log > Settings gets a Send emails switch, off by default, with a
  red warning and a confirmation when switching it on. While it is on,
  stop_emails() lets every email through (logged as "Let through: emails
  switched on" with its real result), core's password and email change
  notices are sent, and every wp-admin page shows a red notice with a
  link to the switch and the WP-CLI command to turn it off.
- The switch is bound to the site's address (a hash of home and
  WP_HOME), so copies and pushed databases start with emails off. It is
  held off while SAFETY_NET_DELETE_DATA keeps customer data.
- The REST status route reports emails_enabled.

Refs #152.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@t51eng-poseidon

t51eng-poseidon Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

🔱 Poseidon started reviewing this PR — central run.

@t51eng-poseidon t51eng-poseidon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔱 Poseidon Review

No issues found on this pass.

ℹ️ Review info
  • Commit: 4d4f040
  • Files reviewed: includes/status.php, includes/admin.php, includes/common.php, includes/email-log.php, includes/utilities.php, includes/rest-status.php, safety-net.php, assets/js/safety-net-admin.js
  • Files skipped: AGENTS.md, README.md (docs); assets/css/admin.css (styling only); tests/smoke/fixtures/mu-plugins/00-sn-test-helper.php, tests/smoke/fixtures/php/helpers.php, tests/smoke/lib/status.mjs, tests/smoke/scenarios.mjs, tests/smoke/scenarios/email-log.test.mjs, tests/smoke/scenarios/multisite-network-woocommerce.test.mjs, tests/smoke/scenarios/production.test.mjs, tests/smoke/scenarios/staging-plugin.test.mjs, tests/smoke/scenarios/status-and-switch.test.mjs, tests/smoke/scenarios/woocommerce-hpos.test.mjs, tests/smoke/scenarios/woocommerce-keep-data.test.mjs, tests/smoke/scenarios/woocommerce-preprocessed.test.mjs (test-only, not shipped)
  • Model: claude-opus-5-5

Resolves the overlap with #219: log_email() keeps both the secrets column
and the allowed_switch status, the docs combine both changes, and ST6
expects the email log's table version 2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@t51eng-poseidon t51eng-poseidon Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔱 Poseidon Review

No issues found on this pass. The only change since the last review is the trunk merge (#219). It resolves the overlap correctly: log_email() treats allowed_switch like allowed (no dry run, row pushed for the real result) and still applies the secrets handling and the staff-recipient check to emails the switch lets through.


♻️ Previously flagged

No previously flagged items.


ℹ️ Review info
  • Commit: 6a07ecd
  • Files reviewed: includes/admin.php, includes/email-log.php, includes/status.php, includes/common.php, includes/utilities.php, includes/rest-status.php, safety-net.php, assets/js/safety-net-admin.js
  • Files skipped: AGENTS.md, README.md (docs); assets/css/admin.css (styling only); tests/smoke/** (test-only, not shipped)
  • Model: claude-opus-5-5

@Ninodevo
Ninodevo merged commit 1df3147 into trunk Oct 13, 2026
20 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