# format_for_editor()

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

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

## Сигнатура

```php
format_for_editor( string $text, string $default_editor = null ): string
```

## Описание

Generally the browsers treat everything inside a textarea as text, but it is still a good idea to HTML entity encode `<`, `>` and `&` in the content.

The filter [‘format_for_editor’](https://developer.wordpress.org/reference/hooks/format_for_editor/) is applied here. If `$text` is empty the filter will be applied to an empty string.[See also](#see-also)
- [_WP_Editors::editor()](https://developer.wordpress.org/reference/classes/_WP_Editors/editor/)

## Параметры

- `$text` `string` — обязательный. Текст для форматирования.
- `$default_editor` `string` — необязательный, по умолчанию `null`. Редактор по умолчанию для текущего пользователя.
  
  Обычно это либо 'html', либо 'tinymce'.

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

`string`

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

Файл: `wp-includes/formatting.php:4394`

```php
function format_for_editor( $text, $default_editor = null ) {
	if ( $text ) {
		$text = htmlspecialchars( $text, ENT_NOQUOTES, get_option( 'blog_charset' ) );
	}

	/**
	 * Filters the text after it is formatted for the editor.
	 *
	 * @since 4.3.0
	 *
	 * @param string $text           The formatted text.
	 * @param string $default_editor The default editor for the current user.
	 *                               It is usually either 'html' or 'tinymce'.
	 */
	return apply_filters( 'format_for_editor', $text, $default_editor );
}
```

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

- 4.3.0 — Introduced.

## Связанные

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

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