Make WordPress Core

Ticket #29722: 29722.2.patch

File 29722.2.patch, 857 bytes (added by Fab1en, 11 years ago)

Avoid warning when scalar value is passed but decode HTML entities

  • src/wp-includes/class.wp-scripts.php

    diff --git a/src/wp-includes/class.wp-scripts.php b/src/wp-includes/class.wp-scripts.php
    index 89a9ec9..c239a4a 100644
    a b class WP_Scripts extends WP_Dependencies { 
    160160                        unset($l10n['l10n_print_after']);
    161161                }
    162162
    163                 foreach ( (array) $l10n as $key => $value ) {
    164                         if ( !is_scalar($value) )
    165                                 continue;
     163                if ( is_array($l10n) ) {
     164                        foreach ( $l10n as $key => $value ) {
     165                                if ( !is_scalar($value) )
     166                                        continue;
    166167
    167                         $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
     168                                $l10n[$key] = html_entity_decode( (string) $value, ENT_QUOTES, 'UTF-8');
     169                        }
     170                } else if ( is_string($l10n) ) {
     171                        $l10n = html_entity_decode( $l10n, ENT_QUOTES, 'UTF-8');
    168172                }
    169173
    170174                $script = "var $object_name = " . json_encode($l10n) . ';';