From 65f312428372f4caade616c62539ed669f21aef0 Mon Sep 17 00:00:00 2001 From: Mike Schroder Date: Thu, 29 Aug 2019 07:52:43 +0000 Subject: [PATCH] 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 `
` rather than `

`. 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 --- src/index.php | 5 ++++- src/wp-admin/css/common.css | 6 ++++++ src/wp-includes/functions.php | 10 +++++++--- 3 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/index.php b/src/index.php index 371a97900b..9e75b990c5 100644 --- a/src/index.php +++ b/src/index.php @@ -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.' ) . '

'; +$die = sprintf( + '

%s

', + __( 'You are running WordPress without JavaScript and CSS files. These need to be built.' ) +); $die .= '

' . sprintf( /* translators: %s: npm install */ diff --git a/src/wp-admin/css/common.css b/src/wp-admin/css/common.css index 3a84f856b8..406e522411 100644 --- a/src/wp-admin/css/common.css +++ b/src/wp-admin/css/common.css @@ -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; diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index 29beb4370c..8a7897a909 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -3191,9 +3191,12 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) { wp_list_pluck( $parsed_args['additional_errors'], 'message' ) ); $message = "

"; - } else { - $message = "

$message

"; } + + $message = sprintf( + '
%s
', + $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;