pre_unzip_file
云策文档标注
概述
pre_unzip_file 是一个 WordPress 过滤器,允许开发者自定义 ZIP 档案的解压过程,覆盖默认行为。它用于在解压操作前拦截并处理,提供参数如文件路径、目标路径和所需空间等。
关键要点
- 过滤器名称:pre_unzip_file,用于覆盖 ZIP 档案的解压过程
- 参数包括:$result(结果,可为 null、true 或 WP_Error)、$file(ZIP 文件完整路径)、$to(解压目标路径)、$needed_dirs(需创建的文件夹列表)、$required_space(所需空间,含 10% 缓冲)
- 返回类型:成功时返回 true,失败时返回 WP_Error,默认 null
- 相关函数:_unzip_file_ziparchive() 和 _unzip_file_pclzip(),分别使用 ZipArchive 和 PclZip 库进行解压
- 引入版本:WordPress 6.4.0
代码示例
$pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space );
原文内容
Filters archive unzipping to override with a custom process.
Parameters
$resultnull|true|WP_Error-
The result of the override. True on success, otherwise WP Error. Default null.
$filestring-
Full path and filename of ZIP archive.
$tostring-
Full path on the filesystem to extract archive to.
$needed_dirsstring[]-
A full list of required folders that need to be created.
$required_spacefloat-
The space required to unzip the file and copy its contents, with a 10% buffer.
Source
$pre = apply_filters( 'pre_unzip_file', null, $file, $to, $needed_dirs, $required_space );
Changelog
| Version | Description |
|---|---|
| 6.4.0 | Introduced. |