钩子文档

rest_oembed_ttl

💡 云策文档标注

概述

rest_oembed_ttl 是一个 WordPress 过滤器,用于修改 REST API oEmbed 代理端点的 TTL(生存时间)值。它类似于 oembed_ttl 过滤器,但专门针对 REST API 上下文。

关键要点

  • 过滤器名称:rest_oembed_ttl
  • 用途:调整 oEmbed 代理端点的缓存时间,以秒为单位
  • 参数:$time(整数,TTL 秒数)、$url(字符串,嵌入 URL)、$args(数组,嵌入请求参数)
  • 默认值:DAY_IN_SECONDS(一天秒数)
  • 引入版本:WordPress 4.8.0
  • 相关函数:WP_oEmbed_Controller::get_proxy_item()

代码示例

$ttl = apply_filters( 'rest_oembed_ttl', DAY_IN_SECONDS, $url, $args );

📄 原文内容

Filters the oEmbed TTL value (time to live).

Description

Similar to the ‘oembed_ttl’ filter, but for the REST API oEmbed proxy endpoint.

Parameters

$timeint
Time to live (in seconds).
$urlstring
The attempted embed URL.
$argsarray
An array of embed request arguments.

Source

$ttl = apply_filters( 'rest_oembed_ttl', DAY_IN_SECONDS, $url, $args );

Changelog

Version Description
4.8.0 Introduced.