钩子文档

format_for_editor

💡 云策文档标注

概述

format_for_editor 是一个 WordPress 过滤器,用于在文本为编辑器格式化后对其进行过滤。它允许开发者修改格式化后的文本内容。

关键要点

  • 过滤器名称:format_for_editor
  • 参数:$text(格式化后的文本字符串)和 $default_editor(当前用户的默认编辑器,通常为 'html' 或 'tinymce')
  • 用途:在文本被 format_for_editor() 函数格式化后,应用自定义过滤逻辑
  • 相关函数:format_for_editor() 位于 wp-includes/formatting.php 中,用于格式化文本以供编辑器使用
  • 引入版本:WordPress 4.3.0

📄 原文内容

Filters the text after it is formatted for the editor.

Parameters

$textstring
The formatted text.
$default_editorstring
The default editor for the current user.
It is usually either 'html' or 'tinymce'.

Source

return apply_filters( 'format_for_editor', $text, $default_editor );

Changelog

Version Description
4.3.0 Introduced.