Make WordPress Core

Ticket #46666: 46666.patch

File 46666.patch, 3.0 KB (added by mohsinrasool, 6 years ago)

Newbie here. I developed attached solution by editing functions.php. I tried to follow WordPress coding standard as much as I am aware of. Please guide me if I made any mistakes. Trunk patch is attached.

  • functions.php

     
    29542954 *     @type string $link_text      A label for the link to include. Only works in combination with $link_url.
    29552955 *                                  Default empty string.
    29562956 *     @type bool   $back_link      Whether to include a link to go back. Default false.
     2957 *     @type string $charset            Character set of the response HTML
     2958 *                                  Default is "utf-8".
    29572959 *     @type string $text_direction The text direction. This is only useful internally, when WordPress
    29582960 *                                  is still loading and the site's locale is not set up yet. Accepts 'rtl'.
    29592961 *                                  Default is the value of is_rtl().
     
    30793081
    30803082        if ( ! did_action( 'admin_head' ) ) :
    30813083                if ( ! headers_sent() ) {
    3082                         header( 'Content-Type: text/html; charset=utf-8' );
     3084                        $charset = $r['charset'];
     3085                        header( "Content-Type: text/html; charset=$charset" );
    30833086                        status_header( $r['response'] );
    30843087                        nocache_headers();
    30853088                }
     
    30903093                } else {
    30913094                        $dir_attr = "dir='$text_direction'";
    30923095                }
     3096
     3097                $charset = $r['charset'];
     3098                $charset_attr = "charset=$charset";
     3099
    30933100                ?>
    30943101<!DOCTYPE html>
    30953102<html xmlns="http://www.w3.org/1999/xhtml" <?php echo $dir_attr; ?>>
    30963103<head>
    3097         <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
     3104        <meta http-equiv="Content-Type" content="text/html; <?php echo $charset_attr; ?>" />
    30983105        <meta name="viewport" content="width=device-width">
    30993106                <?php
    31003107                if ( function_exists( 'wp_no_robots' ) ) {
     
    32973304        );
    32983305
    32993306        if ( ! headers_sent() ) {
    3300                 header( 'Content-Type: application/json; charset=utf-8' );
     3307                $charset = $r['charset'];
     3308                header( "Content-Type: application/json; charset=$charset"  );
    33013309                if ( null !== $r['response'] ) {
    33023310                        status_header( $r['response'] );
    33033311                }
     
    33353343        );
    33363344
    33373345        if ( ! headers_sent() ) {
    3338                 header( 'Content-Type: application/javascript; charset=utf-8' );
     3346                $charset = $r['charset'];
     3347                header( "Content-Type: application/javascript; charset=$charset" );
    33393348                header( 'X-Content-Type-Options: nosniff' );
    33403349                header( 'X-Robots-Tag: noindex' );
    33413350                if ( null !== $r['response'] ) {
     
    34153424EOD;
    34163425
    34173426        if ( ! headers_sent() ) {
    3418                 header( 'Content-Type: text/xml; charset=utf-8' );
     3427                $charset = $r['charset'];
     3428                header( "Content-Type: text/xml; charset=$charset" );
    34193429                if ( null !== $r['response'] ) {
    34203430                        status_header( $r['response'] );
    34213431                }
     
    34733483                'code'              => '',
    34743484                'exit'              => true,
    34753485                'back_link'         => false,
     3486                'charset'               => 'utf-8',
    34763487                'link_url'          => '',
    34773488                'link_text'         => '',
    34783489                'text_direction'    => '',
     
    35303541                        $args['text_direction'] = 'rtl';
    35313542                }
    35323543        }
     3544        if ( ! empty( $args['charset'] ) ) {
     3545                $args['charset'] = _canonical_charset($args['charset']);
     3546        }
    35333547
    35343548        return array( $message, $title, $args );
    35353549}