Skip to content

Instantly share code, notes, and snippets.

@stevegrunwell
Created September 9, 2015 19:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stevegrunwell/e8744152e73fdb7f3053 to your computer and use it in GitHub Desktop.
Save stevegrunwell/e8744152e73fdb7f3053 to your computer and use it in GitHub Desktop.
Upgrade WordPress plugins via WP-CLI one at a time, committing the results to Git as you go
function wp-upgrade-plugins() {
UPDATES=`wp plugin list --update=available --fields=name,title,update_version --format=csv`
i=1
while IFS="," read -r slug name version
do
test $i -eq 1 && ((i=i+1)) && continue
echo "Upgrading $name to $version..."
wp plugin update $slug &&
git add -A wp-content/plugins/$slug &&
git commit -m "Upgraded $name to $version"
done <<< "$UPDATES"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment