Categories
Links of Interest

Article Roundup for 08.01.2014

Categories
Workflow

Learning html/css

My wife had sent me a text asking me for a list of html/css (aka Front-End Development) resources for someone she knew. It didn’t take too long to get a list together of things I use, but I thought I really should put this out for anyone else.

Free Courses:

Remember, Google is your friend. If you have a problem, chances are someone else has had the same issue, so Google the question you are asking. I tend to gravitate to these sites:

Paid Learning:

Podcasts:

Tools:

If you are looking for people to follow, check out my followers on Twitter (they are mostly Web people).

Feel free to comment if there are some great tools or resources that you think I missed.

Categories
Links of Interest

Article Roundup for 04.11.2014

Categories
Tutorials Workflow

Batch Upgrading WordPress installs on server

PSA: You shouldn’t just willy nilly upgrade your WordPress installs. It’s best to test your upgrade in a staging environment.

Every time a WordPress update comes out, I cringe having to update all the sites on my VPS server. I finally hunkered down today and got a shell script written to upgrade all WordPress installs on a server.

This solution will upgrade on one server, so If you have WordPress installs sprawled across multiple servers, you might want to look into a service like ManageWP.

The key is wp-cli

wp-cli is a command line tool that helps streamline WordPress tasks like upgrading, installing and configuring.

Installing wp-cli

Note: Right now, I haven’t successfully installed wp-cli globally, so for now, you will have to install wp-cli for each user on your server. Add a comment to this post if you have successfully done a global install.

Update: wp-cli changed their installation and you can now do a global installation.

Follow the wp-cli installation guide to install globally.

 

Creating the shell script

We’ll create a script that will upgrade wordpress, the database, all plugins, and all themes. You can edit this accordingly in the script below.

Create the file

$ vim push_all_wordpress_sites.sh

Paste the following into your new file:

#!/bin/bash

paths=(
  /home/USERNAME/path/to/wordpress
  /home/USERNAME/path/to/anothor/wordpress
)

for PATH_STRING in "${paths[@]}"
do
  :

  # regex to extract username from path
  re="\/home\/([^/]+)\/"
  if [[ $PATH_STRING =~ $re ]]; then

    # change to correct directory
    cd ${PATH_STRING}

    echo "Backing up" ${PATH_STRING} "Database..."
    /usr/bin/sudo -H -u ${BASH_REMATCH[1]} zsh -c '~/.wp-cli/bin/wp db export'

    # prompt user of upgrade
    echo "Upgrading: " ${PATH_STRING}

    # do wp-cli magic
    /usr/bin/sudo -H -u ${BASH_REMATCH[1]} bash -c '/usr/local/bin/wp core update'
    /usr/bin/sudo -H -u ${BASH_REMATCH[1]} bash -c '/usr/local/bin/wp core update-db'
    /usr/bin/sudo -H -u ${BASH_REMATCH[1]} bash -c '/usr/local/bin/wp plugin update --all'
    /usr/bin/sudo -H -u ${BASH_REMATCH[1]} bash -c '/usr/local/bin/wp theme update --all'

  fi

done

Note: This script assumes that your paths are full paths including the username folder.

As you’ll see in the “paths” variable in the top, you’ll want to change those placeholders to real paths on your server where your WordPress installs are located.

Executing the script

From here you just need to change the permissions of your new file:

$ chmod 755 push_all_wordpress_sites.sh

Then, you can run it anytime you want to upgrade all of your WordPress installs:

$ ./push_all_wordpress_sites.sh
Categories
Links of Interest

Article Roundup for 03.17.2014

Tvenge Design