返回介绍

get_user_locale()

发布于 2017-09-11 00:45:04 字数 4468 浏览 1137 评论 0 收藏 0

get_user_locale( int|WP_User $user_id )

Retrieves the locale of a user.


description

If the user has a locale set to a non-empty string then it will be returned. Otherwise it returns the locale of get_locale().


参数

$user_id

(int|WP_User) (Required) User's ID or a WP_User object. Defaults to current user.


返回值

(string) The locale of the user.


源代码

File: wp-includes/l10n.php

function get_user_locale( $user_id = 0 ) {
	$user = false;
	if ( 0 === $user_id && function_exists( 'wp_get_current_user' ) ) {
		$user = wp_get_current_user();
	} elseif ( $user_id instanceof WP_User ) {
		$user = $user_id;
	} elseif ( $user_id && is_numeric( $user_id ) ) {
		$user = get_user_by( 'id', $user_id );
	}

	if ( ! $user ) {
		return get_locale();
	}

	$locale = $user->locale;
	return $locale ? $locale : get_locale();
}

更新日志

Versiondescription
4.7.0Introduced.

相关函数

Uses

  • wp-includes/l10n.php: get_locale()
  • wp-includes/pluggable.php: wp_get_current_user()
  • wp-includes/pluggable.php: get_user_by()

Used By

  • wp-includes/class-wp-editor.php: _WP_Editors::get_mce_locale()
  • wp-admin/includes/class-wp-community-events.php: WP_Community_Events::get_request_args()
  • wp-includes/l10n.php: _get_path_to_translation_from_lang_dir()
  • wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php: WP_REST_Users_Controller::prepare_item_for_response()
  • wp-includes/class-wp-locale-switcher.php: WP_Locale_Switcher::switch_to_locale()
  • wp-includes/class-wp-locale-switcher.php: WP_Locale_Switcher::__construct()
  • wp-includes/customize/class-wp-customize-selective-refresh.php: WP_Customize_Selective_Refresh::export_preview_data()
  • wp-admin/includes/class-wp-press-this.php: WP_Press_This::html()
  • wp-admin/includes/theme.php: themes_api()
  • wp-admin/includes/ms.php: update_option_new_admin_email()
  • wp-admin/includes/ms.php: send_confirmation_on_profile_email()
  • wp-admin/includes/plugin-install.php: plugins_api()
  • wp-admin/includes/dashboard.php: wp_dashboard_cached_rss_widget()
  • wp-admin/includes/dashboard.php: wp_dashboard_rss_control()
  • wp-admin/includes/dashboard.php: wp_dashboard_browser_nag()
  • wp-admin/includes/class-wp-plugin-install-list-table.php: WP_Plugin_Install_List_Table::prepare_items()
  • wp-admin/includes/template.php: iframe_header()
  • wp-admin/includes/import.php: wp_get_popular_importers()
  • wp-admin/includes/credits.php: wp_credits()
  • wp-includes/class-wp-customize-manager.php: WP_Customize_Manager::customize_preview_settings()
  • wp-includes/l10n.php: load_default_textdomain()
  • wp-includes/l10n.php: load_plugin_textdomain()
  • wp-includes/l10n.php: load_muplugin_textdomain()
  • wp-includes/l10n.php: load_theme_textdomain()
  • wp-includes/pluggable.php: wp_new_user_notification()
  • wp-includes/class-wp-theme.php: WP_Theme::sort_by_name()
  • wp-includes/user.php: wp_update_user()
  • wp-includes/ms-functions.php: wpmu_welcome_user_notification()
  • wp-includes/ms-functions.php: wpmu_welcome_notification()
  • wp-includes/ms-functions.php: wpmu_signup_blog_notification()
  • wp-includes/ms-functions.php: wpmu_signup_user_notification()
  • wp-includes/class-wp-customize-widgets.php: WP_Customize_Widgets::export_preview_data()
  • wp-includes/class-wp-editor.php: _WP_Editors::editor_settings()
  • Show 28 more used by Hide more used by

User Contributed Notes

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文