Skip to content

Instantly share code, notes, and snippets.

@mitchelldmiller
Created January 2, 2019 22:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mitchelldmiller/e3ba3e2905be1f44d0f5f011fa98b1c7 to your computer and use it in GitHub Desktop.
Save mitchelldmiller/e3ba3e2905be1f44d0f5f011fa98b1c7 to your computer and use it in GitHub Desktop.
Update WordPress plugin on command line, from slug.
#! /bin/bash
if [ ! -z $1 ]; then
if [[ "$PWD" =~ "plugins" ]]; then
curl -OkLs https://downloads.wordpress.org/plugin/$1.zip
if [ -f $1.zip ]; then
if [ -d $1 ]; then
rm -rf $1
fi # if directory exists
unzip -qq $1.zip
rm -f $1.zip
if [[ `type -t wp` ]]; then
wp plugin list | grep $1
else
echo "Extracted files from $1.zip"
fi # if got wp-cli
else
echo "Error: plugin $1 not found"
echo "Usage: update_zip.sh [plugin slug]"
fi # if zip exists
else
echo "Error: run this script from plugin directory"
fi # pwd
else
echo "Usage: update_zip.sh [plugin slug]"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment