Auto-install Payments & Shipping plugin on WooCommerce activation#930
Conversation
AI code review✅ Strengths
|
|
Coverage: Base 8.81% → PR 8.88% (must not decrease). |
arunshenoy99
left a comment
There was a problem hiding this comment.
Approved ✅
Reviewed thoroughly alongside the paired catalog PR newfold-labs/wp-module-installer#331.
What this does: Re-enables the activated_plugin → detect_plugin_activation() hook and installs nfd_slug_wp_plugin_payments_shipping when WooCommerce is activated, with an early return so it only fires for woocommerce/woocommerce.php.
Verification performed:
- Slug matches the catalog entry exactly (installer#331 defines
nfd_slug_wp_plugin_payments_shipping).PluginInstalleris already imported inECommerce.php— no missing-class fatal. - No race condition / no recursion.
activated_pluginfires synchronously in-request.PluginInstaller::install()callsactivate_plugin()on the payments plugin, which re-firesactivated_plugin— but the'woocommerce/woocommerce.php' !== $pluginearly return cleanly stops re-entry. The separatedetect_plugin_activationin wp-module-data's Jetpack listener is an independent callback on a different instance — no collision. - Idempotent.
is_plugin_installed()/is_plugin_active()guards insideinstall()make repeat WooCommerce activations safe (no double install/activate). - No fatal when dependencies aren't ready. If installer#331 hasn't shipped, the unknown slug returns a
WP_Errorthatdetect_plugin_activation()discards (return value unused). If the worker zip 404s, same graceful no-op. The PR's own note confirms this. - Admin functions are available because
activated_pluginonly fires from withinwp-admin/includes/plugin.php'sactivate_plugin(); the upgrader files are explicitlyrequired ininstall_from_zip().
Pattern mirrors the prior YITH auto-install (proven), consolidated to a single slug. Ship together with installer#331 and ensure the wp-plugin-payments-shipping zip is published to the free-download worker.
https://newfold.atlassian.net/browse/PRESS0-3627
Proposed changes
Restores auto-installing payments & shipping when WooCommerce is activated, for any site at any time (not just onboarding).
Background: in Dec 2025 (PRESS0-3588) the old YITH payment auto-install was removed because the YITH plugins were replaced by the consolidated Payments & Shipping plugin — but the replacement install (PRESS0-3627) was never wired up. Net effect: activating WooCommerce installed nothing. Reported in PRESS0-4705.
activated_pluginhook →detect_plugin_activation().detect_plugin_activation()installsnfd_slug_wp_plugin_payments_shippingwhenwoocommerce/woocommerce.phpis activated, with an early return so it only fires for WooCommerce.Depends on newfold-labs/wp-module-installer#331 (catalog entry).
Type of Change
Visual
N/A — backend activation behavior.
Checklist
Further comments
Requires the installer catalog entry (#331) and the plugin zip published to the free download worker under
wp-plugin-payments-shipping. Until the zip is in the bucket, the install call is a no-op/404 — no fatal.