How to activate plugins for my WordPress sites from a remote server

If you’re only managing a few sites and you’re comfortable with the command line, you might want to look into wp-cli. With a little bit of scripting you can SSH into a remote server and do all manner of stuff like:

Enable plugins:
wp plugin activate acf-pro gravityforms wordpress-seo

Check the versions, activation and update availability:
wp plugin status

Update all plugins, optionally doing a dry run first:
wp plugin update --all --dry-run

Update all themes:
wp theme update

And all of the other stuff wp-cli enables like:

Back up the db:
wp db backup ../data-backup-directoy

Adjust posts:
wp post update 6 --post_author=1

Add or edit a user:
wp user create sally [email protected] --role=subscriber

Update options:
wp option update siteurl http://foobar.com

I manage most of my sites with it and a few bash scripts which consist of ssh in, do stuff, report back. Here’s a script I use to backup a remote site’s database, pull down a copy, load it into my local instance and reactive development-only plugins (that are disabled on the live site, natch):

#!/bin/bash

DATE=`date +%Y-%m-%d-%H%M`

# Backup the local db, just in case. Note that /data/local/* is .gitignored
wp db export ../data/local/$DATE.sql

# export live
ssh [email protected] "cd /path/to/wordpress/; wp db export /path/to/site/data/live-dump-$DATE.sql"

# pull it down
scp -Cp [email protected]:/path/to/site/data/live-dump-$DATE.sql /path/to/local/data/live-dump.sql

#import it
wp db import /path/to/local/data/live-dump.sql

# reactive local developer centric plugins
wp plugin activate debug-bar console debug-this debug-bar-extender debug-bar-hook-log

wp-cli is boss mode for WordPress. It even has tab completion on the command line. 🙂

HumanMade was working on some code to make remote management with it a first class citizen but it hasn’t been touched in a couple of years. I find that using ssh and either running commands manually or doing a little bit of scripting is all that I really need.