get_language_attributes() WP 4.3.0
Gets the language attributes for the 'html' tag.
Builds up a set of HTML attributes containing the text direction and language information for the page.
Хуки из функции
Возвращает
Null. Ничего.
Использование
get_language_attributes( $doctype );
- $doctype(строка)
- The type of HTML document. Accepts 'xhtml' or 'html'.
По умолчанию: 'html'
Список изменений
С версии 4.3.0 | Введена. |
Код get_language_attributes() get language attributes WP 5.6
function get_language_attributes( $doctype = 'html' ) {
$attributes = array();
if ( function_exists( 'is_rtl' ) && is_rtl() ) {
$attributes[] = 'dir="rtl"';
}
$lang = get_bloginfo( 'language' );
if ( $lang ) {
if ( 'text/html' === get_option( 'html_type' ) || 'html' === $doctype ) {
$attributes[] = 'lang="' . esc_attr( $lang ) . '"';
}
if ( 'text/html' !== get_option( 'html_type' ) || 'xhtml' === $doctype ) {
$attributes[] = 'xml:lang="' . esc_attr( $lang ) . '"';
}
}
$output = implode( ' ', $attributes );
/**
* Filters the language attributes for display in the 'html' tag.
*
* @since 2.5.0
* @since 4.3.0 Added the `$doctype` parameter.
*
* @param string $output A space-separated list of language attributes.
* @param string $doctype The type of HTML document (xhtml|html).
*/
return apply_filters( 'language_attributes', $output, $doctype );
}