Make WordPress Core


Ignore:
Timestamp:
02/04/2023 08:45:36 PM (21 months ago)
Author:
swissspidy
Message:

I18N: Improve method names in WP_Locale_Switcher().

This is a follow-up to [55161] to rename ::get_current_locale() to ::get_switched_locale() and ::get_current_user_id() to ::get_switched_user_id() for improved clarity.

Also:

  • Fix docblock for switch_locale filter. The User ID is false if missing, not null.
  • Add additional test involving restore_previous_locale() and improve test cleanup.

And most importantly: happy birthday ocean90! 🎂

Props johnjamesjacoby, ocean90.
See #57123.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/class-wp-locale-switcher.php

    r55161 r55224  
    9393         * @since 6.2.0 The `$user_id` parameter was added.
    9494         *
    95          * @param string   $locale  The new locale.
    96          * @param null|int $user_id User ID for context if available.
     95         * @param string    $locale  The new locale.
     96         * @param false|int $user_id User ID for context if available.
    9797         */
    9898        do_action( 'switch_locale', $locale, $user_id );
     
    187187     * @return string|false Locale if the locale has been switched, false otherwise.
    188188     */
    189     public function get_current_locale() {
     189    public function get_switched_locale() {
    190190        $entry = end( $this->stack );
    191191
     
    204204     * @return int|false User ID if set and if the locale has been switched, false otherwise.
    205205     */
    206     public function get_current_user_id() {
     206    public function get_switched_user_id() {
    207207        $entry = end( $this->stack );
    208208
     
    223223     */
    224224    public function filter_locale( $locale ) {
    225         $switched_locale = $this->get_current_locale();
     225        $switched_locale = $this->get_switched_locale();
    226226
    227227        if ( $switched_locale ) {
Note: See TracChangeset for help on using the changeset viewer.