PHP Error Handling & Safe Mode

When using PHP or Universal snippets with WPCode you get automatic error detection. Error handling is done in multiple steps to help you avoid locking yourself out of your website.

The first layer of checks is when you activate a snippet. WPCode will execute the code when you try to activate it and if any errors are caught it will automatically prevent the snippet from being activated.

The second layer is used whenever the snippet is executed. If you activate a snippet that doesn’t throw an error right away (the syntax is correct) but it throws an error when executed later (for example, if it calls a function that throws an error) WPCode’s error protection system will catch the error and deactivate the snippet automatically.

When will a snippet be automatically deactivated?

Snippets will be automatically deactivated only when they will potentially prevent you from accessing your website’s admin area to manage the snippets.

There are two auto-insert locations that get automatically deactivated when an error is encountered:

  1. Run Everywhere – as the name suggests, snippets assigned to this location will be executed across the whole site and if they throw a fatal error it’s likely that you won’t be able to access the site admin so the plugin will automatically disable them if we catch an error.
  2. Admin only – as snippets assigned to this location will always be executed in the admin, the plugin will automatically disable them if an error is caught.

Safe mode

Even though WPCode attempts to always prevent you from locking yourself out of your site admin there are still situations when you might get locked out by running a snippet that doesn’t throw an error. These scenarios are very unlikely but in case you run into that or you just want to temporarily disable all the snippets on your site you can use the safe mode.

In order to start using the Snippet Safe Mode all you have to do is add the “wpcode-safe-mode” parameter to your admin url.

For example, if your site’s admin address is:, to access the safe mode you would visit:

Once you do that, the plugin will keep the Safe Mode on until you click the link in the notice to disable the safe mode so you can navigate your site easily.

Safe mode can only be enabled by users that can activate or deactivate snippets so you have to be logged-in to get safe mode enabled.

In case your site is no longer accessible and you are logged-out you can use the safe mode parameter on the login page (it will have no effect on other pages if you are not logged-in).