From 8316af9198e0efaa03be66ed45a1c0f662785d6e Mon Sep 17 00:00:00 2001 From: Sergey Biryukov Date: Sat, 14 Sep 2019 15:42:56 +0000 Subject: [PATCH] Bootstrap/Load: Allow charset to be passed to the `wp_die()` function. Props mohsinrasool, spacedmonkey, socalchristina. Fixes #46666. Built from https://develop.svn.wordpress.org/trunk@46109 git-svn-id: http://core.svn.wordpress.org/trunk@45921 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/functions.php | 17 ++++++++++++----- wp-includes/version.php | 2 +- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/wp-includes/functions.php b/wp-includes/functions.php index c135d0d93e..0de1076f59 100644 --- a/wp-includes/functions.php +++ b/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 ); } diff --git a/wp-includes/version.php b/wp-includes/version.php index f239655dcc..db9d0bb5c1 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.3-alpha-46108'; +$wp_version = '5.3-alpha-46109'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.