Changeset 44624 for trunk/src/wp-includes/class-wp-shutdown-handler.php
- Timestamp:
- 01/16/2019 03:20:04 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/class-wp-shutdown-handler.php
r44623 r44624 123 123 * 124 124 * A drop-in 'php-error.php' can be used as a custom template. This drop-in should control the HTTP status code and 125 * print the HTML markup indicating that a PHP error occurred. Alternatively, {@see wp_die()} can be used. Note126 * that this drop-in may potentially be executed very early in the WordPress bootstrap process, so any core127 * functions used that are not part of`wp-includes/load.php` should be checked for before being called.125 * print the HTML markup indicating that a PHP error occurred. Note that this drop-in may potentially be executed 126 * very early in the WordPress bootstrap process, so any core functions used that are not part of 127 * `wp-includes/load.php` should be checked for before being called. 128 128 * 129 * The default template also displays a link to the admin in order to fix the problem, however doing so is not 130 * mandatory. 129 * If no such drop-in is available, this will call {@see WP_Shutdown_Handler::display_default_error_template()}. 131 130 * 132 131 * @since 5.1.0 … … 142 141 } 143 142 144 // Otherwise, fail with a `wp_die()` message. 145 $message = $this->get_error_message_markup(); 146 147 // `wp_die()` wraps the message in paragraph tags, so let's just try working around that. 148 if ( substr( $message, 0, 3 ) === '<p>' && substr( $message, -4 ) === '</p>' ) { 149 $message = substr( $message, 3, -4 ); 150 } 151 152 wp_die( $message, '', 500 ); 143 // Otherwise, display the default error template. 144 $this->display_default_error_template(); 153 145 } 154 146 155 147 /** 156 * Returns the error message markup to display in the default error template. 148 * Displays the default PHP error template. 149 * 150 * This method is called conditionally if no 'php-error.php' drop-in is available. 151 * 152 * It calls {@see wp_die()} with a message indicating that the site is experiencing technical difficulties and a 153 * login link to the admin backend. The {@see 'wp_php_error_message'} and {@see 'wp_php_error_args'} filters can 154 * be used to modify these parameters. 157 155 * 158 156 * @since 5.1.0 159 *160 * @return string Error message HTML output.161 157 */ 162 protected function get_error_message_markup() {158 protected function display_default_error_template() { 163 159 if ( ! function_exists( '__' ) ) { 164 160 wp_load_translations_early(); 165 161 } 166 162 167 $message = sprintf( 168 '<p>%s</p>', 169 __( 'The site is experiencing technical difficulties.' ) 170 ); 171 172 if ( function_exists( 'admin_url' ) ) { 173 $message .= sprintf( 174 '<hr><p><em>%s <a href="%s">%s</a></em></p>', 175 __( 'Are you the site owner?' ), 176 admin_url(), 177 __( 'Log into the admin backend to fix this.' ) 178 ); 163 if ( ! function_exists( 'wp_die' ) ) { 164 require_once ABSPATH . WPINC . '/functions.php'; 179 165 } 180 166 181 if ( function_exists( 'apply_filters' ) ) { 182 /** 183 * Filters the message that the default PHP error page displays. 184 * 185 * @since 5.1.0 186 * 187 * @param string $message HTML error message to display. 188 */ 189 $message = apply_filters( 'wp_technical_issues_display', $message ); 167 $message = __( 'The site is experiencing technical difficulties.' ); 168 169 $args = array( 'response' => 500 ); 170 if ( function_exists( 'admin_url' ) ) { 171 $args['link_url'] = admin_url(); 172 $args['link_text'] = __( 'Log into the admin backend to fix this.' ); 190 173 } 191 174 192 return $message; 175 /** 176 * Filters the message that the default PHP error template displays. 177 * 178 * @since 5.1.0 179 * 180 * @param string $message HTML error message to display. 181 */ 182 $message = apply_filters( 'wp_php_error_message', $message ); 183 184 /** 185 * Filters the arguments passed to {@see wp_die()} for the default PHP error template. 186 * 187 * @since 5.1.0 188 * 189 * @param array $args Associative array of arguments passed to `wp_die()`. By default these contain a 190 * 'response' key, and optionally 'link_url' and 'link_text' keys. 191 */ 192 $args = apply_filters( 'wp_php_error_args', $args ); 193 194 wp_die( $message, '', $args ); 193 195 } 194 196 }
Note: See TracChangeset
for help on using the changeset viewer.