Information

This article was written on 08 Feb 2015, and is filed under Technical.

WordPress Development Offline

The most usual way to develop software is for the developer(s) to work on their personal computer, with a code repository mediating inputs from multiple developers, such as SVN or GIT. Even a solo developer might use a code repository to manage the code they are developing, to get reliable versioning and deployment tools.

While working on their local PC, the developer can test using a local webserver. In our case that is the WAMP server – Windows, Apache, MySQL and PHP.  The code is then committed to the repository (in our case github.com) and deployed from there to test and live webservers on the cloud.  One of the great advantages of working in this way for the developer is the ability to work offline, i.e. with no internet connection.  While the internet might seem to be ubiquitous, if you are on an aeroplane, or sometimes in a train in the country, you have no internet connection. Apart from lacking access to on-line documentation, working offline can be as productive as when you are in the office.

Enter WordPress which is increasingly providing cloud-based services such as checking for software updates, or providing site statistics. If you try to open WP admin pages without an internet connection, the software update checking process takes several seconds to time out. In wp-includes/update.php for example:

$timeout = 3 + (int) ( count( $plugins ) / 10 );

There are plugins and articles on stopping the update “nag” from appearing, but these don’t stop the checking, only the on-screen reminders.  After the timeout, WordPress gives an error which fills up the top half of your screen. All this makes off-line development unworkable.

Our solution was to prevent the checks from being carried out by adding the follwing code to our theme’s functions.php:


if ( CBDWeb_SUPPRESS_CHECK_UPDATES ) {
	add_action( 'in_admin_header', 'suppress_update_checks', 1 );
}
function suppress_update_checks() {
	remove_action( 'admin_bar_menu', 'stats_admin_bar_menu', 100 );
	remove_action( 'admin_bar_menu', 'wp_admin_bar_updates_menu', 40 );
}

To control this feature, so updates are checked on the production site, we use wp-config.php

define('CBDWeb_SUPPRESS_CHECK_UPDATES', true );