__return_empty_string()
云策文档标注
概述
__return_empty_string() 是一个 WordPress 核心函数,用于返回空字符串,常用于过滤器(filter)中作为回调函数。
关键要点
- 函数返回空字符串,类型为 string。
- 主要用于简化过滤器回调,例如在 add_filter() 中直接使用。
- 自 WordPress 3.7.0 版本引入。
代码示例
// 在 'example_filter' 上添加过滤器,返回空字符串
add_filter( 'example_filter', '__return_empty_string' );注意事项
函数名遵循 WordPress 命名约定,带有双下划线前缀;相关函数有 __return_null()。
原文内容
Returns an empty string.
Description
Useful for returning an empty string to filters easily.
See also
Source
function __return_empty_string() { // phpcs:ignore WordPress.NamingConventions.ValidFunctionName.FunctionDoubleUnderscore,PHPCompatibility.FunctionNameRestrictions.ReservedFunctionNames.FunctionDoubleUnderscore
return '';
}
Changelog
| Version | Description |
|---|---|
| 3.7.0 | Introduced. |