wpseek.com
WordPress开发者和主题制作者的搜索引擎



format_for_editor › WordPress Function

Since4.3.0
已弃用n/a
format_for_editor ( $text, $default_editor = null )
参数: (2)
  • (string) $text The text to be formatted.
    Required: Yes
  • (string) $default_editor The default editor for the current user. It is usually either 'html' or 'tinymce'.
    Required: No
    默认: null
查看:
  • _WP_Editors::editor()
返回:
  • (string) The formatted text after filter is applied.
定义在:
文档:

Formats text for the editor.

Generally the browsers treat everything inside a textarea as text, but it is still a good idea to HTML entity encode </code>, > and & in the content. The filter {@see 'format_for_editor'} is applied here. If $text is empty the filter will be applied to an empty string.


源码

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