refactor(emails): move Emails from Settings to Audience Configuration#4759
Open
kmwilkerson wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Moves the unified Emails management UI from Newspack → Settings to Audience → Configuration as the last tab. The Emails screen itself (chips, DataViews, registry, preview thumbnails, toggle behavior) is unchanged; REST API paths remain stable via a hardcoded REST_BASE constant on Emails_Section, and a small inline redirect forwards bookmarks from the old hash URL to the new one.
Changes:
- Re-registers the
Emails_Sectionunder the Audience wizard (class-wizards.php,class-audience-wizard.php) while keeping the REST namespacewizard/newspack-settings/emailsfor backwards compatibility. - Removes the Emails tab/data from the Settings wizard (PHP localized data, TS types, sections registry) and adds it to the Audience wizard (route, tab, localized
window.newspackAudience.emails). - Adds an inline redirect on the old Settings page from
#/emailsto the new Audience URL, plus a minor typo fix insettings.tsx("transacitonal" → "transactional").
Reviewed changes
Copilot reviewed 10 out of 16 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| includes/class-wizards.php | Moves Emails_Section registration from Settings to Audience wizard. |
| includes/wizards/audience/class-audience-wizard.php | Accepts $args in constructor; localizes emails data on window.newspackAudience. |
| includes/wizards/newspack/class-emails-section.php | Switches wizard_slug to newspack-audience; introduces REST_BASE constant to preserve API path. |
| includes/wizards/newspack/class-newspack-settings.php | Removes Emails tab data; adds inline JS redirect for old bookmarks. |
| src/wizards/audience/views/setup/index.js | Adds Emails tab and route to Audience setup. |
| src/wizards/audience/views/setup/emails/index.tsx | Reads new window.newspackAudience.emails shape; wraps screen with withWizardScreen. |
| src/wizards/audience/views/setup/emails/emails.tsx | Reads emails config from window.newspackAudience instead of window.newspackSettings. |
| src/wizards/audience/views/setup/emails/settings.tsx | Header doc update; fixes "transacitonal" typo. |
| src/wizards/audience/views/setup/emails/emails.test.js | Updates mock to new window.newspackAudience.emails shape. |
| src/wizards/audience/views/setup/emails/email-preview.tsx / .scss / .test.js | New EmailPreview component, styles, and tests (preview path uses stable newspack-settings/emails REST base). |
| src/wizards/audience/views/setup/emails/emails.scss | Emails tab layout, chips, and trigger description styles. |
| src/wizards/newspack/views/settings/sections.tsx | Removes Emails import and section component mapping. |
| src/wizards/newspack/types/index.d.ts | Drops Emails entry from window.newspackSettings types. |
| src/wizards/types/window.d.ts | Adds emails entry to window.newspackAudience types. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
3410271 to
643cb6d
Compare
bfb86d3 to
a420a31
Compare
…NPPD-1538) Move the Emails management UI from Newspack > Settings > Emails to Audience > Configuration > Emails as the last tab. REST API paths remain stable at /wizard/newspack-settings/emails via a hardcoded REST_BASE constant for backward compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
a420a31 to
8b01984
Compare
643cb6d to
43a03aa
Compare
This was referenced May 27, 2026
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.
What this PR does
Moves the unified Emails management UI from Newspack → Settings → Emails to Audience → Configuration → Emails, where it sits alongside the other audience-configuration surfaces (NPPD-1538).
Nav-and-routing change only. The Emails screen itself (chips, DataViews, registry, preview thumbnails, toggle behavior) is unchanged. The REST API also stays at its existing path so no external callers break.
Final piece of the project's UI consolidation work — Emails now lives where publishers will look for it.
Depends on slice 2 (#4732), NPPD-1524 (#4756), and NPPD-1537 (#4758) — branched off that stack and inherits their changes.
Code changes
Backend —
includes/wizards/newspack/class-emails-section.php$wizard_slugchanged from'newspack-settings'to'newspack-audience'so the section registers under the Audience wizardREST_BASEconstant hardcoded to'wizard/newspack-settings/emails'with a docblock explaining the historical naming for API stability. Allregister_rest_route()calls useself::REST_BASEinstead of deriving from$wizard_slug— REST routes stay at their existing paths regardless of which parent wizard owns the admin screenBackend —
includes/class-wizards.php'emails'section from thenewspack-settingswizard instantiation'emails'section to theaudiencewizard via the new$argsparameterBackend —
includes/wizards/audience/class-audience-wizard.php$argstoparent::__construct()so sections can be passed inenqueue_scripts_and_styles()localizes the emails config (isEmailEnhancementsActive, dependencies, postType) ontowindow.newspackAudience.emailsBackend —
includes/wizards/newspack/class-newspack-settings.phpemailsblock fromget_local_data()and dropped the now-unused imports (Emails,Reader_Revenue_Emails,WooCommerce_Emails)window.location.hash === '#/emails', redirects toadmin.php?page=newspack-audience#/emailsbefore React mounts. Handles old bookmarks without a server-side redirect (the hash fragment is invisible to PHP)Frontend —
src/wizards/audience/views/setup/emails/(moved fromsrc/wizards/newspack/views/settings/emails/)index.tsx,emails.tsx,settings.tsx,email-preview.tsx,email-preview.scss, plus their tests. Directory nesting depth is unchanged, so existing relative imports continue resolving correctly without path editsindex.tsx: data source switched fromwindow.newspackSettings.emails.sections.emails.isEmailEnhancementsActiveto the flattenedwindow.newspackAudience.emails.isEmailEnhancementsActiveemails.tsx: reads config fromwindow.newspackAudience.emailsFrontend —
src/wizards/audience/views/setup/index.jsEmailsimport, appended the "Emails" tab unconditionally (matches current Settings behavior — screen contents continue to adapt viaisEmailEnhancementsActive)/emailsrouteFrontend —
src/wizards/newspack/views/settings/sections.tsxEmailsimport and theemailsentry from the sections mappingFrontend — TypeScript
src/wizards/types/window.d.ts: addedemailsproperty to thenewspackAudienceinterfacesrc/wizards/newspack/types/index.d.ts: removedemailsfrom thenewspackSettingsinterfaceFrontend — Tests
src/wizards/audience/views/setup/emails/emails.test.js: updated mock setup fromwindow.newspackSettingstowindow.newspackAudiencewith the flattened structureemail-preview.test.js: existing mock paths unchanged (REST API paths stayed put)Why this PR
The Emails management UI has grown into a comprehensive audience-configuration surface (registry, chips, WC integration, preview thumbnails, card expiry warning, branded WC Subs delivery). It belongs alongside the other Audience → Configuration screens — Configuration, Checkout & Payment, and eventually Access Control.
The single non-obvious choice in this PR is keeping the REST API at the old path (
wizard/newspack-settings/emails). The motivation: REST paths are part of the contract with external callers (Newspack Manager, third-party integrations, tooling). Moving them would break things outside this repo for no UX benefit. The frontend doesn't care which path the API lives at — it just hits whatever path is configured.Manual testing
Tested locally with Newspack, WooCommerce, WooCommerce Subscriptions, and the WC Block Email Editor feature enabled. Verified:
admin.php?page=newspack-settings#/emailsredirects toadmin.php?page=newspack-audience#/emails/newspack/v1/wizard/newspack-settings/emails(confirmed via network tab and direct curl)Note: 3 pre-existing TypeScript warnings on DataViews generics carried over from trunk — not introduced by this PR.
PHPUnit, Jest (49 suites / 438 tests), and webpack all green locally; PHPCS clean on changed files.
All Submissions: