Created
January 2, 2019 22:52
-
-
Save mitchelldmiller/e3ba3e2905be1f44d0f5f011fa98b1c7 to your computer and use it in GitHub Desktop.
Update WordPress plugin on command line, from slug.
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 | |
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