WP_Fatal_Error_Handler::display_default_error_template( array $error, true|WP_Error $handled )
- Since
- 5.2.0, 5.3.0
- Source
wp-includes/class-wp-fatal-error-handler.php:174
Displays the default PHP error template.
Description
This method is called conditionally if no 'php-error.php' drop-in is available. It calls wp_die() with a message indicating that the site is experiencing technical difficulties and a login link to the admin backend. The 'wp_php_error_message' and 'wp_php_error_args' filters can be used to modify these parameters.
Parameters
$errorarray- Error information retrieved from
error_get_last(). $handledtrue|WP_Error- Whether Recovery Mode handled the fatal error.
Hooks fired · 2
2 hooks fire while WP_Fatal_Error_Handler::display_default_error_template() runs, in this order:
- apply_filters( wp_php_error_message )filterline 224 (+50 into the body)
Filters the message that the default PHP error template displays.
- apply_filters( wp_php_error_args )filterline 235 (+61 into the body)
Filters the arguments passed to {@see wp_die()} for the default PHP error template.
Uses · 10
- wp_load_translations_early()Attempts an early load of translations.
- wp_is_recovery_mode()Determines whether WordPress is in Recovery Mode.
- __()Retrieves the translation of $text.
- is_protected_endpoint()Determines whether we are currently on an endpoint that should be protected against WSODs.
- wp_recovery_mode()Access the WordPress Recovery Mode instance.
- is_multisite()Determines whether Multisite is enabled.
- apply_filters()Calls the callback functions that have been added to a filter hook.
- wp_die()Kills WordPress execution and displays HTML page with an error message.
- wp_recovery_mode()::is_initialized()
- WP_Error::__construct()Initializes the error.
Used by · 1
- WP_Fatal_Error_Handler::display_error_template()Displays the PHP error template and sends the HTTP status code, typically 500.
Source
protected function display_default_error_template( $error, $handled ) { if ( ! function_exists( '__' ) ) { wp_load_translations_early(); } if ( ! function_exists( 'wp_die' ) ) { require_once ABSPATH . WPINC . '/functions.php'; } if ( ! class_exists( 'WP_Error' ) ) { require_once ABSPATH . WPINC . '/class-wp-error.php'; } if ( true === $handled && wp_is_recovery_mode() ) { $message = __( 'There has been a critical error on this website, putting it in recovery mode. Please check the Themes and Plugins screens for more details. If you just installed or updated a theme or plugin, check the relevant page for that first.' ); } elseif ( is_protected_endpoint() && wp_recovery_mode()->is_initialized() ) { if ( is_multisite() ) { $message = __( 'There has been a critical error on this website. Please reach out to your site administrator, and inform them of this error for further assistance.' ); } else { $message = sprintf( /* translators: %s: Support forums URL. */ __( 'There has been a critical error on this website. Please check your site admin email inbox for instructions. If you continue to have problems, please try the <a href="%s">support forums</a>.' ), __( 'https://wordpress.org/support/forums/' ) ); } } else { $message = __( 'There has been a critical error on this website.' ); } $message = sprintf( '<p>%s</p><p><a href="%s">%s</a></p>', $message, /* translators: Documentation about troubleshooting. */ __( 'https://wordpress.org/documentation/article/faq-troubleshooting/' ), __( 'Learn more about troubleshooting WordPress.' ) ); $args = array( 'response' => 500, 'exit' => false, ); /** * Filters the message that the default PHP error template displays. * * @since 5.2.0 * * @param string $message HTML error message to display. * @param array $error Error information retrieved from `error_get_last()`. */ $message = apply_filters( 'wp_php_error_message', $message, $error ); /** * Filters the arguments passed to {@see wp_die()} for the default PHP error template. * * @since 5.2.0 * * @param array $args Associative array of arguments passed to `wp_die()`. By default these contain a * 'response' key, and optionally 'link_url' and 'link_text' keys. * @param array $error Error information retrieved from `error_get_last()`. */ $args = apply_filters( 'wp_php_error_args', $args, $error ); $wp_error = new WP_Error( 'internal_server_error', $message, array( 'error' => $error, ) ); wp_die( $wp_error, '', $args ); }History
Introduced in 5.2.0. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
5.3.0
The
$handled parameter was added.from the docblock5.2.0
Introduced.from the docblock
About this page
- Parsed data
- Generated from the wordpress-develop 7.1.0 tag, from
src/wp-includes/class-wp-fatal-error-handler.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.