钩子文档

pre_set_site_transient_{$transient}

💡 云策文档标注

概述

pre_set_site_transient_{$transient} 是一个动态 Hook,用于在设置站点瞬态值之前过滤其值。它允许开发者在瞬态被存储前修改或拦截数据。

关键要点

  • 这是一个动态 Hook,$transient 部分对应瞬态名称,例如 pre_set_site_transient_my_transient。
  • 参数包括 $value(站点瞬态的新值)和 $transient(瞬态名称)。
  • 从 WordPress 4.4.0 版本开始添加了 $transient 参数,最初在 3.0.0 版本引入。
  • 与 set_site_transient() 函数相关,用于设置或更新站点瞬态值。

代码示例

$value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );

📄 原文内容

Filters the value of a specific site transient before it is set.

Description

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

Parameters

$valuemixed
New value of site transient.
$transientstring
Transient name.

Source

$value = apply_filters( "pre_set_site_transient_{$transient}", $value, $transient );

Changelog

Version Description
4.4.0 The $transient parameter was added.
3.0.0 Introduced.