Skip to content

Instantly share code, notes, and snippets.

@chrisjangl
Created June 21, 2023 17:38
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 chrisjangl/e7b10ea5bd1fd05ca5de3605987cb652 to your computer and use it in GitHub Desktop.
Save chrisjangl/e7b10ea5bd1fd05ca5de3605987cb652 to your computer and use it in GitHub Desktop.
WordPress plugin management
for plugin in $(wp --allow-root plugin list --update=available --status=inactive --field=name);
do
TITLE=$(wp --allow-root plugin get $plugin --field=title)
# look into how we can mark the date here. Maybe also only output final result
rm -r wp-content/plugins/$plugin/* && rmdir wp-content/plugins/$plugin
git add -A wp-content/plugins/$plugin
git commit -m "$(printf "delete plugin: $TITLE")"
echo "$TITLE -> $VERSION" >> ./reports/deleted-plugins.txt
done;
for plugin in $(wp plugin list --update=available --status=active --field=name);
do
TITLE=$(wp plugin get $plugin --field=title)
wp plugin update $plugin &&
VERSION=$(wp plugin get $plugin --field=version)
git add -A wp-content/plugins/$plugin &&
git commit -m "$(printf "update plugin: $TITLE to $VERSION")"
echo "$TITLE -> $VERSION" >> updated.txt
done;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment