Skip to content

feat(reader-activation): replace RAS auto-enable with manual toggle#4754

Closed
miguelpeixe wants to merge 29 commits into
trunkfrom
nppd-1066-allow-ras-to-be-active-with-less-requisites
Closed

feat(reader-activation): replace RAS auto-enable with manual toggle#4754
miguelpeixe wants to merge 29 commits into
trunkfrom
nppd-1066-allow-ras-to-be-active-with-less-requisites

Conversation

@miguelpeixe

@miguelpeixe miguelpeixe commented May 25, 2026

Copy link
Copy Markdown
Member

All Submissions:

Changes proposed in this Pull Request:

Closes NPPD-1066.

Reworks Audience Management (RAS) setup so it can be enabled with far fewer prerequisites, and reorganizes the wizard around an explicit reader‑revenue platform selection. RAS no longer auto‑enables based on a fully‑configured plugin stack; an administrator picks a platform and Audience Management is enabled as part of that choice, regardless of which optional plugins are installed.

Platform selection (first‑run step)

  • The Audience wizard opens a three‑option platform chooser — Newspack (full WooCommerce stack), RevEngine (News Revenue Hub / donate block), and Other (bring‑your‑own integrations) — rendered in the standard wizard header/layout. It appears whenever no platform has been chosen yet.
  • Selecting a platform persists the reader‑revenue platform, enables Audience Management, and auto‑installs that platform's plugins (Newspack → WooCommerce, WooCommerce Subscriptions, Newspack Blocks; RevEngine → Newspack Blocks; Other → none), then advances to the configuration page.
  • Plugin installation is non‑blocking: if a plugin can't be auto‑installed (e.g. WooCommerce Subscriptions, which Newspack cannot install automatically), the installer surfaces the per‑plugin message and a Continue button instead of waiting indefinitely.
  • The currently‑selected platform is marked with a "Selected" badge.

Enable / disable

  • The enable/disable toggle now lives on the platform screen (not the configuration page, where it was easy to flip accidentally). First‑run enabling is implicit in selecting a platform; the toggle is shown when returning to the screen.
  • Disabling prompts a confirmation modal (destructive action). Enabling is immediate.
  • A site with Audience Management disabled lands on the platform screen (rather than the active‑looking configuration page), showing the current platform's "Selected" badge and the toggle.

Tabs

  • The Checkout & Payment tab is shown only for the Newspack and RevEngine platforms; for "Other" it is hidden. The inline platform selector was removed from that tab (it is now the first‑run chooser).

Configuration page cleanup

  • The prerequisites checklist is trimmed and reordered to: Transactional Emails → Legal Pages → reCAPTCHA → ESP. The Reader Revenue and Audience Management Campaign prerequisites were removed, and ESP appears only when Newspack Newsletters is installed.
  • Any of the selected platform's required/recommended plugins that are still missing are surfaced on the configuration page (with install actions), so they can be completed there even if the chooser's install didn't finish.

Plugin independence

  • Prerequisites are an informational checklist; the "Skip" buttons and the "waiting for all settings" disabled‑action state are gone. The skip subsystem is removed: Reader_Activation::skip() / is_skipped() / is_ras_ready_to_configure(), the /audience-management/skip REST route, the SKIP_CAMPAIGN_SETUP_OPTION constant, and the is_skipped_campaign_setup localized field.
  • The now‑unused Reader_Activation::is_reader_revenue_ready() helper (only consumed by the removed Reader Revenue prerequisite) and other dead code (an unused donation_settings read in Donations::remove_donations_from_cart(), the never‑set is_unavailable prerequisite branch) are removed.
  • Newsletters‑dependent controls (post‑checkout newsletter signup, ESP Advanced Settings) gate on Newspack Newsletters being installed.
  • Reader_Activation::setup_nav_menu() no longer requires WooCommerce for the anonymous Sign In link.
  • The Audience → Donations submenu hides when neither WooCommerce is installed nor NRH is the donations platform.

Fixes

  • Saving the Newspack (wc) platform before WooCommerce is installed no longer fatals: the WooCommerce donation‑product write is skipped when WooCommerce isn't active (Donations::get_donation_settings() returns a WP_Error).
  • The wp newspack ras setup CLI command now explicitly enables Audience Management (it previously relied on the removed auto‑enable path, so it published prompts but left RAS disabled).
  • Audience_Donations::fetch_all_data() no longer serializes a WP_Error into donation_data when the WooCommerce suite is incomplete (returns an empty array instead; missing plugins are still surfaced via plugin_status), and api_update_payment_settings guards against a missing platform param.

Migration

  • No upgrade migration: already‑enabled sites keep enabled = true. The legacy newspack_reader_activation_*_skipped options are left in the database, intentionally unread.

How to test the changes in this Pull Request:

  1. First run: On a site with no reader‑revenue platform chosen, open Audience. Confirm a platform chooser (Newspack / RevEngine / Other) renders in the wizard layout instead of the configuration page.
  2. Select Other. Confirm Audience Management is enabled, no plugins are installed, the Checkout & Payment tab is absent, and you land on the configuration page.
  3. Select Newspack (on a site without WooCommerce). Confirm it installs WooCommerce and Newspack Blocks, that WooCommerce Subscriptions reports it must be installed manually, and that a Continue button appears (no hang). Continue and confirm the Checkout & Payment tab is present.
  4. Missing plugins: On the configuration page with the Newspack platform selected but WooCommerce/Subscriptions not installed, confirm they are listed as recommended/missing with install actions.
  5. Prerequisites: Confirm the checklist shows Transactional Emails → Legal Pages → reCAPTCHA, with ESP appearing only when Newspack Newsletters is installed, and no Reader Revenue or Campaign‑defaults items.
  6. Disable + confirm: From the configuration page, click Change to open the platform screen; toggle Audience Management off and confirm a confirmation modal appears before it is disabled.
  7. Disabled landing: With Audience Management disabled, reload the wizard. Confirm it lands on the platform screen (not the configuration page), the previously‑selected platform shows a "Selected" badge, and the toggle reads "disabled".
  8. Re‑enable: Toggle Audience Management on (or re‑select the platform) and confirm you move forward to the configuration page.
  9. Front‑end / menus: With WooCommerce not installed and RAS enabled, confirm the Sign In link renders for anonymous visitors; confirm the Audience → Donations submenu is hidden until WooCommerce is installed or NRH is the platform.
  10. Regression: On a site already enabled with all plugins present, confirm no regression in the wizard, reader auth, or RAS‑dependent features.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully ran tests with your changes locally?

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR changes the Audience → Setup flow for Reader Activation (RAS) so enablement is no longer automatically inferred from prerequisites; instead, admins explicitly enable/disable Audience Management via a manual toggle, while prerequisites become informational and “skip” functionality is removed.

Changes:

  • Adds an explicit “Enable Audience Management” toggle in the Setup UI and removes skip/auto-enable wiring.
  • Simplifies prerequisites checklist behavior (no skip states; always renders checklist items) and adjusts campaign publish flow copy/actions.
  • Removes skip REST endpoint and related PHP helpers/options; makes menu behavior less dependent on WooCommerce.

Reviewed changes

Copilot reviewed 9 out of 10 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/unit-tests/reader-activation.php Adds unit coverage ensuring skip-related keys/methods are removed.
src/wizards/audience/views/setup/setup.js Introduces manual enable toggle and updates prerequisite rendering / newsletter gating.
src/wizards/audience/views/setup/index.js Removes skip action plumbing from the wizard container.
src/wizards/audience/views/setup/complete.js Updates campaign completion step UI and removes skip-activation behavior.
src/wizards/audience/views/setup/campaign.js Removes “Skip” button/navigation dependencies from campaign step.
src/wizards/audience/types/index.d.ts Updates TS types to drop skip-related prerequisite props/fields.
src/wizards/audience/components/prerequisite.tsx Removes skip UI and simplifies prerequisite validity/status handling.
includes/wizards/audience/class-audience-wizard.php Removes skip endpoint/localized data; adjusts activation endpoint behavior.
includes/wizards/audience/class-audience-donations.php Hides Donations submenu when neither WooCommerce nor NRH platform is available.
includes/reader-activation/class-reader-activation.php Removes skip/auto-enable helpers and cleans prerequisite status payload; loosens nav menu WC dependency.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread includes/wizards/audience/class-audience-wizard.php
Comment thread src/wizards/audience/components/prerequisite.tsx Outdated
Comment thread src/wizards/audience/views/setup/complete.js

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 14 out of 16 changed files in this pull request and generated 4 comments.

Comment thread src/wizards/audience/views/setup/setup.js Outdated
Comment thread src/wizards/audience/views/setup/setup.js
Comment thread src/wizards/audience/views/setup/complete.js
Comment thread includes/reader-activation/class-reader-activation.php Outdated
@miguelpeixe

Copy link
Copy Markdown
Member Author

Migrated to the newspack-workspace monorepo: Automattic/newspack-workspace#196 (identical diff, now under plugins/newspack-plugin). Closing here in favor of that PR.

@miguelpeixe miguelpeixe closed this Jun 2, 2026
@miguelpeixe miguelpeixe deleted the nppd-1066-allow-ras-to-be-active-with-less-requisites branch June 2, 2026 15:01
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.

2 participants