对即将编辑的文本采取行动。
原型
format_to_edit( string $content, bool $rich_text = false )
描述
$ content通过esc_textarea()运行,它使用htmlspecialchars()将特殊字符转换为HTML实体。如果$ richedit设置为true,则它只是’format_to_edit’过滤器的持有者。
参数
$content
(string)
(Required)
即将编辑的文字。
$rich_text
(bool)
(Optional)
是否应将$ content视为富文本,在这种情况下,它不会通过esc_textarea()传递。
返回值
(string)
过滤后的文本(可能还有htmlspecialchars())已经运行。
源文件
路径:wp-includes/formatting.php
<?php
...
function format_to_edit( $content, $rich_text = false ) {
/**
* Filters the text to be formatted for editing.
*
* @since 1.2.0
*
* @param string $content The text, prior to formatting for editing.
*/
$content = apply_filters( 'format_to_edit', $content );
if ( ! $rich_text )
$content = esc_textarea( $content );
return $content;
}
...
?>
其他
英文文档:https://developer.wordpress.org/reference/functions/format_to_edit/