From 981111ee9044d8c255d22e7cf9483666d141097c Mon Sep 17 00:00:00 2001 From: Pascal Birchler Date: Sat, 4 Feb 2023 20:47:18 +0000 Subject: [PATCH] I18N: Improve method names in `WP_Locale_Switcher()`. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. Built from https://develop.svn.wordpress.org/trunk@55224 git-svn-id: http://core.svn.wordpress.org/trunk@54757 1a063a9b-81f0-0310-95a4-ce76da25c4cd --- wp-includes/class-wp-locale-switcher.php | 10 +++++----- wp-includes/version.php | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/wp-includes/class-wp-locale-switcher.php b/wp-includes/class-wp-locale-switcher.php index 424561a21a..a99433e38d 100644 --- a/wp-includes/class-wp-locale-switcher.php +++ b/wp-includes/class-wp-locale-switcher.php @@ -92,8 +92,8 @@ class WP_Locale_Switcher { * @since 4.7.0 * @since 6.2.0 The `$user_id` parameter was added. * - * @param string $locale The new locale. - * @param null|int $user_id User ID for context if available. + * @param string $locale The new locale. + * @param false|int $user_id User ID for context if available. */ do_action( 'switch_locale', $locale, $user_id ); @@ -186,7 +186,7 @@ class WP_Locale_Switcher { * * @return string|false Locale if the locale has been switched, false otherwise. */ - public function get_current_locale() { + public function get_switched_locale() { $entry = end( $this->stack ); if ( $entry ) { @@ -203,7 +203,7 @@ class WP_Locale_Switcher { * * @return int|false User ID if set and if the locale has been switched, false otherwise. */ - public function get_current_user_id() { + public function get_switched_user_id() { $entry = end( $this->stack ); if ( $entry ) { @@ -222,7 +222,7 @@ class WP_Locale_Switcher { * @return string The locale currently being switched to. */ public function filter_locale( $locale ) { - $switched_locale = $this->get_current_locale(); + $switched_locale = $this->get_switched_locale(); if ( $switched_locale ) { return $switched_locale; diff --git a/wp-includes/version.php b/wp-includes/version.php index 0a32702033..16a6d6c92a 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -16,7 +16,7 @@ * * @global string $wp_version */ -$wp_version = '6.2-alpha-55223'; +$wp_version = '6.2-alpha-55224'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.