函数文档

format_to_post()

💡 云策文档标注

概述

format_to_post() 是一个已弃用的 WordPress 函数,曾用于在插入数据库前转义字符串,但自 3.9.0 版本起不再执行此功能,直接返回原文本。

关键要点

  • 该函数自 WordPress 3.9.0 版本起被弃用,使用 wpdb::prepare() 替代。
  • 函数接受一个字符串参数 $content,并直接返回相同的文本,无实际转义操作。
  • 调用时会触发 _deprecated_function() 警告,提示开发者更新代码。

代码示例

function format_to_post( $content ) {
    _deprecated_function( __FUNCTION__, '3.9.0' );
    return $content;
}

注意事项

自 3.9.0 版本起,此函数已过时,建议在开发中避免使用,改用 wpdb::prepare() 进行数据库查询的字符串转义,以确保安全性和兼容性。


📄 原文内容

Formerly used to escape strings before inserting into the DB.

Description

Has not performed this function for many, many years. Use wpdb::prepare() instead.

Parameters

$contentstringrequired
The text to format.

Return

string The very same text.

Source

function format_to_post( $content ) {
	_deprecated_function( __FUNCTION__, '3.9.0' );
	return $content;
}

Changelog

Version Description
3.9.0 Deprecated.
0.71 Introduced.