0

I am writing a maintenance mode plugin for my multisite setup. At its core its a very simple script that returns a maintenance mode page when a option is set. Now, I want to add cli commands to enable or disable it, but here's the catch:

When maintenance mode is enabled, any cli command just returns the html of the maintenance page.

Is there a way to circumvent this, by checking if the request came from cli or something?

In CLI it's possible to exclude plugins when executing a command, but that wont work as I need to disable the plugin which has the commands registered...

  • "When maintenance mode is enabled, any cli command just returns the html of the maintenance page." sounds like your maintenance logic is kicking in too soon. – kero Oct 16 at 9:41
  • Good point! Its hooked in init. What hook would you suggest using in stead? – Jurgen Oldenburg Oct 16 at 12:14
  • 1
    Have you checked which hooks other maintenance plugins use? init sounds way too early. I'd look up the order of which they are fired, template_redirect comes to mind as it is quite late but before any of the contents are loaded/displayed. – kero Oct 16 at 13:49
0

@kero the init hook proved to be way to early, thanks for the bright mind!

The template_redirect hook works just fine as you mentioned.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.