wp_upload_bits
云策文档标注
概述
wp_upload_bits 是一个 WordPress 过滤器,用于控制是否将上传数据视为错误。开发者可以通过此过滤器中断上传处理并返回自定义错误信息。
关键要点
- 过滤器 wp_upload_bits 允许开发者检查上传数据,并决定是否将其视为错误。
- 如果过滤器返回非数组值(如字符串),将中断上传准备过程,直接返回该值作为错误消息。
- 参数 $upload_bits_error 可以是数组(包含上传数据)或字符串(错误消息)。
- 此过滤器在 wp_upload_bits() 函数中使用,用于在 WordPress 上传文件夹中创建文件。
- 自 WordPress 3.0.0 版本引入。
原文内容
Filters whether to treat the upload bits as an error.
Description
Returning a non-array from the filter will effectively short-circuit preparing the upload bits and return that value instead. An error message should be returned as a string.
Parameters
$upload_bits_errorarray|string-
An array of upload bits data, or error message to return.
Source
$upload_bits_error = apply_filters(
'wp_upload_bits',
array(
'name' => $name,
'bits' => $bits,
'time' => $time,
)
);
Changelog
| Version | Description |
|---|---|
| 3.0.0 | Introduced. |