From e4e1c7380c03ad98958a164b7a2992859ef1535a Mon Sep 17 00:00:00 2001 From: SergeyBiryukov Date: Sat, 14 Sep 2019 15:41:02 +0000 Subject: [PATCH] Bootstrap/Load: Allow charset to be passed to the `wp_die()` function. Props mohsinrasool, spacedmonkey, socalchristina. Fixes #46666. git-svn-id: https://develop.svn.wordpress.org/trunk@46109 602fd350-edb4-49c9-b593-d223f7449a82 --- src/wp-includes/functions.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/wp-includes/functions.php b/src/wp-includes/functions.php index c135d0d93e..0de1076f59 100644 --- a/src/wp-includes/functions.php +++ b/src/wp-includes/functions.php @@ -3076,6 +3076,7 @@ function wp_nonce_ays( $action ) { * @since 4.1.0 The `$title` and `$args` parameters were changed to optionally accept * an integer to be used as the response code. * @since 5.1.0 The `$link_url`, `$link_text`, and `$exit` arguments were added. + * @since 5.3.0 The `$charset` argument was added. * * @global WP_Query $wp_query WordPress Query object. * @@ -3099,6 +3100,7 @@ function wp_nonce_ays( $action ) { * @type string $text_direction The text direction. This is only useful internally, when WordPress * is still loading and the site's locale is not set up yet. Accepts 'rtl'. * Default is the value of is_rtl(). + * @type string $charset Character set of the HTML output. Default 'utf-8'. * @type string $code Error code to use. Default is 'wp_die', or the main error code if $message * is a WP_Error. * @type bool $exit Whether to exit the process after completion. Default true. @@ -3226,7 +3228,7 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) { if ( ! did_action( 'admin_head' ) ) : if ( ! headers_sent() ) { - header( 'Content-Type: text/html; charset=utf-8' ); + header( "Content-Type: text/html; charset={$parsed_args['charset']}" ); status_header( $parsed_args['response'] ); nocache_headers(); } @@ -3241,7 +3243,7 @@ function _default_wp_die_handler( $message, $title = '', $args = array() ) { > - + '', 'link_text' => '', 'text_direction' => '', + 'charset' => 'utf-8', 'additional_errors' => array(), ); @@ -3679,6 +3682,10 @@ function _wp_die_process_input( $message, $title = '', $args = array() ) { } } + if ( ! empty( $args['charset'] ) ) { + $args['charset'] = _canonical_charset( $args['charset'] ); + } + return array( $message, $title, $args ); }