Make WordPress Core

Ticket #42241: 42241.3.diff

File 42241.3.diff, 1.9 KB (added by westonruter, 7 years ago)

Add mejsL10n global as inline script before the mediaelement-core script instead of after the mediaelement script.

  • src/wp-includes/script-loader.php

    diff --git src/wp-includes/script-loader.php src/wp-includes/script-loader.php
    index 96e26b0712..0930ea8c77 100644
    function wp_default_scripts( &$scripts ) { 
    355355        $scripts->add( 'mediaelement', false, array( 'jquery', 'mediaelement-core', 'mediaelement-migrate' ), '4.2.6-78496d1' );
    356356        $scripts->add( 'mediaelement-core', "/wp-includes/js/mediaelement/mediaelement-and-player$suffix.js", array(), '4.2.6-78496d1', 1 );
    357357        $scripts->add( 'mediaelement-migrate', "/wp-includes/js/mediaelement/mediaelement-migrate$suffix.js", array(), false, 1);
    358         did_action( 'init' ) && $scripts->localize( 'mediaelement', 'mejsL10n', array(
    359                 'language' => get_bloginfo( 'language' ),
     358
     359        $mejs_language = null;
     360        if ( did_action( 'init' ) ) {
     361                $mejs_language = strtolower( str_replace( '_', '-', is_admin() ? get_user_locale() : get_locale() ) );
     362                if ( $mejs_language !== 'zh-cn' ) { // The only locale with a country code currently.
     363                        $mejs_language = strtok( $mejs_language, '-' );
     364                }
     365        }
     366
     367        did_action( 'init' ) && $scripts->add_inline_script( 'mediaelement-core', sprintf( 'var mejsL10n = %s;', wp_json_encode( array(
     368                'language' => $mejs_language,
    360369                'strings'  => array(
    361370                        'mejs.install-flash'       => __( 'You are using a browser that does not have Flash player enabled or installed. Please turn on your Flash player plugin or download the latest version from https://get.adobe.com/flashplayer/' ),
    362371                        'mejs.fullscreen-off'      => __( 'Turn off Fullscreen' ),
    function wp_default_scripts( &$scripts ) { 
    443452                        'mejs.welsh'               => __( 'Welsh' ),
    444453                        'mejs.yiddish'             => __( 'Yiddish' ),
    445454                        ),
    446                 ) );
     455                ) ) ), 'before' );
    447456
    448457
    449458        $scripts->add( 'mediaelement-vimeo', "/wp-includes/js/mediaelement/renderers/vimeo.min.js", array('mediaelement'), '4.2.6-78496d1', 1 );