WordPress.org

Make WordPress Core

Ticket #45441: 45441.diff

File 45441.diff, 970 bytes (added by swissspidy, 8 months ago)
  • src/wp-includes/class.wp-scripts.php

    diff --git src/wp-includes/class.wp-scripts.php src/wp-includes/class.wp-scripts.php
    index e843233cbc..cc6107eefa 100644
    class WP_Scripts extends WP_Dependencies { 
    545545                        $json_translations = '{ "locale_data": { "messages": { "": {} } } }';
    546546                }
    547547
    548                 $output = '(function( translations ){' .
    549                                           'translations.locale_data.messages[""].domain = "' . $domain . '";' .
    550                                           'wp.i18n.setLocaleData( translations.locale_data.messages, "' . $domain . '" );' .
    551                                   '})(' . $json_translations . ');';
     548                $output = <<<JS
     549(function( domain, translations ){
     550        var localeData = translations.locale_data[ domain ] || translations.locale_data.messages;
     551        localeData[""].domain = domain;
     552        wp.i18n.setLocaleData( localeData, domain );
     553})( "$domain", $json_translations );
     554JS;
    552555
    553556                if ( $echo ) {
    554557                        printf( "<script type='text/javascript'>\n%s\n</script>\n", $output );