format_for_editor

函数
format_for_editor ( $text, $default_editor = null )
参数
  • (string) $text The text to be formatted.
    Required:
  • (string) $default_editor The default editor for the current user. It is usually either 'html' or 'tinymce'.
    Required:
    Default: null
返回值
  • (string) The formatted text after filter is applied.
相关
  • _WP_Editors::editor()
定义位置
相关方法
format_to_editedit_form_image_editormedia_send_to_editorthe_editorimage_constrain_size_for_editor
引入
4.3.0
弃用
-

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

为编辑器形成文本。

一般来说,浏览器会将文本框内的所有内容视为文本,但在内容中对HTML实体编码“和`&`仍然是一个好主意。

过滤器{@see ‘format_for_editor’}在这里被应用。如果`$text`是空的,过滤器将被应用于一个空字符串。

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
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 );
}
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 ); }
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 );
}

常见问题

FAQs
查看更多 >