Skip to content

Instantly share code, notes, and snippets.

@chrisjangl
Last active July 13, 2022 12:13
Show Gist options
  • Save chrisjangl/9bd4f4f81a20d93e59392110a7ace1d8 to your computer and use it in GitHub Desktop.
Save chrisjangl/9bd4f4f81a20d93e59392110a7ace1d8 to your computer and use it in GitHub Desktop.
WP CLI script to update active plugins, and commit each update individually. 99% percent stolen from https://markjaquith.wordpress.com/2018/02/12/updating-plugins-using-git-and-wp-cli/, (ever so slightly) adapted to my own personal workflow
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