get_locale()
get_locale() 检索当前区域设置。Retrieves the current locale. 目录锚…
get_locale()
检索当前区域设置。
Retrieves the current locale.
检索当前区域设置。
Retrieves the current locale.
目录锚点:#说明#返回#源码#笔记
说明(Description)
如果设置了区域设置,则它将在“locale”筛选器挂钩中筛选区域设置并返回值。
如果尚未设置区域设置,则如果已定义WPLANG常量,则使用该常量。然后通过“locale”过滤器钩子过滤它,并返回locale全局集和locale的值。
获取区域设置的过程只应完成一次,但区域设置将始终使用“locale”挂钩进行筛选。
返回(Return)
(string)博客或“locale”挂钩中的区域设置。
源码(Source)
/**
* Get the current locale.
*
* If the locale is set, then it will filter the locale in the 'locale' filter
* hook and return the value.
*
* If the locale is not set already, then the WPLANG constant is used if it is
* defined. Then it is filtered through the 'locale' filter hook and the value
* for the locale global set and the locale is returned.
*
* The process to get the locale should only be done once, but the locale will
* always be filtered using the 'locale' hook.
*
* @since 1.5.0
*
* @global string $locale
* @global string $wp_local_package
*
* @return string The locale of the blog or from the 'locale' hook.
*/
function get_locale() {
global $locale, $wp_local_package;
if ( isset( $locale ) ) {
/**
* Filter WordPress install's locale ID.
*
* @since 1.5.0
*
* @param string $locale The locale ID.
*/
return apply_filters( 'locale', $locale );
}
if ( isset( $wp_local_package ) ) {
$locale = $wp_local_package;
}
// WPLANG was defined in wp-config.
if ( defined( 'WPLANG' ) ) {
$locale = WPLANG;
}
// If multisite, check options.
if ( is_multisite() ) {
// Don't check blog option when installing.
if ( defined( 'WP_INSTALLING' ) || ( false === $ms_locale = get_option( 'WPLANG' ) ) ) {
$ms_locale = get_site_option( 'WPLANG' );
}
if ( $ms_locale !== false ) {
$locale = $ms_locale;
}
} else {
$db_locale = get_option( 'WPLANG' );
if ( $db_locale !== false ) {
$locale = $db_locale;
}
}
if ( empty( $locale ) ) {
$locale = 'en_US';
}
/** This filter is documented in wp-includes/l10n.php */
return apply_filters( 'locale', $locale );
}| 更新版本 | 源码位置 | 使用 | 被使用 |
|---|---|---|---|
| 1.5.0 | wp-includes/l10n.php:30 | 21 | 6 |
笔记(Notes)
这将设置货币区域设置,如果为空,则设置为en_US
类别:WordPress 函数手册、
本文收集自互联网,转载请注明来源。
如有侵权,请联系 wper_net@163.com 删除。




还没有任何评论,赶紧来占个楼吧!