WP-CLI command for Multisite: wp plugin active-on-sites <plugin_slug> — lists all sites where a given plugin is active.
Single-file plugin (wp-cli-plugin-active-on-sites.php), no classes — flat functions under namespace WP_CLI\Plugin\Active_On_Sites. No build step.
Entry point: invoke() → pre_flight_checks() → find_sites_with_plugin() → display_results()
Behat integration tests (no unit tests). Two feature files in features/:
plugin-active-on-sites.feature— multisite scenariosplugin-active-on-sites-single-site.feature— single site error
Run tests inside the LocalWP shell:
composer test
The bin/behat-localwp wrapper auto-detects the MySQL socket so no env vars needed. Requires running inside a LocalWP shell (wp-cli/wp-cli-tests handles WP scaffolding).
- Errors if not Multisite
- Warns and halts (exit 0) if plugin is network-activated
- Iterates all sites via
switch_to_blog()/restore_current_blog() - Supports
--field,--fields,--formatviaWP_CLI\Formatter