Skip to content
Permalink
Browse files

Administration: Output valid HTML when `wp_die()` is called.

To better support HTML and string calls to `wp_die()` without
outputting invalid HTML, wraps error messages in `<div>` rather than `<p>`.

Adds `.wp-die-message` CSS class for styling.

Props dinhtungdu, jeremyfelt, audrasjb, SergeyBiryukov, afercia, audrasjb, noisysocks.
Fixes #47580.

git-svn-id: https://develop.svn.wordpress.org/trunk@45909 602fd350-edb4-49c9-b593-d223f7449a82
  • Loading branch information...
getsource committed Aug 29, 2019
1 parent 71697ae commit 65f312428372f4caade616c62539ed669f21aef0
Showing with 17 additions and 4 deletions.
  1. +4 −1 src/index.php
  2. +6 −0 src/wp-admin/css/common.css
  3. +7 −3 src/wp-includes/functions.php
@@ -30,7 +30,10 @@
wp_load_translations_early();
// Die with an error message
$die = __( 'You are running WordPress without JavaScript and CSS files. These need to be built.' ) . '</p>';
$die = sprintf(
'<p>%s</p>',
__( 'You are running WordPress without JavaScript and CSS files. These need to be built.' )
);
$die .= '<p>' . sprintf(
/* translators: %s: npm install */
@@ -460,6 +460,12 @@ code {
white-space: nowrap;
}

.wp-die-message {
font-size: 13px;
line-height: 1.5;
margin: 1em 0;
}

/* .widefat - main style for tables */
.widefat {
border-spacing: 0;
@@ -3191,9 +3191,12 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) {
wp_list_pluck( $parsed_args['additional_errors'], 'message' )
);
$message = "<ul>\n\t\t<li>" . join( "</li>\n\t\t<li>", $message ) . "</li>\n\t</ul>";
} else {
$message = "<p>$message</p>";
}
$message = sprintf(
'<div class="wp-die-message">%s</div>',
$message
);
}
$have_gettext = function_exists( '__' );
@@ -3263,7 +3266,8 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) {
#error-page {
margin-top: 50px;
}
#error-page p {
#error-page p,
#error-page .wp-die-message {
font-size: 14px;
line-height: 1.5;
margin: 25px 0 20px;

0 comments on commit 65f3124

Please sign in to comment.
You can’t perform that action at this time.