mu_dropdown_languages() - WordPress 函数参考中文文档

返回介绍

mu_dropdown_languages()

发布于 2017-09-11 字数2999 浏览 976 评论 0

mu_dropdown_languages( array $lang_files = array(),  string $current = '' )

Generates and displays a drop-down of available languages.


描述


参数

$lang_files

(array)
(Optional)
An array of the language files.

Default value: array()

$current

(string)
(Optional)
The current language code.

Default value: ”


源代码

File: wp-admin/includes/ms.php

function mu_dropdown_languages( $lang_files = array(), $current = '' ) {
	$flag = false;
	$output = array();

	foreach ( (array) $lang_files as $val ) {
		$code_lang = basename( $val, '.mo' );

		if ( $code_lang == 'en_US' ) { // American English
			$flag = true;
			$ae = __( 'American English' );
			$output[$ae] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $ae . '</option>';
		} elseif ( $code_lang == 'en_GB' ) { // British English
			$flag = true;
			$be = __( 'British English' );
			$output[$be] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . $be . '</option>';
		} else {
			$translated = format_code_lang( $code_lang );
			$output[$translated] = '<option value="' . esc_attr( $code_lang ) . '"' . selected( $current, $code_lang, false ) . '> ' . esc_html ( $translated ) . '</option>';
		}

	}

	if ( $flag === false ) // WordPress english
		$output[] = '<option value=""' . selected( $current, '', false ) . '>' . __( 'English' ) . "</option>";

	// Order by name
	uksort( $output, 'strnatcasecmp' );

	/**
	 * Filters the languages available in the dropdown.
	 *
	 * @since MU
	 *
	 * @param array $output     HTML output of the dropdown.
	 * @param array $lang_files Available language files.
	 * @param string $current   The current language code.
	 */
	$output = apply_filters( 'mu_dropdown_languages', $output, $lang_files, $current );

	echo implode( "\n\t", $output );
}

更新日志

Version 描述
3.0.0 Introduced.

相关函数

Uses

  • wp-admin/includes/ms.php:
    mu_dropdown_languages
  • wp-admin/includes/ms.php:
    format_code_lang()
  • wp-includes/l10n.php:
    __()
  • wp-includes/formatting.php:
    esc_attr()
  • wp-includes/formatting.php:
    esc_html()
  • wp-includes/general-template.php:
    selected()
  • wp-includes/plugin.php:
    apply_filters()
  • Show 2 more uses
    Hide more uses


User Contributed Notes

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!