Last active
February 16, 2023 05:54
-
-
Save bigdawggi/9079774 to your computer and use it in GitHub Desktop.
WP-CLI commands to get the active themes across a WordPress blog network (single site ID with multiple blogs for the site)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Be sure to change or omit the --network parameter; it defaults to 1. | |
wp site list --network=4 --field=url | while read line; do wp theme list --status=active --field=name --url=$line >> /tmp/wpcli-themes.txt; done && sort /tmp/wpcli-themes.txt | uniq -c |
Thanks @iandunn, if I ever need this again, I'll investigate it :)
I think using something like wp option get stylesheet --url="$line"
should go much faster than wp theme list
wp find-unused-themes
fixed the performance issue, so it's a good solution now IMO.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for sharing this!
I found it to take 20+ minutes on a network with 1300 sites, though. It may be possible to optimize with an approach similar to wp plugin active-on-sites. That would avoid the overhead from launching WP-CLI and reading from disk
N
times, and takes about65
seconds on the same network.These is the wp find-unused-themes package, but it's also pretty slow because it relies on
WP_CLI::launch_self
.