A Lazy Developer’s Guide to Managing WordPress Updates

Brajesh Sachan
Reverberations
Published in
2 min readSep 16, 2020
Photo by Stephen Phillips — Hostreviews.co.uk on Unsplash

WordPress is one of the most popular Content Management Systems, used for blogs and websites among other things. It has thousands of plugins, including Embed-Iframe maintained by me, to extend the platform functionality. This also makes it the target of many security attacks. An effective mitigation practice against security attacks is to keep WordPress updated with the latest releases.

We can update WordPress by

  1. Providing FTP information in WordPress dashboard,
  2. Specifying FTP credentials in wp-config.php,
  3. Downloading WordPress release and updating manually,
  4. Using Subversion releases, or
  5. Configuring Direct File I/O method in wp-config.php
define('FS_METHOD','direct');

The method we are going to follow is using WP-CLI — Command Line Interface for WordPress.

Installing WP-CLI

curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar

To map wp command in Console

chmod +x wp-cli.phar
sudo mv wp-cli.phar /usr/local/bin/wp

Let’s check if it is working

wp --info

Installing WordPress

If we don’t have WordPress installed already, we can run the following command to install the latest version of WordPress in the current folder

wp core download

Since it is the first time installation, we need to configure the database access. So, first let’s connect to the database and create an empty database

mysql> create database <Database Name>

Configure WordPress to use this database

wp config create --dbname=<Database Name> --dbuser=<Database User> --dbpass=<Database Password>

and then navigate to the WordPress installation homepage in the browser and complete the set up.

and then navigate to the WordPress installation homepage in the browser and complete the set up.

Updating WordPress

  1. Updating current branch: wp core update
  2. Updating to a specific version: wp core update --version=<Version #>
  3. Updating to the latest nightly builds: wp core update --version=nightly
  4. Updating to the `trunk`: wp core update --version=trunk

Maintaining Plugins

  1. Installing a plugin: wp plugin install embed-iframe
  2. Activating wp plugin activate embed-iframe
  3. Updating: wp plugin update embed-iframe

Updating WP-CLI

We can update WP-CLI at any time by running

wp cli update

--

--