钩子文档

the_editor

💡 云策文档标注

概述

the_editor 是一个 WordPress 过滤器,用于修改编辑器输出的 HTML 标记。它允许开发者在插件或主题中自定义 TinyMCE 编辑器的显示内容。

关键要点

  • the_editor 过滤器用于过滤编辑器输出的 HTML 标记。
  • 参数 $output 是编辑器的 HTML 标记字符串。
  • 通过 apply_filters('the_editor', ...) 应用此过滤器,可以自定义编辑器界面。
  • 此过滤器自 WordPress 2.1.0 版本引入。
  • 相关函数 _WP_Editors::editor() 用于输出单个编辑器实例的 HTML。

代码示例

$the_editor = apply_filters(
    'the_editor',
    '' .
    $quicktags_toolbar .
    '%s'
);

📄 原文内容

Filters the HTML markup output that displays the editor.

Parameters

$outputstring
Editor’s HTML markup.

Source

$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>'
);

Changelog

Version Description
2.1.0 Introduced.

User Contributed Notes

  1. Skip to note 2 content

    More information
    The “the_editor() ” allows you to call the TinyMCE editor in your plugin or theme/page.

    Basic Usage

    the_editor( $content, $id, $prev_id, $media_buttons, $tab_index );

    Filtered Content

    $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>'
    );