Make WordPress Core

Changeset 46109


Ignore:
Timestamp:
09/14/2019 03:41:02 PM (5 years ago)
Author:
SergeyBiryukov
Message:

Bootstrap/Load: Allow charset to be passed to the wp_die() function.

Props mohsinrasool, spacedmonkey, socalchristina.
Fixes #46666.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/functions.php

    r46107 r46109  
    30773077 *              an integer to be used as the response code.
    30783078 * @since 5.1.0 The `$link_url`, `$link_text`, and `$exit` arguments were added.
     3079 * @since 5.3.0 The `$charset` argument was added.
    30793080 *
    30803081 * @global WP_Query $wp_query WordPress Query object.
     
    31003101 *                                  is still loading and the site's locale is not set up yet. Accepts 'rtl'.
    31013102 *                                  Default is the value of is_rtl().
     3103 *     @type string $charset        Character set of the HTML output. Default 'utf-8'.
    31023104 *     @type string $code           Error code to use. Default is 'wp_die', or the main error code if $message
    31033105 *                                  is a WP_Error.
     
    32273229    if ( ! did_action( 'admin_head' ) ) :
    32283230        if ( ! headers_sent() ) {
    3229             header( 'Content-Type: text/html; charset=utf-8' );
     3231            header( "Content-Type: text/html; charset={$parsed_args['charset']}" );
    32303232            status_header( $parsed_args['response'] );
    32313233            nocache_headers();
     
    32423244<html xmlns="http://www.w3.org/1999/xhtml" <?php echo $dir_attr; ?>>
    32433245<head>
    3244     <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     3246    <meta http-equiv="Content-Type" content="text/html; charset=<?php echo $parsed_args['charset']; ?>" />
    32453247    <meta name="viewport" content="width=device-width">
    32463248        <?php
     
    34463448
    34473449    if ( ! headers_sent() ) {
    3448         header( 'Content-Type: application/json; charset=utf-8' );
     3450        header( "Content-Type: application/json; charset={$parsed_args['charset']}" );
    34493451        if ( null !== $parsed_args['response'] ) {
    34503452            status_header( $parsed_args['response'] );
     
    34843486
    34853487    if ( ! headers_sent() ) {
    3486         header( 'Content-Type: application/javascript; charset=utf-8' );
     3488        header( "Content-Type: application/javascript; charset={$parsed_args['charset']}" );
    34873489        header( 'X-Content-Type-Options: nosniff' );
    34883490        header( 'X-Robots-Tag: noindex' );
     
    35643566
    35653567    if ( ! headers_sent() ) {
    3566         header( 'Content-Type: text/xml; charset=utf-8' );
     3568        header( "Content-Type: text/xml; charset={$parsed_args['charset']}" );
    35673569        if ( null !== $parsed_args['response'] ) {
    35683570            status_header( $parsed_args['response'] );
     
    36253627        'link_text'         => '',
    36263628        'text_direction'    => '',
     3629        'charset'           => 'utf-8',
    36273630        'additional_errors' => array(),
    36283631    );
     
    36783681            $args['text_direction'] = 'rtl';
    36793682        }
     3683    }
     3684
     3685    if ( ! empty( $args['charset'] ) ) {
     3686        $args['charset'] = _canonical_charset( $args['charset'] );
    36803687    }
    36813688
Note: See TracChangeset for help on using the changeset viewer.