Skip to content

Instantly share code, notes, and snippets.

@mattsims
Created April 4, 2016 17:53
Show Gist options
  • Save mattsims/dda6061e7b74d824092c5a81ea18fcd5 to your computer and use it in GitHub Desktop.
Save mattsims/dda6061e7b74d824092c5a81ea18fcd5 to your computer and use it in GitHub Desktop.
Bash script to update and commit WordPress plugins using WP-CLI
#!/bin/bash -e
git stash
plugins=`wp plugin list --fields=name,title --format=csv`
printf %s "$plugins" | while IFS= read -r plugin
do
name=`echo "$plugin" | cut -d$',' -f1`
title=`echo "$plugin" | cut -d$',' -f2`
title="${title%\"}"
title="${title#\"}"
wp plugin update "$name" --quiet
if [[ `git status --porcelain` ]]; then
git add .
git commit -m "Update $title plugin to latest version."
echo "$title: Updated."
else
echo "$title: No update available."
fi
done
git stash apply
exit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment