mochahochabeachside.com

wordpress

Auto-install of WordPress Theme from CLI

by on Mar.25, 2010, under Blog, Scripts, wordpress

If you're like me, and you still like to install your WordPress themes from the command line (or you were 3/4 asleep and forgot WordPress now has a nice, easy-to-use auto-installer built into the admin interface), you know it can be a pain.  You have to download the file, unzip it, make sure it's right, delete the archive, chwon the files, etc...  It can be a pain.

So, I created a nice little script to take care of all of that.  wpthemeget will take a download URL from the WordPress Themes directory (in the format of http://(www.)wordpress.org/extend/themes/download/themename.ver.zip (or .tar.gz, or .tgz)), and will download, unarchive, chown, and remove the downloaded file, with no muss or fuss...  The output?:

root@fyre [.../wp-content/themes]# wpthemeget http://wordpress.org/extend/themes/                                        download/motion.1.0.4.zip
Downloading theme motion.1.0.4.zip...
Theme is a zip archive...
Unzipping... [COMPLETE]
...Removing downloaded archive file... removed `motion.1.0.4.zip'
...Chowning files... [COMPLETE]
...Installation Complete!

No muss, no fuss. The only caveat is that you have to be in your themes directory when you run it.  Future versions probably won't have this requirement, but hey, I hacked this out when I was barely awake, on heavy medication, and repeatedly falling asleep at the keyboard.  At one point, I had to delete something like 40 lines of "zzzzzzzzzzz......" because I fell asleep with my finger on the key.  Fortunately, vi treated it as all one paragraph so '<esc> dd' did the job.  The code for this little script is after the break.  Grab it, chmod it to exec, and drop it in /usr/local/bin, and it'll be good to go anywhere on your system, for all your blogs.  Happy blogging!

(continue reading...)

Leave a Comment :, , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!

Visit our friends!

A few highly recommended friends...