钩子文档

update_attached_file

💡 云策文档标注

概述

update_attached_file 是一个 WordPress 过滤器钩子,用于修改附件文件的路径。它允许开发者在更新附件文件路径时进行自定义处理。

关键要点

  • 这是一个过滤器钩子,用于过滤要更新的附件文件路径。
  • 接受两个参数:$file(文件路径字符串)和 $attachment_id(附件 ID)。
  • 在 update_attached_file() 函数中被调用,用于基于附件 ID 更新附件文件路径。
  • 自 WordPress 2.1.0 版本引入。

代码示例

$file = apply_filters( 'update_attached_file', $file, $attachment_id );

📄 原文内容

Filters the path to the attached file to update.

Parameters

$filestring
Path to the attached file to update.
$attachment_idint
Attachment ID.

Source

$file = apply_filters( 'update_attached_file', $file, $attachment_id );

Changelog

Version Description
2.1.0 Introduced.