Make WordPress Core


Ignore:
Timestamp:
01/30/2023 10:25:53 AM (23 months ago)
Author:
swissspidy
Message:

I18N: Introduce switch_to_user_locale().

This new function makes it easier to switch to a specific user’s locale by reducing duplicate code and storing the user’s ID as additional context for plugins to consume. Existing usage of switch_to_locale() in core has been replaced with switch_to_user_locale() where appropriate.

Also, this change ensures WP_Locale_Switcher properly filters determine_locale so that anyyone using the determine_locale() function will get the correct locale information when switching is in effect.

Props costdev.
Fixes #57123.
See #26511.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-recovery-mode-email-service.php

    r55001 r55161  
    117117        $blogname = wp_specialchars_decode( get_option( 'blogname' ), ENT_QUOTES );
    118118
    119         $switched_locale = false;
    120 
    121         // The switch_to_locale() function is loaded before it can actually be used.
    122         if ( function_exists( 'switch_to_locale' ) && isset( $GLOBALS['wp_locale_switcher'] ) ) {
    123             $switched_locale = switch_to_locale( get_locale() );
    124         }
     119        $switched_locale = switch_to_locale( get_locale() );
    125120
    126121        if ( $extension ) {
Note: See TracChangeset for help on using the changeset viewer.