|

WP-CLI Command to List Sites on a Multisite with a Specific Plugin Active

Digital Church Platform is built on wordpress multisite, and as we have grown our platform, we’ve found it incredibly useful to lean into using command line interface to manage our servers and our wordpress installation via wp-cli.

Once specific wp-cli command we needed to run was to be able to generate a list of sites that had a specific plugin activated. There are plugins like Enhanced Multisite that provided a way to do that in the network admin interface, but that one in particular added a good bit of bloat to the network admin and made things unstable when scaling a larger network. WP-CLI is a much more lightweight approach to accessing data like that, so we went on a hunt for how to do it.

There isn’t a wp-cli command in wordpress core that does this, but we did find an extra script we could install on our servers to add this functionality to wp-cli.

https://github.com/iandunn/wp-cli-plugin-active-on-sites

We installed this using the instructions in the readme.md on the root directory of the server, and then we access wordpress to run the commands. The commands are simple:

wp plugin active-on-sites dgtl-sermons –allow-root

This would generate a simple table with the blog id and subdomain of each site that has it active. Big thanks to Ian Dunn for this great tool!

Leave a Reply

Your email address will not be published. Required fields are marked *