Changeset 44624
- Timestamp:
- 01/16/2019 03:20:04 PM (6 years ago)
- Location:
- trunk/src/wp-includes
- Files:
-
- 2 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 } -
trunk/src/wp-includes/functions.php
r44590 r44624 2934 2934 * @since 4.1.0 The `$title` and `$args` parameters were changed to optionally accept 2935 2935 * an integer to be used as the response code. 2936 * @since 5.1.0 The `$link_url` and `$link_text` arguments were added. 2936 2937 * 2937 2938 * @param string|WP_Error $message Optional. Error message. If this is a WP_Error object, … … 2947 2948 * 2948 2949 * @type int $response The HTTP response code. Default 200 for Ajax requests, 500 otherwise. 2950 * @type string $link_url A URL to include a link to. Only works in combination with $link_text. 2951 * Default empty string. 2952 * @type string $link_text A label for the link to include. Only works in combination with $link_url. 2953 * Default empty string. 2949 2954 * @type bool $back_link Whether to include a link to go back. Default false. 2950 2955 * @type string $text_direction The text direction. This is only useful internally, when WordPress … … 3034 3039 } elseif ( is_string( $message ) ) { 3035 3040 $message = "<p>$message</p>"; 3041 } 3042 3043 if ( ! empty( $r['link_url'] ) && ! empty( $r['link_text'] ) ) { 3044 $link_url = $r['link_url']; 3045 if ( function_exists( 'esc_url' ) ) { 3046 $link_url = esc_url( $link_url ); 3047 } 3048 $link_text = $r['link_text']; 3049 $message .= "\n<p><a href='{$link_url}'>{$link_text}</a></p>"; 3036 3050 } 3037 3051
Note: See TracChangeset
for help on using the changeset viewer.