Skip to content

Instantly share code, notes, and snippets.

@mjot
Last active April 10, 2019 07:46
Show Gist options
  • Save mjot/45cb1e98b46b33b6015862c850f075de to your computer and use it in GitHub Desktop.
Save mjot/45cb1e98b46b33b6015862c850f075de to your computer and use it in GitHub Desktop.
update each wordpress plugin with wp-cli and commit each update with plugin name and version in commit message
#!/usr/bin/env bash
wp () {
command /usr/local/bin/php7.2.11-cli ~/wp-cli/wp-cli.phar "$@"
}
for plugins in $(wp plugin list --path='../html/' --update=available --fields=name,version,update_version --format=csv);
do
IFS=', ' read -r -a plugin <<< "$plugins"
if [ ${plugin[0]} = "name" ]; then
continue
fi
wp plugin update ${plugin[0]} --path='../html/' &&
git add -A ../html/wp-content/plugins/${plugin[0]} &&
git commit -m "Plugin update - ${plugin[0]} - ${plugin[1]} to ${plugin[2]}"
done;
@mjot
Copy link
Author

mjot commented Feb 6, 2019

The script is located in a scripts folder next to the Wordpress installation. That's why the --path option is used.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment