Podcast Episode

286 – Hiding Your Site with Maintenance Mode

Announcements

Is there a plugin for that?

With more than 50,000 plugins in the WordPress repository, it’s hard to find the perfect one. Each week, I will highlight an interesting plugin form the repository.

For more great plugins, download my 50 Most Useful Plugins eBook.

Spacer adds a spacer button to the WYSIWYG visual editor which allows you to add precise custom spacing between lines in your posts and pages.

Hiding Your Site with Maintenance Mode

Why Maintenance Mode?

  • WordPress or Plugin Updates
  • Leading up to a live launch
  • Launching a brand new website

How to put in Maintenance Mode

  • Let WordPress handle it

Briefly unavailable for scheduled maintenance. Check back in a minute.

  • Manually put in maintenance mode with code in functions.php
// Activate WordPress Maintenance Mode
    function wp_maintenance_mode(){
        if(!current_user_can('edit_themes') || !is_user_logged_in()){
            wp_die('<h1 style="color:red">Website currently under Maintenance</h1><br />We are performing routine maintenance. We will be back online soon.');
        }
    }
    add_action('get_header', 'wp_maintenance_mode');

How to remove Maintenance Mode

Sometimes WordPress’ maintenance mode gets stuck. If this is the case, you will need to log into your server via FTP and remove the .maintenance file.

Or if you used a plugin, you can deactivate the plugin.

Thank You!

Thank you to those who use my affiliate links. As you know I make a small commission when someone uses my link and I want to say thank you to the following people. For all my recommended resources, go to my Resources Page

Call To Action

  • Consider using a maintenance mode plugin the next time you perform updates to your website

Full Transcript

Business Transcription is provided by GMR Transcription.

In today’s episode, we will be talking about how to hide your website with maintenance mode right here on your website and junior podcast episode #286. Hello, everybody. Welcome back to another episode of your website and junior podcast. My name is Dustin Hartzler. Today, I’m coming to you live from, well, live in recording; but I am recording from Spain. I am in Spain for the next few weeks with my wife, daughter, and we brought my sister-in-law as well to watch my daughter during the day. My wife is teaching a study abroad course. So we’re in Valencia, Spain. I’m trying my best to learn as much Spanish as I can. I’m recording the podcast episodes for the next few weeks out of a co-working space. So there may be a little extra background noise. I will do my best to try to take that out in post-processing and what not.

These episodes in the next five weeks will probably be just a little bit shorter just based on everything that’s going on trying to get into the recording room. I’m calling the conference room that I’m using at 9:00 am my recording room mainly because there is nobody else here. Nobody in Spain really gets up super early. So I’m in here and recording this quickly. Actually, I recording it on Wednesday morning, and it will still go out Wednesday morning regular time in the United States. So today, we’re going to dive in and talk about maintenance mode, but first I’ve got a couple of announcements or a couple of fun things to talk about. I’ve got a plug-in for you. Then, we’ll get into the bulk of the show. Okay. The first thing I want to talk about today is a neat article found over on wordinpress.com. It’s talking about the hashtag wp reviews in real life.

If you look up that hashtag, you’ll find some very funny tweets that are quite hilarious actually. Some of them are just funny because your putting kind of Word Press into perspective of real life things that you would give five star reviews or one star reviews for. It’s just funny because people expect so much out of a free plug-in, or they leave these bad reviews when it doesn’t do what it says. Like one is this hammer is decent for hammering nails, but it just breaks screws if you try to hammer them. One star. #wpreviewsinreallife. Hotel was clean. Nice bed. Had to pay an extra $30.00 for room service. One star. #wpreviewsinreallife. If you need something funny and something humorous for a little bit over break today, go ahead and check out wpreviewsinreallife the hashtag and on Twitter.

Here’s another one. I got a free dishwasher. It washes my dishes, but it doesn’t clean my clothes. One star. Amazing E-commerce solution for Word Press. Best shopping experience ever. Inability to accept cash online. One star. So really funny. Lots of really cool things is the #wpreviewsinreallife.com. So check that out. The other thing that I want to share with you is there is a new prototype for the new plug-in directory. So the Word Press media team is publishing prototypes in the plug-in directory of a redesign. They’re working on just making it easier to just find plugins and doing some really cool things. This article came from WP Tavern. So there is a link in the show notes for it. It basically is a big, you know, you come to the plug-in page. The first thing you see is search box. Then, it has some popular plugins.

It highlights trending plugins, and it has beta plugins which is kind of nice. I think these beta plugins are the ones that are being beta tested for the next version of Core and whatnot. So if you’re interested in seeing what that looks like, go ahead and check out the article over on WP Tavern, and there’s a link in the show notes for episode #286. Okay. Another thing I want to share with you today when it comes to plugins is there’s a lot of plugins out there. More than 44,000 plugins in the word press repository. This one is a neat one that I’ve never seen before and never even thought of before. But it is called Spacer. It gives you a spacer button in the WYSIWYG editor so you can add precise custom spacing between lines in your post and pages. So if you ever tried to add spacing between paragraphs in Word Press, it’s kind of difficult.

You have to usually create a div tag, then you have to set a style. You have to say the height. So that’s kind of annoying if you ever want to put a line other than just a regular HR which is HGML tag. Those are pretty difficult. So in this version of Spacer version three, you can actually go in and create fancy divisors. You can set them on a page by page basis, or you can do site wide. It is a plugin that has more than 100,000 downloads. It was just updated a few hours ago. So if you’re interested in some along those lines, I’d definitely recommend checking out the plugin called Spacer on Word Press Repository. All right. Let’s go ahead and talk about hiding your website with maintenance mode. This is something that I used to never be a big fan of maintenance mode. It’s like somebody is launching a website for the very first time.

They’ve got it behind a maintenance mode wall when they don’t have any visitors anyway. So what is the reason for doing this? I think maintenance mode is a great thing. I think it does justice to keep your site hidden when you’re making updates and changes and doing things. I don’t think it necessarily needs to be done with brand new sites. If you’ve never launched a site, I don’t necessarily think you need a maintenance mode. But if you are doing some updates on a live site, I think maintenance mode is really, really cool. I think that you would use maintenance mode for several different reasons for a live site. Maybe if you were updating Word Press, the plugins, or some sort of regular updates like that. Maybe you could use a maintenance mode plugin if you are doing a launch of a brand new website that’s a new product that’s coming.

You know, you’re kind of building the hype. You’re ready to launch something new. Or maybe if you’re launching a brand new website, you might want to use a maintenance mode temporarily. So those are several different reasons you would use a maintenance mode. If you’re launching a brand new website, you may just need that maintenance mode for a couple of hours as you transfer the site from your development server to your live server. So the question is how do you put your site into maintenance mode? I guess let me define what maintenance mode is. It’s basically a static page that says … it’s kind of like a coming soon page or briefly undergoing maintenance. It’s basically that. It just puts your entire sight behind this one page. So if they go to any page within your website, it will re-direct them to this page that says I’m sorry.

We’re currently doing maintenance right now. That’s the premise of a maintenance mode plugin. Now, people use maintenance mode plugins for a lot of things. Like I said earlier, they use it when they’re leading up to a launch. If they are temporarily taking their site down for a little while. If they have moved their website to another location, you can use maintenance mode plugin. You can do it with a lot of things. The maintenance plugins … how they normally work is … I guess we’ll get to that in just a second. How to put it in maintenance mode? So the very first way to do it is to just let Word Press handle it. This is specifically only if you’re updating Word Press core files, updating any plugins, or updating any themed files. They will automatically create a doc maintenance file, put that into your root directory of your Word Press installation.

It will say briefly unavailable for scheduled maintenance. Check back in a minute. That message is only up there for a few seconds or a minute at most. This happens every time you update a plugin whether you recognize that or not. That’s how Word Press puts things into a maintenance mode. Another thing you could do is put a little bit of code inside your functions.php file. There’s a link in the show notes. The actual code is in the show notes. You can go ahead and see that, and see what that looks like. But it’s basically five lines of code that is going to activate a maintenance mode for your website. It basically just is creating a static html page. It basically will give you the text or the code that I’ve added just gives you the ability to put an H1 style red and just says website under maintenance.

Then, it gives another snippet underneath it and says we’re just performing a scheduled update or routine. We’ll be back online shortly. So you can just put that in there and that will display for every user except for admin which is nice because you don’t want … you want to be able to see what’s going on if your launching something brand new. Like you want to be able to see does your new sight work? Does your plugin work? Whatever that is. As long as you’re logged in, you’ll be able to see your live site. So that’s pretty nice. The other way to put it into a maintenance mode is using a maintenance mode plugin. There’s dozens and dozens of these in the Word Press Repository. A couple of them … I put a link in the show notes for a few of them.

The main reason you would want to use a maintenance mode plugin is because the fact that maintenance mode plugins give you the ability to integrate with your email newsletter subscription. So a lot of times people like to put countdowns on their website and say this site is launching if you’re doing a launch. This site is launching in 24 hours. Or this launch is 36 days or whatever that is. Then, you can say sign up to get more information. You can put them automatically on your email newsletter list. So a lot of plugins will give you that ability to add that functionality. You can add … with the plugins they make it really easy to add a background, a responsive background, integrate social media. You know, put your social icons on there. Put the countdown timer, and things along those lines.

The other thing that is nice with some of these maintenance mode or coming soon plugins, you can search for either of those terms in the Word Press Repository. Some of them will allow you to use this for your clients. So they will just have to enter a password. It’s going to automatically prompt them for a password to be able to see. This is really great for if you are launching this and you just want your clients be able to see this. And you know your clients are the only ones that are going to this website. Maybe it’s a brand new website, but your client doesn’t want anybody to see it until it’s officially done. Then, you can put up this coming soon page. Then, they can enter just a password. So you don’t have to create them a username and password. Just a password for them to login. So that’s pretty nice as well. There’s tons of these plugins out there.

Like I said, you can just search for coming soon or maintenance mode on the Word Press Repository. Now maybe you’ve got your site all ready. We’ve put up the maintenance mode plugin. I see this as a very good method if you are updating a live site, especially if you have done some database work on your development server. Obviously your website has changed. If you’re taking orders or if you’ve got blog comments or something, like it’s going to take a little while to merge. Both your development changes and your live changes, so you’ll want to actually take your site down for a brief moment while you get all that stuff merged together. If you are taking your development data and overriding your live database, then you’re going to lose any sale, any share, like anything that’s happened since you’ve downloaded that database. So it’s kind of a tricky process.

There’s not really a good way to do it. It’s a lot of manual checking go back and forth. So that would be probably one of the biggest reason I would take a live site, put it into a maintenance mode for an hour or two hours whatever that is. Make sure that no extra sales, no extra comments, and things can be made while you’re making these upgrades and your changes. It probably goes without saying, but probably doing this at a time when you don’t have a lot of traffic. Maybe if your website and sales, you know, you get the majority of your sales between 8:00 and 5:00, 8:00 am and 5:00 pm; it’s probably best at 6:00, 7:00, 8:00, 9:00, or 10:00 pm or early in the morning. I would probably recommend putting it in this mode late at night in case it takes a long time. Then, you might have to stay up all night and get everything fixed and taken into consideration.

Maintenance mode also gives you an opportunity to like everything will just kind of pause. So if you have to take some time to figure out what’s going on on the website, you don’t want more sales coming in. Maybe you’ve got – I keep thinking sales, but that’s just the thing that I think of these days with woo commerce and helping people with woo commerce all day. Maybe there’s some problem with the plugin, and you’re not getting your payments properly or it’s giving you some sort of error. It may be best to put it into maintenance mode. You turn on one of these plugins and just say we’re experiencing some difficulties. Then, you start doing some testing. You don’t have hundreds of people that you have to get in contact with that had failed payment methods or whatever.

So those are some things to think about when it comes to putting things into maintenance mode. A lot of times with woo commerce support, we do get people that have their websites in maintenance mode that give us a password or a username and credentials. Then, we can go in and just see what’s going on because we are an admin. So the next thing is once we’re done with our work, we’ve got to take it out of maintenance mode. How do we do that? Well, if we’ve just used the Word Press maintenance mode, most of the time it just goes ahead and works. Your plugin is updated. The doc maintenance file is deleted from your server. Then, you can go ahead and just restore your normal activity. Sometimes it gets stuck. I’ve had this happen to me maybe a handful of times in the last five or six years that the doc maintenance file doesn’t get removed.

It’s just kind of stuck there. So you have to actually go in to your web post. You can do this via the C panel or the ftp. You have to look for a hidden file called doc maintenance. You just go in there and just delete the file. It’s not going to hurt anything. You just delete it. Once it’s deleted, your site will be back online as normal. If you are using the bit of code that I put in the functions@phpfile, you can just go ahead and remove that code. Your site will be back online. Or you take the plugin that you’re using and just deactivate that plugin. Now, if this is something that regularly that you do, you take it in and out of maintenance mode a few times a month or few times a year, you may want to just keep that plugin around. Otherwise, you can go ahead and remove that plugin from the Word Press Repository … not from the Repository.

Obviously, you want to remove it from your plugin directory and just install it the next time you do it. I know that I don’t necessarily have a like a maintenance plugin always saved because I know that when I need it for a longer period of time, a few hours or whatnot, I can just download one from the Word Press Repository and get things all set up. So wrapping up, there’s a lot of different reasons you could use a maintenance mode plugin. You don’t necessarily just have to use it when you’re doing updates to core or plugin, but it may be a good tactic if you want to make major changes on your website. If you need to merge some changes that you’ve made to your database on your local environment and you to make that live, that would be another good place to use Word Press or the Word Press maintenance mode.

So with that I am going to wrap up. This is, like I said, Dustin coming to you from Spain. Next week, I’ll have another great episode for you. That’s it. We’ll talk about soon. Take care. Bye-bye.

For more great Word Press information, head on over to your websiteengineer.com

Leave a Reply