dead_db()
Load custom DB error or display WordPress DB error.
Description Description
If a file exists in the wp-content directory named db-error.php, then it will be loaded instead of displaying the WordPress DB error. If it is not found, then the WordPress DB error will be displayed instead.
The WordPress DB error sets the HTTP status header to 500 to try to prevent search engines from caching the message. Custom DB messages should do the same.
This function was backported to WordPress 2.3.2, but originally was added in WordPress 2.5.0.
Source Source
File: wp-includes/functions.php
4234 4235 4236 4237 4238 4239 4240 4241 4242 4243 4244 4245 4246 4247 4248 4249 4250 4251 4252 4253 4254 4255 4256 4257 4258 4259 4260 4261 4262 4263 4264 4265 4266 4267 4268 4269 4270 4271 4272 4273 | function dead_db() { global $wpdb ; wp_load_translations_early(); // Load custom DB error template, if present. if ( file_exists ( WP_CONTENT_DIR . '/db-error.php' ) ) { require_once ( WP_CONTENT_DIR . '/db-error.php' ); die (); } // If installing or in the admin, provide the verbose message. if ( wp_installing() || defined( 'WP_ADMIN' ) ) { wp_die( $wpdb ->error ); } // Otherwise, be terse. status_header( 500 ); nocache_headers(); header( 'Content-Type: text/html; charset=utf-8' ); $dir_attr = '' ; if ( is_rtl() ) { $dir_attr = ' dir="rtl"' ; } ?> <!DOCTYPE html> <head> <meta http-equiv= "Content-Type" content= "text/html; charset=utf-8" /> <title><?php _e( 'Database Error' ); ?></title> </head> <body> <h1><?php _e( 'Error establishing a database connection' ); ?></h1> </body> </html> <?php die (); } |
Expand full source code Collapse full source code View on Trac
Changelog Changelog
Version | Description |
---|---|
2.3.2 | Introduced. |