format_for_editor() - WordPress 函数参考中文文档

返回介绍

format_for_editor()

发布于 2017-09-10 字数2133 浏览 975 评论 0

format_for_editor( string $text,  string $default_editor = null )

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 <, > and & in the content.

The filter ‘format_for_editor’ is applied here. If $text is empty the filter will be applied to an empty string.


参数

$text

(string)
(Required)
The text to be formatted.

$default_editor

(string)
(Optional)
The default editor for the current user. It is usually either ‘html’ or ‘tinymce’.

Default value: null


返回值

(string) The formatted text after filter is applied.


源代码

File: wp-includes/formatting.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 );
}

更新日志

Version 描述
4.3.0 Introduced.

相关函数

Uses

  • wp-includes/formatting.php:
    format_for_editor
  • wp-includes/plugin.php:
    apply_filters()
  • wp-includes/option.php:
    get_option()

User Contributed Notes

上一篇:format_code_lang()

下一篇:format_to_edit()

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

目前还没有任何评论,快来抢沙发吧!