钩子文档

themes_api

💡 云策文档标注

概述

themes_api 过滤器用于控制是否覆盖 WordPress.org 主题 API 的默认请求。返回非 false 值将短路 API 请求,允许开发者自定义响应。

关键要点

  • 过滤器名称:themes_api
  • 作用:允许覆盖 WordPress.org 主题 API 的请求,返回自定义数据
  • 参数:$override(默认 false,可返回对象或数组)、$action(如 'theme_information')、$args(查询参数)
  • 返回值:非 false 值将短路 API 请求,根据 $action 返回对象或数组

注意事项

  • 当 $action 为 'query_themes'、'theme_information' 或 'feature_list' 时,必须返回对象
  • 当 $action 为 'hot_tags' 时,应返回数组

📄 原文内容

Filters whether to override the WordPress.org Themes API.

Description

Returning a non-false value will effectively short-circuit the WordPress.org API request.

If $action is ‘query_themes’, ‘theme_information’, or ‘feature_list’, an object MUST be passed. If $action is ‘hot_tags’, an array should be passed.

Parameters

$overridefalse|object|array
Whether to override the WordPress.org Themes API. Default false.
$actionstring
Requested action. Likely values are 'theme_information', 'feature_list', or 'query_themes'.
$argsobject
Arguments used to query for installer pages from the Themes API.

Source

$res = apply_filters( 'themes_api', false, $action, $args );

Changelog

Version Description
2.8.0 Introduced.