pre_upload_error
云策文档标注
概述
pre_upload_error 是一个 WordPress 过滤器,用于在 XML-RPC 媒体上传过程中进行预占或拦截。开发者可以通过此 Hook 控制上传流程,返回真值将直接中断上传并返回 500 错误。
关键要点
- pre_upload_error 过滤器允许在 XML-RPC 媒体上传前进行干预,返回真值(如 true 或非空值)会短路上传过程,并返回该值作为 500 错误。
- 参数 $error 是一个布尔值,默认为 false,表示是否预占上传;开发者可以修改此值以控制上传行为。
- 此过滤器主要用于 wp_xmlrpc_server::mw_newMediaObject() 方法中,用于文件上传的自定义处理。
- 自 WordPress 2.1.0 版本引入,是 XML-RPC 相关开发中的重要 Hook。
原文内容
Filters whether to preempt the XML-RPC media upload.
Description
Returning a truthy value will effectively short-circuit the media upload, returning that value as a 500 error instead.
Parameters
$errorbool-
Whether to pre-empt the media upload. Default false.
Source
$upload_err = apply_filters( 'pre_upload_error', false );
Changelog
| Version | Description |
|---|---|
| 2.1.0 | Introduced. |