跳到内容

Safe Mode – Fatal Error Recovery

v1.1.2

Naveen Goyal · 2026年6月19日 上架

Recover from fatal errors: detects the plugin or theme that crashed your site, disables it and restores access to wp-admin.

正在使用
10 以下
评分
暂无
累计下载
791
最近更新
2026年11月24日
需要 WordPress 6.5+已测试到 7.1.5PHP 8.0+

贡献者

截图

Admin notice shown after automatic recovery — confirms what failed and what action was taken.
Admin notice shown after automatic recovery — confirms what failed and what action was taken.
Error Logs — filterable table of every fatal error with source, file, line, and recovery status.
Error Logs — filterable table of every fatal error with source, file, line, and recovery status.
Recovery History — chronological record of every recovery action and its outcome.
Recovery History — chronological record of every recovery action and its outcome.
Settings — toggle recovery, auto-disable, theme fallback, email notifications, and retention controls.
Settings — toggle recovery, auto-disable, theme fallback, email notifications, and retention controls.

NaveenCodes Safe Mode helps restore access after fatal plugin or theme crashes. It detects fatal PHP shutdown errors, identifies whether the source is a plugin or theme, performs the configured recovery action, records detailed logs, stores recovery history, shows persistent admin notices, and emails administrators.

Plugin page and step-by-step guides: naveencodes.com/safe-mode

The plugin does not modify, rewrite, or repair user code. Version 1 is focused only on detection, disabling, recovery, logging, and notification.

Version 1 Architecture

  • Namespace: NaveenCodes\SafeMode
  • Prefix: ncsm_
  • Text domain: naveencodes-safe-mode
  • Bootstrap: naveencodes-safe-mode.php
  • Autoloading: lightweight PSR-4 style autoloader for includes/
  • Composition root: includes/Core/Plugin.php
  • Service boundaries:
    • Core: activation, deactivation, settings, plugin bootstrapping
    • Database: custom table schema
    • Recovery: shutdown detection, source detection, queueing, plugin/theme recovery, notifications
    • Logging: error logs and recovery history persistence
    • Admin: dashboard, logs, history, settings, notices, coming soon UI
    • Helpers: focused WordPress helper utilities
    • Interfaces: shared service contracts

Database Schema

wp_ncsm_logs
  • id
  • timestamp
  • error_type
  • error_message
  • file_path
  • line_number
  • source_type
  • source_name
  • action_taken
  • recovery_status

    wp_ncsm_recovery_history

  • id

  • timestamp
  • source_type
  • source_name
  • recovery_action
  • recovery_result

Recovery Workflow

  1. Register a shutdown function early on plugins_loaded.
  2. Inspect error_get_last() on shutdown.
  3. Continue only for fatal, parse, compile, core, user, or recoverable fatal errors.
  4. Detect source from the error file path:
    • wp-content/plugins/... becomes a plugin source.
    • wp-content/themes/... becomes a theme source.
    • Anything else is stored as Unknown Source.
  5. Check recovery queue attempts for the source.
  6. If the source is a plugin and plugin auto-disable is enabled, deactivate the faulty plugin.
  7. If the source is the active theme and theme recovery is enabled, switch to the configured fallback theme.
  8. Log the error and recovery action.
  9. Store recovery history.
  10. Add a persistent admin notice.
  11. Send an administrator email when enabled.

WordPress Hooks

  • plugins_loaded boots the plugin.
  • register_shutdown_function() detects fatal shutdown errors.
  • admin_menu registers the admin pages.
  • admin_enqueue_scripts loads admin assets.
  • admin_notices renders persistent recovery notices.
  • admin_post_ncsm_save_settings saves settings.
  • admin_post_ncsm_export_logs exports logs.
  • admin_post_ncsm_dismiss_notice dismisses recovery notices.

Admin Pages

  • Dashboard: protection status, statistics, recovery workflow, and theme snapshot status.
  • Error Logs: fatal error log table, filters, and CSV export.
  • Recovery History: source, action, result, and timestamp.
  • Theme Snapshot: take, replace, restore, or delete the active theme backup.
  • Settings: recovery toggles, notifications, fallback theme, retention, maximum attempts.
  • Coming Soon: planned feature previews only.

Settings

  • Enable Recovery
  • Enable Plugin Auto Disable
  • Enable Theme Recovery
  • Enable Email Notifications
  • Fallback Theme Selector
  • Log Retention Period
  • Maximum Recovery Attempts

Coming Soon

The following features are displayed as UI-only cards and are not implemented in Version 1:

  • Automatic Rollback
  • Update Sandbox Testing
  • Code Snippet Protection
  • AI Error Analysis
  • Slack Notifications
  • Cloud Backups
  • Uptime Monitoring
  • One Click Restore

Security

Version 1 uses capability checks, nonces, sanitization, escaping, WordPress database APIs, and prepared SQL for dynamic values. It performs no tracking, no hidden data collection, no remote code execution, and no unsafe file rewriting.

Need custom WordPress work?

This plugin is free, with no paid version, and it stays that way. If you need something it doesn’t do, such as a custom plugin, an integration or help with a broken site, I also take on custom development work for businesses and agencies: naveencodes.com

Plums

按场景查找 WordPress 插件。安装量、评分和兼容版本来自官方目录。

导航

说明

WordPress 是 WordPress Foundation 的商标。本站与 WordPress Foundation、Automattic 没有隶属关系。这里不托管插件文件,下载和安装以 WordPress.org 上的页面为准。

© 2026 Plums