# get_language_attributes()

URL: https://chugunov.pro/api-wordpress/functions/get_language_attributes/
Проверено на WordPress 6.9, обновлено 06.08.2026.
Источник: независимый русскоязычный справочник chugunov.pro. Не является официальной документацией WordPress.

Тип: функция.
Появился в версии: 4.3.0.

## Сигнатура

```php
get_language_attributes( string $doctype = 'html' ): string
```

## Описание

Формирует набор HTML-атрибутов, содержащих направление текста и языковую информацию для страницы.

## Параметры

- `$doctype` `string` — необязательный, по умолчанию `'html'`. Тип HTML-документа. Принимает 'xhtml' или 'html'. Значение по умолчанию 'html'.

## Возвращаемое значение

`string`

## Исходный код

Файл: `wp-includes/general-template.php:4539`

```php
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 );
}
```

## История изменений

- 4.3.0 — Introduced.

## Связанные

Использует: [`is_rtl`](https://chugunov.pro/api-wordpress/functions/is_rtl/), [`esc_attr`](https://chugunov.pro/api-wordpress/functions/esc_attr/), [`get_bloginfo`](https://chugunov.pro/api-wordpress/functions/get_bloginfo/), [`apply_filters`](https://chugunov.pro/api-wordpress/functions/apply_filters/), [`get_option`](https://chugunov.pro/api-wordpress/functions/get_option/).
Используется в: `WP_Sitemaps_Stylesheet::get_sitemap_stylesheet`, `WP_Sitemaps_Stylesheet::get_sitemap_index_stylesheet`, [`language_attributes`](https://chugunov.pro/api-wordpress/functions/language_attributes/), [`_default_wp_die_handler`](https://chugunov.pro/api-wordpress/functions/_default_wp_die_handler/).

Оригинал в официальной документации: https://developer.wordpress.org/reference/functions/get_language_attributes/
