← All posts

Recover from a PHP Fatal Error with Scripts Organizer Safe Mode

A typo in a PHP snippet can take your whole site down with a fatal error. If you closed the Scripts Organizer editor before you noticed, you can't just go back and undo it. This short video shows how to trigger Safe Mode manually for the broken code block, so the site loads again and you can fix the code without FTP or deleting files.

Find the broken code block in the fatal error

You need to know which snippet caused the crash before you can switch it off. The PHP error message already tells you.

In the video the front end shows:

Fatal error: Uncaught Error: Call to undefined function aadd_filter() in …/wp-content/uploads/scripts-organizer/132.php on line 10

Scripts Organizer saves each code block as a file named after its ID in wp-content/uploads/scripts-organizer/. So 132.php means code block 132 is the problem. Here the cause is a typo on line 10: aadd_filter() instead of add_filter().

Trigger Safe Mode manually

With the ID, you can put that one block into Safe Mode and leave the rest of the site alone.

  1. Note the ID from the error message (here 132).
  2. Trigger Safe Mode manually with the Safe Mode link for that ID. The exact link is in the Scripts Organizer documentation.
  3. Go to WP Admin → Scripts Organizer and open code block 132 (in the video it's Add body class, a PHP block with Trigger location set to Everywhere).
  4. Fix the code and click Update.
  5. Click Disable Safe Mode in the top bar, then Update again.
  6. Visit the front end. The site loads normally.

Your visitors stop seeing the fatal error as soon as the bad block is in Safe Mode, and you can take the time to fix the actual code.

Get Scripts Organizer → dplugins.com