函数文档

is_locale_switched()

💡 云策文档标注

概述

is_locale_switched() 函数用于检测当前是否处于 switch_to_locale() 切换后的语言环境状态。它返回一个布尔值,指示语言环境是否已切换。

关键要点

  • 函数返回布尔值:true 表示语言环境已切换,false 表示未切换。
  • 内部调用 WP_Locale_Switcher 类的 is_switched() 方法来实现功能。
  • 该函数自 WordPress 4.7.0 版本引入。

📄 原文内容

Determines whether switch_to_locale() is in effect.

Return

bool True if the locale has been switched, false otherwise.

Source

function is_locale_switched() {
	/* @var WP_Locale_Switcher $wp_locale_switcher */
	global $wp_locale_switcher;

	return $wp_locale_switcher->is_switched();
}

Changelog

Version Description
4.7.0 Introduced.