Categories
Automate your Workflow English Uncategorized WordPress

Vagrant, WordPress, and Theme Development

I’ve been playing around with Vagrant recently. It really is a great tool for setting up development environments quickly and cleanly – no more local MySQL databases with 100 separate databases!

There are a few ways to solve this problem that many WordPress developers have:

  1. Use WordPress Multisite mode.
  2. Regularly clean your databases up and delete old ones.
  3. Use a common WordPress install, switching themes.
  4. Use Vagrant.

I’m going to be talking about the last option, Vagrant, in this blog post. I’ll list out a few reasons why Vagrant was attractive to me in the first place:

  • Isolation – this was appealing not only to reduce my database clutter, but also to be sure that the development and production environments were as similar as possible (within reason – of course).
  • Portability – another killer feature of Vagrant. Check out the repository, vagrant up, and you’re ready to go.
  • Coolness – don’t you love the idea of having contained, automatically managed environments for your projects? No? Well, I do.

Here’s what I came up with: vagrant-wp-theme-template.

It’s a template based on Underscores (_s), a template theme for WordPress themes. I’ve made two modifications: convert the CSS to SCSS, and the JavaScript to CoffeeScript. Grunt, an excellent automation tool, is used to compile the sources into CSS and JavaScript.

I’ve made the template compatible with _s, so just follow the instructions for _s regarding naming your theme, then the directions for getting your development environment set up. If you want to use an existing theme, just drop it inside the theme folder (and don’t forget to update the name in the Vagrantfile!)

I’m always open to new ideas and pull requests – please don’t hesitate to contribute!

Finally, this wouldn’t have been possible without the help of @miya0001‘s vagrant-chef-centos-wordpress, which this template is built off of. Thanks!

Categories
Automate your Workflow English

WordPress Install Script pt. 2

A week ago, I posted Automate your Workflow: Local WordPress Install with a script that helps you install new WordPress installations. I’ve been using it regularly, and have made some improvements:

  • Multi-language support (install a different language with the -l switch)
  • Nightly build support (-v nightly)
  • Multi-version (-v {code in the 'Version' column})
  • Arbitrary URL support (-u {URL})

As always, the script is available as a gist.

Categories
Automate your Workflow English

Automate your Workflow: Local WordPress Install

Lately, I’ve been pretty obsessed with streamlining my workflow, which means writing scripts (read: building tools to do stuff for me). They say that the best programmers are the laziest; I can’t vouch for being a great programmer, but I can proudly say that I am pretty lazy.

So, I’ve decided to start cleaning up my tools and posting them here as I make them. Use at your own risk!

We do a lot of WordPress sites, and downloading the latest WordPress install can be tedious. Navigating to http://wordpress.org/download/, clicking the “Download” link… Agh!! Too many clicks. Even if you’re awesome and use wget, it’s still a pain to move all those files around. So I made a script.

\#!/bin/bash

if [ -z "$1" ]; then
    echo "Usage: $0 "
    exit 1
fi

if [ -e "$1" ]; then
    echo "Pathspec '$1' exists."
    exit 1
fi

wordpresstemp="wordpress-latest-$RANDOM"
zipfile="$wordpresstemp.zip"

echo "Downloading latest WordPress..."

curl "http://wordpress.org/latest.zip" > $zipfile
unzip $zipfile -d "$wordpresstemp"/ > /dev/null
rm $zipfile

mv "$wordpresstemp"/wordpress "$1"

rm -r "$wordpresstemp"

echo "Created a new WordPress install in '$1'!"

Just save this in a file called wp_install, and put it in your $PATH directory of choice.

Also available as a gist.

Super simple:

$ cd webroot
$ wp_install new-wordpress

Done!