the_editor │ хук-фильтр │ WP 2.1.0

Изменяет HTML-разметку редактора WordPress (HTML, к которому затем подключаются TinyMCE и Quicktags).

Этот хук может пригодиться, когда в HTML-редактор нужно добавить нестандартный атрибут тега или какой-то элемент. Это можно сделать с помощью str_replace().

Использование

add_filter( 'the_editor', 'wp_kama_the_editor_filter' );

/**
 * Function for `the_editor` filter-hook.
 * 
 * @param string $output Editor's HTML markup.
 *
 * @return string
 */
function wp_kama_the_editor_filter( $output ){
	// filter...
	return $output;
}
$output(строка)

HTML код визуального редактора.

По умолчанию параметр содержит такой HTML:

'<div id="wp-' . $editor_id_attr . '-editor-container" class="wp-editor-container">' .
		$quicktags_toolbar .
		'<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . esc_attr( $set['textarea_name'] ) . '" ' .
		'id="' . $editor_id_attr . '">%s</textarea></div>'

Примеры

#1 Заменяем часть формы редактирования поста

add_filter('the_editor', 'the_editor_demo_funct');
function the_editor_demo_funct( $wrapper ) {

	if ( false !== strpos($wrapper, 'id="content"') ) {
		$wrapper = str_replace('</textarea>', '</textarea><p>Вписывайте текст в это поле.</p>', $wrapper );
	}

	return $wrapper;
}

Список изменений

С версии 2.1.0 Введена.

Где вызывается хук

_WP_Editors::editor()
the_editor
wp-includes/class-wp-editor.php 267-273
$the_editor = apply_filters(
	'the_editor',
	'<div id="wp-' . $editor_id_attr . '-editor-container" class="wp-editor-container">' .
	$quicktags_toolbar .
	'<textarea' . $editor_class . $height . $tabindex . $autocomplete . ' cols="40" name="' . esc_attr( $set['textarea_name'] ) . '" ' .
	'id="' . $editor_id_attr . '">%s</textarea></div>'
);

Где используется хук в WordPress

Использование не найдено.