Illustrations for the article

How to kill the website when theme is missing or broken

Security, Snippets

You might easily imagine the following situation. You have a tailor-made website with tons of custom functionality and part of them is related to the active theme. Memberships, showing/hiding part of the content based on user role, etc. The very last thing you want is to display raw texts when something goes wrong.

The default WordPress behavior is “smart”. Even though it knows that the theme is broken, it just tries its best and shows the content as it is and just simply doesn’t load styles and functionality. That might be great if you have recipes or sort of public information there, but if you don’t, you won’t be happy at all.

For that case, I’ve written a tiny snippet that you could upload to mu-plugins folder, which means that nobody can’t turn it of accidentally.

Go ahead and modify what you need – check if a plugin is active or if the user is logged in as an admin who tries to debug.

Did you use the snippet somewhere? Let me know in the comments or tag me on Twitter @vyskoczilova.

Leave a Reply

Your email address will not be published. Required fields are marked *