钩子文档

set_transient_{$transient}

💡 云策文档标注

概述

set_transient_{$transient} 是一个 WordPress 动态 Hook,在特定瞬态值设置后触发,允许开发者执行自定义操作。

关键要点

  • 这是一个动态 Hook,名称中的 $transient 部分对应瞬态名称。
  • Hook 参数包括 $value(瞬态值)、$expiration(过期时间,以秒为单位)和 $transient(瞬态名称)。
  • 主要用于 set_transient() 函数调用后,可用于日志记录、缓存同步或其他扩展功能。

注意事项

  • Hook 名称是动态的,使用时需替换 $transient 为具体瞬态名,例如 set_transient_my_transient。
  • 参数 $transient 在 WordPress 4.4.0 版本中添加,$value 和 $expiration 在 3.6.0 版本中添加。

📄 原文内容

Fires after the value for a specific transient has been set.

Description

The dynamic portion of the hook name, $transient, refers to the transient name.

Parameters

$valuemixed
Transient value.
$expirationint
Time until expiration in seconds.
$transientstring
The name of the transient.

Source

do_action( "set_transient_{$transient}", $value, $expiration, $transient );

Changelog

Version Description
4.4.0 The $transient parameter was added.
3.6.0 The $value and $expiration parameters were added.
3.0.0 Introduced.