GC_Fatal_Error_Handler::display_default_error_template()
最后更新于:2021-11-27 14:47:05
GC_Fatal_Error_Handler::display_default_error_template( array$error, true|GC_Error$handled)Displays the default PHP error template.
参数
- $error
-
(array) (Required) Error information retrieved from
error_get_last()
. - $handled
-
(true|GC_Error) (Required) Whether Recovery Mode handled the fatal error.
源文件
文件: gc-includes/class-gc-fatal-error-handler.php
protected function display_default_error_template( $error, $handled ) {
if ( ! function_exists( '__' ) ) {
gc_load_translations_early();
}
if ( ! function_exists( 'gc_die' ) ) {
require_once ABSPATH . GCINC . '/functions.php';
}
if ( ! class_exists( 'GC_Error' ) ) {
require_once ABSPATH . GCINC . '/class-gc-error.php';
}
if ( true === $handled && gc_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() && gc_recovery_mode()->is_initialized() ) {
$message = __( 'There has been a critical error on this website. Please check your site admin email inbox for instructions.' );
} else {
$message = __( 'There has been a critical error on this website.' );
}
$message = sprintf(
'<p>%s</p><p><a href="https://docs.gechiui.com/classes/gc_fatal_error_handler/display_default_error_template/%s">%s</a></p>',
$message,
/* translators: Documentation about troubleshooting. */
__( 'https://gechiui.org/support/article/faq-troubleshooting/' ),
__( 'Learn more about troubleshooting GeChiUI.' )
);
$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( 'gc_php_error_message', $message, $error );
/**
* Filters the arguments passed to {@see gc_die()} for the default PHP error template.
*
* @since 5.2.0
*
* @param array $args Associative array of arguments passed to `gc_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( 'gc_php_error_args', $args, $error );
$gc_error = new GC_Error(
'internal_server_error',
$message,
array(
'error' => $error,
)
);
gc_die( $gc_error, '', $args );
}