钩子文档

oembed_ttl

💡 云策文档标注

概述

oembed_ttl 过滤器用于修改 oEmbed 数据的缓存时间(TTL),以控制嵌入内容的更新频率。

关键要点

  • 过滤器名称:oembed_ttl
  • 参数:$time(TTL 秒数)、$url(嵌入 URL)、$attr(短代码属性数组)、$post_id(文章 ID)
  • 默认 TTL 值:DAY_IN_SECONDS(一天秒数)
  • 相关函数:WP_Embed::shortcode()
  • 引入版本:4.0.0

代码示例

$ttl = apply_filters( 'oembed_ttl', DAY_IN_SECONDS, $url, $attr, $post_id );

📄 原文内容

Filters the oEmbed TTL value (time to live).

Parameters

$timeint
Time to live (in seconds).
$urlstring
The attempted embed URL.
$attrarray
An array of shortcode attributes.
$post_idint
Post ID.

Source

$ttl = apply_filters( 'oembed_ttl', DAY_IN_SECONDS, $url, $attr, $post_id );

Changelog

Version Description
4.0.0 Introduced.