GC_Fatal_Error_Handler::handle()

最后更新于:2021-11-27 14:52:19

GC_Fatal_Error_Handler::handle()

Runs the shutdown handler.

源文件

文件: gc-includes/class-gc-fatal-error-handler.php

	public function handle() {
		if ( defined( 'GC_SANDBOX_SCRAPING' ) && GC_SANDBOX_SCRAPING ) {
			return;
		}

		// Do not trigger the fatal error handler while updates are being installed.
		if ( gc_is_maintenance_mode() ) {
			return;
		}

		try {
			// Bail if no error found.
			$error = $this->detect_error();
			if ( ! $error ) {
				return;
			}

			if ( ! isset( $GLOBALS['gc_locale'] ) && function_exists( 'load_default_textdomain' ) ) {
				load_default_textdomain();
			}

			$handled = false;

			if ( ! is_multisite() && gc_recovery_mode()->is_initialized() ) {
				$handled = gc_recovery_mode()->handle_error( $error );
			}

			// Display the PHP error template if headers not sent.
			if ( is_admin() || ! headers_sent() ) {
				$this->display_error_template( $error, $handled );
			}
		} catch ( Exception $e ) {
			// Catch exceptions and remain silent.
		}
	}