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:
- 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.
- 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.
Automatically Disabled snippets can be easily seen by using the filter at the top of the list of WPCode snippets in the WordPress admin panel (since version 2.0.11).
Additionally, when viewing the list of snippets, automatically-disabled snippets will have an icon next to their status toggle indicating that the snippet requires attention.
When this happens, we recommend enabling the error logging functionality in the WPCode Settings so that you can see more details regarding the error. This way, the next time a snippet throws a fatal error you will be able to see the details regarding the error easily directly in the admin interface. You can find more details regarding how to debug PHP errors in this article.
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:
https://example.com/wp-admin
, to access the safe mode you would visit:
https://example.com/wp-admin/?wpcode-safe-mode=1
.
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).