format_to_edit()

对内容执行htmlspecialchars操作,转化成 HTML 实体 描述 译文 处理将要被编辑的文本。

描述

译文

处理将要被编辑的文本。

$richedit未赋值时只是一个存储“format_to_edit”过滤器的文件夹。如果$richedit被设为true,那么 htmlspecialchar会在文本上运行并将特定字符转换为 HTML实体。

原文

如果参数 $richedit 为 false,format_to_post() 这个函数仅仅包含了一个名为 format_to_edit 的 fliter

如果参数 $richedit 为 true,则它将继续对内容执行 htmlspecialchars 操作,转化成 HTML 实体。

用法

<?php format_to_edit( $content, $richedit ) ?>

参数

$content

(string) (必填) 将编辑的文本

默认值: None

$richedit

(boolean) (可选) 是否 $content 将进行 htmlspecialchars 操作。

默认值: false

返回值

(string) 

编辑之后的文本。

历史

添加于 版本: 0.71

源文件

format_to_edit() 函数的代码位于 wp-includes/formatting.php.

* Acts on text which is about to be edited.
*
* The $content is run through esc_textarea(), which uses htmlspecialchars()
* to convert special characters to HTML entities. If $richedit is set to true,
* it is simply a holder for the ‘format_to_edit’ filter.
*
* @since 0.71
*
* @param string $content  The text about to be edited.
* @param bool   $richedit Whether the $content should not pass through htmlspecialchars(). Default false (meaning it will be passed).
* @return string The text after the filter (and possibly htmlspecialchars()) has been run.
*/

function format_to_edit( $content, $richedit = false ) {

/**

* Filter 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 ( ! $richedit )

$content = esc_textarea( $content );

return $content;

}

原文:http://codex.wordpress.org/Function_Reference/format_to_edit

0 条回复 A文章作者 M管理员
    暂无讨论,说说你的看法吧
个人中心
购物车
优惠劵
今日签到
有新私信 私信列表
搜索