WP_Fatal_Error_Handler::handle()

In this article

Runs the shutdown handler.

Description

This method is registered via register_shutdown_function().

Source

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

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

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

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

		$handled = false;

		if ( ! is_multisite() && wp_recovery_mode()->is_initialized() ) {
			$handled = wp_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.
	}
}

Changelog

VersionDescription
5.2.0Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.