格式化编辑器的文本。
原型
format_for_editor( string $text, string $default_editor = null )
描述
通常,浏览器会将textarea中的所有内容视为文本,但HTML实体编码<,>和仍然是一个好主意
参考:
- _WP_Editors::editor()
参数
$text
(string)
(Required)
要格式化的文本。
$default_editor
(string)
(Optional)
当前用户的默认编辑器。它通常是’html’或’tinymce’。
返回值
(string)
应用过滤器后的格式化文本。
源文件
路径:wp-includes/formatting.php
<?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 );
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/format_for_editor/