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. Built from https://develop.svn.wordpress.org/trunk@55224 git-svn-id: http://core.svn.wordpress.org/trunk@54757 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
4b790e3483
commit
981111ee90
|
@ -93,7 +93,7 @@ class WP_Locale_Switcher {
|
||||||
* @since 6.2.0 The `$user_id` parameter was added.
|
* @since 6.2.0 The `$user_id` parameter was added.
|
||||||
*
|
*
|
||||||
* @param string $locale The new locale.
|
* @param string $locale The new locale.
|
||||||
* @param null|int $user_id User ID for context if available.
|
* @param false|int $user_id User ID for context if available.
|
||||||
*/
|
*/
|
||||||
do_action( 'switch_locale', $locale, $user_id );
|
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.
|
* @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 );
|
$entry = end( $this->stack );
|
||||||
|
|
||||||
if ( $entry ) {
|
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.
|
* @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 );
|
$entry = end( $this->stack );
|
||||||
|
|
||||||
if ( $entry ) {
|
if ( $entry ) {
|
||||||
|
@ -222,7 +222,7 @@ class WP_Locale_Switcher {
|
||||||
* @return string The locale currently being switched to.
|
* @return string The locale currently being switched to.
|
||||||
*/
|
*/
|
||||||
public function filter_locale( $locale ) {
|
public function filter_locale( $locale ) {
|
||||||
$switched_locale = $this->get_current_locale();
|
$switched_locale = $this->get_switched_locale();
|
||||||
|
|
||||||
if ( $switched_locale ) {
|
if ( $switched_locale ) {
|
||||||
return $switched_locale;
|
return $switched_locale;
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
*
|
*
|
||||||
* @global string $wp_version
|
* @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.
|
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||||
|
|
Loading…
Reference in New Issue