WordPress.org

Ready to get started?Download WordPress

Forums

Code Snippets
What to do if a snippet breaks your site (11 posts)

  1. Shea Bunge
    Member
    Plugin Author

    Posted 1 year ago #

    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.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.

    http://wordpress.org/extend/plugins/code-snippets/

  2. Terence
    Member
    Posted 10 months ago #

    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.

  3. GermanKiwi
    Member
    Posted 9 months ago #

    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. :)

  4. Shea Bunge
    Member
    Plugin Author

    Posted 9 months ago #

    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.

  5. halydris
    Member
    Posted 9 months ago #

    Hi also crashed my site, i suspect a conflict somewhere. ended up having to disable plugin via ftp to get back in.

  6. Terence
    Member
    Posted 9 months ago #

    @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.

  7. Dave Navarro, Jr.
    Member
    Posted 8 months ago #

    Why not add it to an admin interface so that wp-config.php doesn't have to be edited?

  8. Shea Bunge
    Member
    Plugin Author

    Posted 8 months ago #

    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.

  9. pacmanmx
    Member
    Posted 7 months ago #

    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

  10. pacmanmx
    Member
    Posted 7 months ago #

    fix it..
    i remove line 147 in code-snippets.php, run the plugin, (the admin is back on!)..remove bad snippet, put line 147 again.

  11. Shea Bunge
    Member
    Plugin Author

    Posted 7 months ago #

    There's no need to edit the plugin files. Simply edit your wp-config.php file, 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.

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic