I've got a multisite install and wp-cli set up and working. Optimally, what I'd need is a script to run that will generate a list of all of the sites on the multisite install along with the name of the active theme.
I can figure out how to run this on a single-site basis, but really what I need is the ability to generate the list.
We've got about 400+ sites within our network, growing weekly. Has anyone tackled this problem yet?
Update: I've got this mostly working now, though I feel like this could be better optimized.
I'm saving this as list_active_themes.sh and am outputting it as a JSON file by running sh list_active_themes.sh > active_themes.json
.
The last piece is to remove the trailing comma that is the result of the 9th line below-- and me not knowing how to count the returned site
results in order to do an if statement to not output the comma if it is the final one in the for loop.
Here's my code:
echo "{"
for site in $(wp site list --domain=sample.domain.com --field=url --quiet)
do
echo -e '\t"site":{'
printf '\t\t"url":"%s",\n' "$site"
echo -e '\t\t"theme":"'|tr '\n' ''
wp theme list --status=active --field=name --url=$site|tr '\n' ''
echo '"'
echo -e '\n\t},'
done
echo "}"