Make WordPress Core

Changeset 57286

Timestamp:
01/15/2024 06:55:59 PM (7 months ago)
Author:
swissspidy
Message:

Upgrade/Install: Fix JavaScript localization on install page.

Blocks registration causes scripts to be initialized and localized very early, before the current locale has been properly set on the installation page.

This changes determine_locale() so that the locale chosen during installation is recognized and loaded earlier, ensuring proper script localization.

Props sabernhardt, NekoJonez, jornp, costdev.
Fixes #58696

Location:
trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/install.php

    r57239 r57286  
    330330$language = '';
    331331if ( ! empty( $_REQUEST['language'] ) ) {
    332     $language = preg_replace( '/[^a-zA-Z0-9_]/', '', $_REQUEST['language'] );
     332    $language = $_REQUEST['language'] );
    333333} elseif ( isset( $GLOBALS['wp_local_package'] ) ) {
    334334    $language = $GLOBALS['wp_local_package'];
  • trunk/src/wp-includes/l10n.php

    r57233 r57286  
    151151    ) {
    152152        $determined_locale = get_user_locale();
     153
     154
     155
     156
     157
     158
     159
     160
     161
    153162    }
    154163
  • trunk/tests/phpunit/tests/l10n/determineLocale.php

    r56559 r57286  
    2121
    2222    public function tear_down() {
    23         unset( $_SERVER['CONTENT_TYPE'], $_GET['_locale'], $_COOKIE['wp_lang'], $GLOBALS['pagenow'] );
     23        unset(
     24            $_SERVER['CONTENT_TYPE'],
     25            $_GET['_locale'],
     26            $_COOKIE['wp_lang'],
     27            $GLOBALS['pagenow'],
     28            $GLOBALS['wp_local_package'],
     29            $_REQUEST['language']
     30        );
     31        wp_installing( false );
    2432
    2533        parent::tear_down();
     
    274282        $this->assertSame( 'siteLocale', determine_locale() );
    275283    }
     284
     285
     286
     287
     288
     289
     290
     291
     292
     293
     294
     295
     296
     297
     298
     299
     300
     301
     302
     303
     304
     305
     306
     307
     308
     309
     310
    276311}
Note: See TracChangeset for help on using the changeset viewer.