WP_Fatal_Error_Handler::display_error_template() WordPress Method

The WP_Fatal_Error_Handler::display_error_template() method is used to display an error template when a fatal error is encountered. This method is called by the wp_die() function when a fatal error is encountered. The error template is located at wp-content/themes/{theme}/error.php.

WP_Fatal_Error_Handler::display_error_template( array $error, true|WP_Error $handled ) #

Displays the PHP error template and sends the HTTP status code, typically 500.


Description

A drop-in ‘php-error.php’ can be used as a custom template. This drop-in should control the HTTP status code and print the HTML markup indicating that a PHP error occurred. Note that this drop-in may potentially be executed very early in the WordPress bootstrap process, so any core functions used that are not part of wp-includes/load.php should be checked for before being called.

If no such drop-in is available, this will call WP_Fatal_Error_Handler::display_default_error_template().


Top ↑

Parameters

$error

(array)(Required)Error information retrieved from error_get_last().

$handled

(true|WP_Error)(Required)Whether Recovery Mode handled the fatal error.


Top ↑

Source

File: wp-includes/class-wp-fatal-error-handler.php

	protected function display_error_template( $error, $handled ) {
		if ( defined( 'WP_CONTENT_DIR' ) ) {
			// Load custom PHP error template, if present.
			$php_error_pluggable = WP_CONTENT_DIR . '/php-error.php';
			if ( is_readable( $php_error_pluggable ) ) {
				require_once $php_error_pluggable;

				return;
			}
		}

		// Otherwise, display the default error template.
		$this->display_default_error_template( $error, $handled );
	}


Top ↑

Changelog

Changelog
VersionDescription
5.3.0The $handled parameter was added.
5.2.0Introduced.

The content displayed on this page has been created in part by processing WordPress source code files which are made available under the GPLv2 (or a later version) license by theĀ Free Software Foundation. In addition to this, the content includes user-written examples and information. All material is subject to review and curation by the WPPaste.com community.