Skip to content

Instantly share code, notes, and snippets.

@tangrufus
Last active August 16, 2022 14:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tangrufus/bb5ee813ec9c70b0e61a29279cb93cb2 to your computer and use it in GitHub Desktop.
Save tangrufus/bb5ee813ec9c70b0e61a29279cb93cb2 to your computer and use it in GitHub Desktop.
Check whether a plugin is avticated on each sites in a network on WP VIP
#!/bin/bash
set -euo pipefail
app='@theApp.theEnv'
plugin='wordpress-seo'
echo "Checking whether plugin ${plugin} is activated on ${app}"
echo 'Fetching URLs'
urls=$(vip "${app}" --yes -- wp site list --fields="url" --format="csv" --quiet --no-color)
for url in $urls
do
if [ "${url}" == "url" ]; then
continue # skip the CSV header
fi
echo "Checking ${url}"
out=$(vip "${app}" wp --yes -- plugin list --name="${plugin}" --url="${url}" --status=active,active-network,dropin,must-use --skip-update-check --format=count --quiet --no-color)
if [[ ${out: -2} =~ ^1 ]]; then
echo "*** Plugin ${plugin} is activated on ${url}"
fi
done
echo 'Done.'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment