Created
April 4, 2016 17:53
-
-
Save mattsims/dda6061e7b74d824092c5a81ea18fcd5 to your computer and use it in GitHub Desktop.
Bash script to update and commit WordPress plugins using WP-CLI
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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