# prep_atom_text_construct()

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

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

## Сигнатура

```php
prep_atom_text_construct( string $data ): array
```

## Описание

Сообщает, является ли тип text, HTML или XHTML согласно разделу 3.1 RFC 4287.
В WordPress text определяется как не содержащий разметки, XHTML — как «правильно построенный», а HTML — как «суп из тегов» (то есть всё остальное).
К значениям XHTML добавляются обрамляющие теги div согласно разделу 3.1.1.3.

## Параметры

- `$data` `string` — обязательный. Входная строка.

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

`array`

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

Файл: `wp-includes/feed.php:588`

```php
function prep_atom_text_construct( $data ) {
	if ( ! str_contains( $data, '<' ) && ! str_contains( $data, '&' ) ) {
		return array( 'text', $data );
	}

	if ( ! function_exists( 'xml_parser_create' ) ) {
		wp_trigger_error( '', __( "PHP's XML extension is not available. Please contact your hosting provider to enable PHP's XML extension." ) );

		return array( 'html', "<![CDATA[$data]]>" );
	}

	$parser = xml_parser_create();
	xml_parse( $parser, '<div>' . $data . '</div>', true );
	$code = xml_get_error_code( $parser );

	if ( PHP_VERSION_ID < 80000 ) { // xml_parser_free() has no effect as of PHP 8.0.
		xml_parser_free( $parser );
	}

	unset( $parser );

	if ( ! $code ) {
		if ( ! str_contains( $data, '<' ) ) {
			return array( 'text', $data );
		} else {
			$data = "<div xmlns='http://www.w3.org/1999/xhtml'>$data</div>";
			return array( 'xhtml', $data );
		}
	}

	if ( ! str_contains( $data, ']]>' ) ) {
		return array( 'html', "<![CDATA[$data]]>" );
	} else {
		return array( 'html', htmlspecialchars( $data ) );
	}
}
```

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

- 2.5.0 — Introduced.

## Связанные

Использует: [`wp_trigger_error`](https://chugunov.pro/api-wordpress/functions/wp_trigger_error/), [`__`](https://chugunov.pro/api-wordpress/functions/__/).

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