WordPress scripts & dev tools that save you time

Grab your toolbelt

Editor’s note: This post is part of our collection on managing multiple WordPress sites.

***

If you’re the one who gets your hands into the guts of WordPress websites, then you already know how to make the most of the Admin dashboard and convince themes to behave. When it comes to bending WordPress to your will, however, sometimes that’s not enough. You need to be able to do things that aren’t on the Admin dashboard and do the things that are there more efficiently. Elevate your game with these helpful WordPress scripts and dev tools.

Take command with WP-CLI

If you’re not using the WordPress command-line interface yet, it’s time to start.

What’s it good for?

It’s awesome for installing and updating the core, managing themes and plugins, performing a database search and replacing options, importing and exporting data, and more.

WP-CLI lets you perform the heavy lifting using efficient commands from your server’s command line.

You can also do many things that simply aren’t possible through the WordPress Admin interface.

If you don’t already have WP-CLI installed, follow these directions to get it up and running. Handy things you can do include:

Downloading the latest WordPress and creating a new installation:

Start by downloading the latest version of WordPress:

wp core download

Then create the wp-config.php file:

wp config create --dbname=”database_name” --dbuser=”database_user”

Once that’s done, run the installation:

wp core install --url="your_domain" --title="Blog Title" --admin_user="admin username" --admin_password="enter_your_password" --admin_email="enter_your_email

Check the URL. WordPress should be successfully installed.

Installing and activating a new plugin in one step:

wp plugin install myplugin --activate

Replace “myplugin” with the plugin slug (if it’s available in the WordPress.org plugin directory) or a direct URL to the plugin .zip file.

Checking the current status of the database to look for errors:

wp db check

Backing it up:

wp db export backup.sql

Installing theme unit test data:

This is a handy shortcut for theme developers and for loading placeholder content into a new site:

curl -O https://wpcom-themes.svn.automattic.com/demo/theme-unit-test-data.xml

wp plugin install wordpress-importer --activate

wp import ./theme-unit-test-data.xml --authors=create

rm theme-unit-test-data.xml

Finding all WordPress installs on the filesystem:

You will need to install the “wp find” package first:

wp package install wp-cli/find-command

Once that’s done, run the command to view all WordPress installs:

wp find ./

Regenerating thumbnails:

wp media regenerate --yes

View all existing roles:

wp role list

To remove a role:

wp role delete role_name

(Replace “role_name” with the name of the role you wish to delete.)

Batch your CLI commands for greater efficiency.

While the above WordPress CLI scripts and tools are simple but powerful commands on their own, you can also run CLI scripts to batch your tasks and save even more time.

Here’s an example script from Smashing Magazine for updating the core for multiple websites at once:

#!/bin/bash
 declare -a sites=('/var/www/wp1' '/var/www/wp2' '/var/www/wp3')
 for site in "${sites[@]}";
 do
 wp --path=$site core update
 done

In the first line, the sites you want to operate on are declared. Then a For loop is defined that operates on each site that you declared, performing a core update on it. You can modify this and other WordPress scripts to do all kinds of things simply by changing the command inside the Do loop.

A full list of WP-CLI commands is available on the WordPress Developer site.

Leverage WordPress theme frameworks

Do you have a favorite theme, but every time you install it you have to copy and paste the same code to add functionality you always use? What if you find a bug or security problem? Then you’ll need to update every instance theme, by hand. Theme frameworks can save you all of this trouble.

Theme frameworks use the parent/child abilities of WordPress to separate functionality and styling.

The core functionality is kept in the parent theme. Each child theme you create can have its own styling and customization. This makes it very easy to push out updates to functionality, such as security and bug fixes, to the parent theme, without interfering with all the customized styling you’ve put into the child.

Creating a child theme is as simple as making a folder for it in /wp-content/themes and adding a style.css for it. The style template references the parent theme. From there on, you make all your modifications to the child theme.

There are existing theme frameworks that include complete drag-and-drop capabilities or offer seemingly endless options and built-in functionality. These can get bloated though, and if you don’t need what they offer, a more barebones framework such as Genesis by StudioPress might better suit your needs. Most frameworks are commercial — you will have to fork over some money for them. However, given the headaches they can save, many developers find them well worth it.

Plug into productivity

You probably already have a well-curated collection of favorite plugins, but how many of those are for you, the developer, rather than to serve the end user? The plugins below are all about you — improving productivity, saving time, making your life easier.

User Switching

Isn’t it a pain to log out and log in as a different user with different permissions when testing sites? Often over and over again? Trim the process down to a click with this handy plugin.

String Locator

You’re working on a site, and you notice a string of text that you want to change. It seems to be hardcoded somewhere, but where? This plugin can find it for you. Easily search through the files that make up the site, even the WordPress core. Pick your choice from the results and edit it right in your browser. Problem solved.

WordPress Reset

When you need to start over, at least with the database, this plugin resets the WordPress database back to its defaults. It deletes all content and customizations. It does not delete any files.

WProller

Do you have a regular set of plugins or themes you install when you set up a new site or test site? Instead of adding them manually one at a time, use WPRoller to create an installation bundle that lets you add plugins and themes to your installer zips and customize your installation. You can also configure your default setup to do things like remove the ubiquitous hello Dolly plugin and sample pages.

Let WordPress scripts and dev tools do the heavy lifting

On the surface, WordPress and WordPress scripts look so simple, but underneath is a mass of loops, hooks and potential complications that take time to manage and expertise to master.
Tools like the WP-CLI interface, theme frameworks, and developer-focused plugins exist to make that job easier.

Why not let them take some of the heavy lifting off your hands?

Image by: jesse orrico on Unsplash