unzip_file
云策文档标注
概述
unzip_file 是一个 WordPress 过滤器,用于在解压 ZIP 存档后修改其结果。它允许开发者拦截和调整解压操作的返回值。
关键要点
- 过滤器名称:unzip_file
- 参数:$result(解压结果,true 或 WP_Error)、$file(ZIP 文件完整路径)、$to(解压目标路径)、$needed_dirs(所需创建的文件夹列表)、$required_space(所需空间,含 10% 缓冲)
- 用途:可用于自定义解压后的处理逻辑,如验证、日志记录或错误处理
代码示例
$result = apply_filters( 'unzip_file', true, $file, $to, $needed_dirs, $required_space );
原文内容
Filters the result of unzipping an archive.
Parameters
$resulttrue|WP_Error-
The result of unzipping the archive. True on success, otherwise WP_Error. Default true.
$filestring-
Full path and filename of ZIP archive.
$tostring-
Full path on the filesystem the archive was extracted to.
$needed_dirsstring[]-
A full list of required folders that were created.
$required_spacefloat-
The space required to unzip the file and copy its contents, with a 10% buffer.
Source
$result = apply_filters( 'unzip_file', true, $file, $to, $needed_dirs, $required_space );
Changelog
| Version | Description |
|---|---|
| 6.4.0 | Introduced. |