feat(integrations): add inactive plugin state#4721
Conversation
There was a problem hiding this comment.
Pull request overview
Surfaces required plugin status for Audience integrations so admins can see missing/inactive dependencies and activate installed dependencies from the Integrations screen.
Changes:
- Adds a
required_pluginsintegration API contract and includes it in integration settings responses. - Declares Newspack Newsletters as the ESP integration dependency.
- Updates the integrations card UI to show requirements or an Activate action based on dependency status.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
src/wizards/audience/views/integrations/settings-section.js |
Renders plugin requirement labels and Activate actions on integration cards. |
src/wizards/audience/views/integrations/index.js |
Adds plugin activation API handler and refetches settings after activation. |
includes/reader-activation/integrations/class-integration.php |
Adds base get_required_plugins() method. |
includes/reader-activation/integrations/class-esp.php |
Reports Newspack Newsletters install/active status for ESP. |
includes/reader-activation/class-integrations.php |
Exposes required_plugins in the integrations settings payload. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
e258e82 to
d957f2e
Compare
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
| const handleActivatePlugin = useCallback( | ||
| pluginSlug => | ||
| apiFetch( { | ||
| path: `/newspack/v1/plugins/${ pluginSlug }/activate`, | ||
| method: 'POST', | ||
| } ).then( () => fetchSettings() ), | ||
| [ fetchSettings ] | ||
| ); |
There was a problem hiding this comment.
We should have an in-flight guard, loading state, and .catch() here.
| * @return array List of associative arrays with keys `slug`, `name`, `is_active`, `is_installed`. | ||
| */ | ||
| public function get_required_plugins() { | ||
| $status = \Newspack\Plugin_Manager::get_managed_plugin_status( 'newspack-newsletters' ); |
There was a problem hiding this comment.
Non-blocking: Plugin_Manager::get_managed_plugin_status() re-runs on every wizard REST hit.
get_plugins() is cached intra-request, but wp_get_themes() inside get_installed_plugins() re-scans /themes. Two integrations declaring the same required plugin = two scans. Not on a hot path (admin-only), but worth memoising as a static map keyed by slug before more integrations land.
| const uninstalledPlugin = missingPlugins.find( plugin => ! plugin.is_installed ); | ||
| const activatablePlugin = missingPlugins.length && ! uninstalledPlugin ? missingPlugins[ 0 ] : null; |
There was a problem hiding this comment.
Non-blocking: activatablePlugin = missingPlugins[ 0 ] picks only the first inactive plugin; after clicking Activate the card just re-renders with the second one.
Today's ESP has a single required plugin, so this is latent, but the framework is clearly designed for multi-plugin. Either chain activations or restructure to requiresInstall = missingPlugins.filter(!is_installed) and activatable = missingPlugins.filter(is_installed).
All Submissions:
Changes proposed in this Pull Request:
Surfaces the install/active status of an integration's required plugins on the Audience → Integrations screen so admins can resolve missing dependencies without leaving the page.
Integration::get_required_plugins()so integrations can declare the plugins they depend on. The base implementation returns an empty array;ESPoverrides it to reportnewspack-newslettersinstall/active state viaPlugin_Manager::get_managed_plugin_status().required_pluginspayload on each integration in the wizard REST response.POST /newspack/v1/plugins/{slug}/activatecall followed by a refetch. When a required plugin is not installed at all, the card renders a "Requires …" requirements affordance instead.How to test the changes in this Pull Request:
n build newspack-plugin), and load Newspack → Audience → Integrations in the admin.required_pluginsarray for the ESP integration withslug,name,is_active, andis_installedkeys.required_pluginsarray and unchanged UI.Other information: