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
This commit is contained in:
Mike Schroder 2019-08-29 07:52:43 +00:00
parent 71697aefc0
commit 65f3124283
3 changed files with 17 additions and 4 deletions

View File

@ -30,7 +30,10 @@ wp_check_php_mysql_versions();
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 */

View File

@ -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;

View File

@ -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;