Oh no! You’ve just activated or edited a snippet, and some error in the code has made your whole site come crashing down into a white screen of death. And the worst of it is, you can’t access your admin panel to deactivate the offending snippet.
Thankfully, Code Snippets includes a built-in ‘safe mode’. This means that snippets will not execute while it is active, so you can access your site and deactivate the snippet causing an error. To activate safe mode, add the following line to your
wp-config.phpfile, just before the line that reads
/* That's all, stop editing! Happy blogging. */:
To turn safe mode off, either comment out this line or delete it.
Thanks Shea, you’re a life saver. A new snippet has crashed my site a couple of times lately and the only way I knew ~ until I found this little gem ~ was to drop both the snippets tables. Which of course I lost all my snippets. So many thanks for both the way it works and this solution for when it doesn’t.
It would be great if this info could be added to the FAQ page at http://wordpress.org/plugins/code-snippets/faq/ to make it a bit easier to find! I was just searching for it and couldn’t find it straight away, because I thought it would be on the FAQ. 🙂
It would be great if this info could be added to the FAQ page to make it a bit easier to find!
That’s a good idea; I’ll update the FAQ with the next plugin release.
Hi also crashed my site, i suspect a conflict somewhere. ended up having to disable plugin via ftp to get back in.
@halydris ~ *it* didn’t crash your site. You crashed it with a badly written code snippet. I do it quite regularly. Its what comes of cutting and pasting other people’s code sometimes.
All you have to do is FTP to your site and put
define('CODE_SNIPPETS_SAFE_MODE', true);in your wp-config.php file, just above where it says /* That’s all, stop editing! Happy blogging. */
And don’t forget to remove it once you fixed the snippet.
Why not add it to an admin interface so that wp-config.php doesn’t have to be edited?
Because if you can access the admin interface, than you can just go and deactivate the snippet. Safe mode is only really intended for when you can’t access the admin.
im using it on a multisite and it broke a secondary site i try the safe mode and it dosent work, i deactivated via ftp but i really like to fix this so i can use it pls help
i remove line 147 in code-snippets.php, run the plugin, (the admin is back on!)..remove bad snippet, put line 147 again.
There’s no need to edit the plugin files. Simply edit your
wp-config.phpfile, and add this line above
/* That's all, stop editing! Happy blogging. */
define( 'CODE_SNIPPETS_SAFE_MODE', true );
This will mean that no snippets will run on any of the sites. Then you can log in and disable the broken snippet. After everything is fixed, you can remove the line so snippets run again.
- The topic ‘What to do if a snippet breaks your site’ is closed to new replies.