WordPress Maintenance Mode Without a Plugin

Every so often someone asks a question in the WordPress IRC channel that sparks my interest, and in this case the core maintenance mode functionality was one of those questions. I’ve known for sometime that WordPress has it’s own maintenance mode functionality since core upgrades were added, however I had never really looked into the functionality. Hooking into this functionality is really quite simple and effective.

Start by creating a file in the root of your WordPress install (on level with wp-settings.php) called .maintenance. Note the preceding dot like a .htaccess file; in Linux this is considered a hidden file. In this file add the following code:

<?php $upgrading = time(); ?>

This code will basically cause the maintenance page to display until you remove the .maintenance file. In wp-settings.php there are 2 checks to see if it should display the maintenance page. First, it makes sure that the .maintenance file exists. Second, it checks that the current time minus the time specified by the $upgrading variable is less than 10 minutes. Using the code above will insure that it is always less than 10 minutes since time() - time() == 0. If you want it to display for a certain period of time you would want to use:

<?php $upgrading = 1234567890; ?>

For your usage you would want to replace 1234567890 with the unix formatted timestamp of the time minus 10 minutes at which you want the maintenance page to stop displaying.

For example if I wanted the maintenance page to stop displaying at November 14, 2013 at 20:13:00, I would really set the $upgrading variable to November 14, 2013 at 20:03:00. Notice the 03 instead of 13. In unix time this would look like 1384459380. And the code needed for the .maintenance file would be:

<?php $upgrading = 1384459380; ?>

Take note that if you use a specific time in the .maintenance file and you do not remove the .maintenance file, your users will see your site and not be affected, however in the admin you will see a notice stating, “An automated WordPress update has failed to complete – please attempt the update again now.” Deleting the .maintenance file will remove this notice.

I’m sure that this functionality could be wrapped in a plugin, or even better an option added to the core code in the admin. However, I am happy with just manually creating the file.

For information on modifying or styling the maintenance page see WordPress Maintenance Mode Without a Plugin Part 2.

WordPress Twitter Hash Tag Widget and the New Widget API

Recently I attended WordCamp Mid-Atlantic, and took notice of the area of the site that listed all of the Twitter status updates that included the #wordcampmidatl hash tag. In fact a number of people took notice of this feature and thought it was a great idea. Yesterday, Brad from WebDevStudios asked me what plugin was used on the WordCamp Mid-Atlantic site so it could be used on the WordCamp Chicago site, and without knowing of such a plugin I recommended several approaches to achieve the same thing.

I ended up, out of curiosity, writing the functional code to do it and handed it off to WebDevStudios so they could get it over to the WordCamp Chicago site owner. After handing off the code apparently both I and WebDevStudios began wrapping the code into a widget. I chose to take the route of using the new Widgets API that will be introduced into WordPress 2.8.

This gave me some quality time with the new Widget API which, I personally feel, is a great improvement for widgets in WordPress.

I have not yet requested hosting for this plugin on in the WordPress Plugin Repo. So for now the download will remain hosted on this site. For anyone curious about the new Widgets API feel free to download the plugin and poke around. If you have and comments or suggestions for this plugin please let me know! I have just recently started into the world of Twitter and know that with as popular as the service is that this could become a very useful plugin.

On a side note I have added some caching capabilities to the plugin so that in the event that the connection to Twitter fails, as it so often does, it will simply serve the cache from the last successful attempt.

Please note that as this plugin uses the new Widgets API introduced in WordPress 2.8 that it will require WordPress 2.8 to function.

Download Now!

Fast WordPress Function and Template Tag Lookups

If you are like me, then you are often referring to the function and template tag documentation on the WordPress Codex. My friend, Andy Stratton, got tired of having to open google, typing in the function name and then clicking on the link to the codex returned in the search results. To make his life easier he wrote WPLookup. WPLookup gives you a simple search box that will redirect you to the documentation for the function or if it doesn’t exist, redirect you to the WordPress.org search where you can see documents containing the function or text you are looking for.

To make the service even better you can integrate it into your web browsers search bar for even faster lookups.

I have taken his service one step further and written an IRC bot that is currelty sitting in the WordPress IRC Channel. To use this bot type something in the form of .codex get_pages and it will query WPLookup and return the resulting URL back to the channel.

See the following links for his release announcements about this new service:

  1. Find WordPress Function and Template Tag Documentation – Fast
  2. New WPLookup Features – Set WPLookup as a browser search engine