Help! My site broke! How can I fix it?

Avatar

By Shea Bunge

updated about 1 month ago

If you have just activated a snippet and now your entire site has crashed, leaving only a white screen or an error message, don't panic! We have a feature built just for this purpose, and it's called safe mode.

While safe mode is active, all snippets will be temporarily 'paused', allowing you to access your site and deactivate the snippet that is causing the error. Both of the methods described below will work, though generally the per-page method is easiest to enable.

Global Method

To activate safe mode, add the following line to your wp-config.php file, just before the line that reads /* That's all, stop editing! Happy blogging. */:

define( 'CODE_SNIPPETS_SAFE_MODE', true );

To turn safe mode off, either comment out this line or delete it.

Per-Page Method

You can enable safe mode on a per-page basis by appending &snippets-safe-mode=1 to end of the current page’s URL. While safe mode is active, all snippets will not execute, allowing you to login to your site and deactivate any snippets that are causing issues.

For example, to see the WordPress admin area in safe mode, you would change the URL from this:

https://yoursiteurl.com/wp-admin/admin.php?page=snippets

… to this:

https://yoursiteurl.com/wp-admin/admin.php?page=snippets&snippets-safe-mode=1

Or, for another example, if you were viewing a page on the front-end of your site, you could change a URL like this:

https://yoursiteurl.com/about-us/

… to this:

https://yoursiteurl.com/about-us/?snippets-safe-mode=1

This will only work if the current user is logged in as an administrator – other visitors will see your site as normal.

Bookmarklet

If you would like a shortcut to turn on safe mode for the current page, create a new browser bookmark and paste this in as the URL:

javascript:window.location.href+=(-1===window.location.href.indexOf('?')?'?':'&')+'snippets-safe-mode=1'

Did this answer your question?