^ 回到顶部
  • 人生没有定律,每个人都有自己的节奏
  • 本站wordpress建站教程均通过实践后发布,希望对你有帮助
  • 希望你的坚持,都是因为热爱,而不是因为不甘心
  • 8年wordpress建站经验,5星服务品质
  • 那些不愿意让你吃亏的人,才是真正值得你深交的人,也是值得你付出时间的人
  • 阿里云2核2g仅需86元/年

wordpress函数get_available_languages()用法示例

get_available_languages( string $dir = null )

Get all available languages based on the presence of *.mo files in a given directory.


描述

The default directory is WP_LANG_DIR.

新用户2核2g仅需86元/年    领取1153套模板    免费cdn流量包    ¥3188礼包


参数

$dir

(string)
(Optional)
A directory to search for language files. Default WP_LANG_DIR.

Default value: null


返回值

(array) An array of language codes or an empty array if no languages are present. Language codes are formed by stripping the .mo extension from the language file names.


源代码

File: wp-includes/l10n.php

function get_available_languages( $dir = null ) {
	$languages = array();

	$lang_files = glob( ( is_null( $dir ) ? WP_LANG_DIR : $dir ) . '/*.mo' );
	if ( $lang_files ) {
		foreach ( $lang_files as $lang_file ) {
			$lang_file = basename( $lang_file, '.mo' );
			if ( 0 !== strpos( $lang_file, 'continents-cities' ) && 0 !== strpos( $lang_file, 'ms-' ) &&
				0 !== strpos( $lang_file, 'admin-' ) ) {
				$languages[] = $lang_file;
			}
		}
	}

	/**
	 * Filters the list of available language codes.
	 *
	 * @since 4.7.0
	 *
	 * @param array  $languages An array of available language codes.
	 * @param string $dir       The directory where the language files were found.
	 */
	return apply_filters( 'get_available_languages', $languages, $dir );
}

更新日志

Version 描述
4.7.0 The results are now filterable with the ‘get_available_languages’ filter.
3.0.0 Introduced.

相关函数

Uses

  • wp-includes/l10n.php:
    get_available_languages
  • wp-includes/plugin.php:
    apply_filters()

Used By

  • wp-includes/rest-api/endpoints/class-wp-rest-users-controller.php:
    WP_REST_Users_Controller::get_item_schema()
  • wp-includes/class-wp-locale-switcher.php:
    WP_Locale_Switcher::__construct()
  • wp-signup.php:
    signup_get_available_languages()
  • wp-admin/includes/translation-install.php:
    wp_install_language_form()
  • wp-admin/includes/translation-install.php:
    wp_download_language_pack()
  • wp-admin/includes/user.php:
    edit_user()
  • wp-includes/formatting.php:
    sanitize_option()
  • wp-includes/update.php:
    wp_update_plugins()
  • wp-includes/update.php:
    wp_update_themes()
  • Show 4 more used by
    Hide more used by


让小雨知道,这篇文章帮到了你
扫码关注微信公众号zs40086(微搜片)随时随地微信看片,抢先福利电影等你来

热门推荐

如有疑问,请前往问答中心反馈!

反馈