I have a WordPress driven website and I need to be able to close the site at a moment’s notice. I need some help to work out a way to do that whereby a php script will check a remote file (xml, php, whatever) hosted on another server to check for a variable (ie. website=closed). If variable is present then close the site with a message such as “Website temporarily closed”. Does anyone have any tips on how to go about doing this, or know of any resources I can access.
WordPress knowledge = good / PHP knowledge = beginner
Thanks 🙂
You could install a maintenance mode plugin, then within that code find the trigger to turn on maintenance mode, then inject a function (curl, for instance) that checks the other site for your variable. For example, if you choose to use the plugin mentioned above, in
maintenance-mode.phpline 46 checks to see if you’ve turned on maintenance mode:you can add a function to
maintenance-mode.phpthat checks for your variable:then assuming your external site returns
onfor maintenance mode on, andofffor maintenance mode off, you can add to themaintenance-mode.phpifstatement like so:this will check to see if either maintenance mode has been turned on from within the wordpress admin, or your external site; in either case it will activate maintenance mode.
EDIT:
Actually the above will not work the way (I think) you are looking for.
The only reason I can think of to have an external var somewhere shut down your site is so that you can turn off multiple sites at the same time. Is this close?
If that is the case, it would make more sense to have a script on the external site that does a
GETto your WP installs that puts them into maintenance mode. To do it from within the site that runs the WP install, you’d need to run a script that checked the external site evernseconds. This would create a lot of overhead, and could possible be unreliable.A better solution would be to have a script on the external site that when accessed would do a get to a
URLon your WP install that would initiate maintenance mode.