format_to_edit

函数
format_to_edit ( $content, $rich_text = false )
参数
  • (string) $content The text about to be edited.
    Required:
  • (bool) $rich_text Optional. Whether `$content` should be considered rich text, in which case it would not be passed through esc_textarea(). Default false.
    Required:
    Default: false
返回值
  • (string) The text after the filter (and possibly htmlspecialchars()) has been run.
定义位置
相关方法
format_for_editorformat_to_postload_image_to_editget_term_to_editget_post_to_edit
引入
0.71
弃用
-

format_to_edit: 这个函数用来格式化文本以便在WordPress编辑器中显示。它将某些HTML实体转换为它们相应的字符。

对即将被编辑的文本采取行动。

$content通过esc_textarea()运行,它使用htmlspecialchars()将特殊字符转换成HTML实体。如果`$richedit`被设置为true,它只是{@see ‘format_to_edit’}过滤器的持有者。

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;
}

常见问题

FAQs
查看更多 >