Skip to content

Commit 4591c51

Browse files
committed
wp_die() improvements from Sewar. fixes WordPress#2902
git-svn-id: https://develop.svn.wordpress.org/trunk@4006 602fd350-edb4-49c9-b593-d223f7449a82
1 parent 87236e5 commit 4591c51

11 files changed

Lines changed: 64 additions & 122 deletions

File tree

wp-admin/bookmarklet.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
require_once('admin.php');
44

55
if ( ! current_user_can('edit_posts') )
6-
die ("Cheatin' uh?");
6+
wp_die(__('Cheatin’ uh?'));
77

88
if ('b' == $a):
99
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

wp-admin/categories.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
check_admin_referer('add-category');
1414

1515
if ( !current_user_can('manage_categories') )
16-
die (__('Cheatin&#8217; uh?'));
16+
wp_die(__('Cheatin&#8217; uh?'));
1717

1818
wp_insert_category($_POST);
1919

@@ -25,7 +25,7 @@
2525
check_admin_referer('delete-category_' . $cat_ID);
2626

2727
if ( !current_user_can('manage_categories') )
28-
die (__('Cheatin&#8217; uh?'));
28+
wp_die(__('Cheatin&#8217; uh?'));
2929

3030
$cat_name = get_catname($cat_ID);
3131

@@ -56,7 +56,7 @@
5656
check_admin_referer('update-category_' . $cat_ID);
5757

5858
if ( !current_user_can('manage_categories') )
59-
die (__('Cheatin&#8217; uh?'));
59+
wp_die(__('Cheatin&#8217; uh?'));
6060

6161
wp_update_category($_POST);
6262

wp-admin/install.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@
7474
<h1 id="logo"><img alt="WordPress" src="images/wordpress-logo.png" /></h1>
7575
<?php
7676
// Let's check to make sure WP isn't already installed.
77-
if ( is_blog_installed() ) wp_die('<h1>'.__('Already Installed').'</h1><p>'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'</p></body></html>');
77+
if ( is_blog_installed() ) die('<h1>'.__('Already Installed').'</h1><p>'.__('You appear to have already installed WordPress. To reinstall please clear your old database tables first.').'</p></body></html>');
7878

7979
switch($step) {
8080

wp-admin/link-import.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
{
1717
include_once('admin-header.php');
1818
if ( !current_user_can('manage_links') )
19-
die (__("Cheatin&#8217; uh?"));
19+
wp_die(__('Cheatin&#8217; uh?'));
2020

2121
$opmltype = 'blogrolling'; // default.
2222
?>
@@ -68,7 +68,7 @@
6868

6969
include_once('admin-header.php');
7070
if ( !current_user_can('manage_links') )
71-
die (__("Cheatin' uh ?"));
71+
wp_die(__('Cheatin&#8217; uh?'));
7272
?>
7373
<div class="wrap">
7474

wp-admin/link.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
// check the current user's level first.
2020
if (!current_user_can('manage_links'))
21-
wp_die(__("Cheatin' uh ?"));
21+
wp_die(__('Cheatin&#8217; uh?'));
2222

2323
//for each link id (in $linkcheck[]) change category to selected value
2424
if (count($linkcheck) == 0) {
@@ -42,7 +42,7 @@
4242

4343
// check the current user's level first.
4444
if (!current_user_can('manage_links'))
45-
wp_die(__("Cheatin' uh ?"));
45+
wp_die(__('Cheatin&#8217; uh?'));
4646

4747
//for each link id (in $linkcheck[]) change category to selected value
4848
if (count($linkcheck) == 0) {
@@ -79,7 +79,7 @@
7979
check_admin_referer('delete-bookmark_' . $link_id);
8080

8181
if (!current_user_can('manage_links'))
82-
wp_die(__("Cheatin' uh ?"));
82+
wp_die(__('Cheatin&#8217; uh?'));
8383

8484
wp_delete_link($link_id);
8585

wp-admin/options.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
wp_reset_vars(array('action'));
99

1010
if ( !current_user_can('manage_options') )
11-
die ( __('Cheatin&#8217; uh?') );
11+
wp_die(__('Cheatin&#8217; uh?'));
1212

1313
switch($action) {
1414

wp-admin/sidebar.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
require_once('admin.php');
55

66
if ( ! current_user_can('edit_posts') )
7-
die ("Cheatin' uh ?");
7+
wp_die(__('Cheatin&#8217; uh?'));
88

99
if ('b' == $_GET['a']) {
1010

wp-admin/update-links.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
$link_uris = $wpdb->get_col("SELECT link_url FROM $wpdb->links");
99

1010
if ( !$link_uris )
11-
wp_die('No links');
11+
wp_die(__('No links'));
1212

1313
$link_uris = urlencode( join( $link_uris, "\n" ) );
1414

wp-includes/functions.php

Lines changed: 46 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1117,65 +1117,58 @@ function wp_nonce_ays($action) {
11171117
}
11181118

11191119
function wp_die($message) {
1120-
global $wpdb;
1121-
1122-
if ( !$wpdb->show_errors )
1123-
return false;
11241120
header('Content-Type: text/html; charset=utf-8');
11251121

1126-
$output = <<<HEAD
1127-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1128-
<html xmlns="http://www.w3.org/1999/xhtml">
1129-
<head>
1130-
<title>WordPress &rsaquo; Error</title>
1131-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1132-
<style media="screen" type="text/css">
1133-
<!--
1134-
html {
1135-
background: #eee;
1136-
}
1137-
body {
1138-
background: #fff;
1139-
color: #000;
1140-
font-family: Georgia, "Times New Roman", Times, serif;
1141-
margin-left: 25%;
1142-
margin-right: 25%;
1143-
padding: .2em 2em;
1144-
}
1122+
?>
1123+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
1124+
<html xmlns="http://www.w3.org/1999/xhtml">
1125+
<head>
1126+
<title>WordPress &rsaquo; <?php _e('Error'); ?></title>
1127+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
1128+
<style media="screen" type="text/css">
1129+
<!--
1130+
html {
1131+
background: #eee;
1132+
}
1133+
body {
1134+
background: #fff;
1135+
color: #000;
1136+
font-family: Georgia, "Times New Roman", Times, serif;
1137+
margin-left: 25%;
1138+
margin-right: 25%;
1139+
padding: .2em 2em;
1140+
}
11451141

1146-
h1 {
1147-
color: #006;
1148-
font-size: 18px;
1149-
font-weight: lighter;
1150-
}
1142+
h1 {
1143+
color: #006;
1144+
font-size: 18px;
1145+
font-weight: lighter;
1146+
}
11511147

1152-
h2 {
1153-
font-size: 16px;
1154-
}
1148+
h2 {
1149+
font-size: 16px;
1150+
}
11551151

1156-
p, li, dt {
1157-
line-height: 140%;
1158-
padding-bottom: 2px;
1159-
}
1152+
p, li, dt {
1153+
line-height: 140%;
1154+
padding-bottom: 2px;
1155+
}
11601156

1161-
ul, ol {
1162-
padding: 5px 5px 5px 20px;
1163-
}
1164-
#logo {
1165-
margin-bottom: 2em;
1166-
}
1167-
-->
1168-
</style>
1169-
</head>
1170-
<body>
1171-
<h1 id="logo"><img alt="WordPress" src="../wp-admin/images/wordpress-logo.png" /></h1>
1172-
<p>$message</p>
1173-
</body>
1174-
</html>
1175-
HEAD;
1176-
1177-
$output = apply_filters('wp_die', $output, $message);
1178-
echo $output;
1157+
ul, ol {
1158+
padding: 5px 5px 5px 20px;
1159+
}
1160+
#logo {
1161+
margin-bottom: 2em;
1162+
}
1163+
-->
1164+
</style>
1165+
</head>
1166+
<body>
1167+
<h1 id="logo"><img alt="WordPress" src="<?php echo get_settings('siteurl'); ?>/wp-admin/images/wordpress-logo.png" /></h1>
1168+
<p><?php echo $message; ?></p>
1169+
</body>
1170+
</html>
1171+
<?php
11791172

11801173
die();
11811174
}

wp-includes/wp-db.php

Lines changed: 3 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -303,59 +303,10 @@ function timer_stop($precision = 3) {
303303
}
304304

305305
function bail($message) { // Just wraps errors in a nice header and footer
306-
if ( !$this->show_errors )
307-
return false;
308-
header( 'Content-Type: text/html; charset=utf-8');
309-
echo <<<HEAD
310-
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
311-
<html xmlns="http://www.w3.org/1999/xhtml">
312-
<head>
313-
<title>WordPress &rsaquo; Error</title>
314-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
315-
<style media="screen" type="text/css">
316-
<!--
317-
html {
318-
background: #eee;
319-
}
320-
body {
321-
background: #fff;
322-
color: #000;
323-
font-family: Georgia, "Times New Roman", Times, serif;
324-
margin-left: 25%;
325-
margin-right: 25%;
326-
padding: .2em 2em;
327-
}
328-
329-
h1 {
330-
color: #006;
331-
font-size: 18px;
332-
font-weight: lighter;
333-
}
334-
335-
h2 {
336-
font-size: 16px;
337-
}
338-
339-
p, li, dt {
340-
line-height: 140%;
341-
padding-bottom: 2px;
342-
}
306+
if ( !$this->show_errors )
307+
return false;
343308

344-
ul, ol {
345-
padding: 5px 5px 5px 20px;
346-
}
347-
#logo {
348-
margin-bottom: 2em;
349-
}
350-
-->
351-
</style>
352-
</head>
353-
<body>
354-
<h1 id="logo"><img alt="WordPress" src="http://static.wordpress.org/logo.png" /></h1>
355-
HEAD;
356-
echo $message;
357-
echo "</body></html>";
358-
die();
309+
wp_die($message);
359310
}
360311
}
361312

0 commit comments

Comments
 (0)