admin管理员组文章数量:1124751
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
- Get all of the plugins installed
- 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?
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
- Get all of the plugins installed
- 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?
Share Improve this question asked May 17, 2022 at 16:42 Michael AltfieldMichael Altfield 18015 bronze badges 3 |3 Answers
Reset to default 2You 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.
I just stumbled upon an extension to WP-CLI that organizes the urls for each plugin queried, on Github.
So I modified the solution by @michael-altfield to get better results:
plugins=$(wp --quiet plugin list --field=name 2> /dev/null)
# List all plugins first
printf "${plugins}\n\n"
for plugin in $plugins; do
wp plugin active-on-sites "${plugin}"
done
The following code uses wp-cli
and will iterate through all plugins and it will print all sites that use each of those plugins.
sites=$(wp --quiet site list --field=url 2> /dev/null)
plugins=$(wp --quiet plugin list --field=name 2> /dev/null)
for plugin in $plugins; do
echo $plugin;
for url in $sites; do
wp --quiet plugin is-active "${plugin}" --url="${url}" --network 2> /dev/null
if [[ $? -eq 0 ]]; then
echo -e "\t${url}"
fi
done
done
Credit to @tom-j-nowell as the above code is a modified version of his answer, but this also loops through plugins.
本文标签: How to see which sites use my installed plugins (wordpress multisite)
版权声明:本文标题:How to see which sites use my installed plugins (wordpress multisite) 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736630236a1945761.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
wp-cli
is definitely a valid answer to this question. However, for this server, I can only use software that can be installed from a secure package manager with cryptographically signed manifests (whichapt
provides but composer, curl, git, brew, etc do not provide) – Michael Altfield Commented May 18, 2022 at 7:30wp-cli.phar
as the wp cli homepage says in that environment is not an option? Even then nothing prevents you downloading the data and running WP CLI locally, and WP CLI may be a hard requirement as you mentioned 1k+ sites ( and ignoring that files and commits in git are all managed using a cryptographic hash chain ) – Tom J Nowell ♦ Commented May 18, 2022 at 13:23