How to see which sites use my installed plugins (wordpress multisite)

How can I (easily) determine which of my wordpress sites are using a given plugin, on a Wordpress Multisite install?

Let's say I have 1,000 wordpress sites on a Wordpress Multisite install. I have 100 plugins.

For each plugin, I want to list all of the sites that are using that plugin.

In the GUI, I can only see how this can be done in about 1 million clicks. Is there a query I can run against the DB (and maybe cleanup with bash/awk/etc) that will automatically

  1. Get all of the plugins installed
  2. For each plugin, list all of the sites that use that plugin (by site-id is fine)

What's a fast way to determine all of the sites that use each of my installed plugins on Wordpress Multisite?

Topic multisite maintenance admin plugins Wordpress

Category Web


You can list the sites a plugin has been activated on in the shell using WP CLI:

sites=$(wp site list --field=url)
for url in $sites; do
    if wp plugin is-active "YOURPLUGINNAME" --url="${url}" --network; then
        echo "${url}"
    fi
done

It will print out the URL of each site on its own line that has that plugin activated.

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.