钩子文档

wp_using_themes

💡 云策文档标注

概述

wp_using_themes 是一个 WordPress 过滤器,用于控制当前请求是否应使用主题。它基于 WP_USE_THEMES 常量的定义和值来工作。

关键要点

  • 这是一个过滤器,允许开发者修改当前请求是否使用主题的布尔值。
  • 默认行为依赖于 WP_USE_THEMES 常量的定义和值。
  • 在 WordPress 5.1.0 版本中引入。

代码示例

return apply_filters( 'wp_using_themes', defined( 'WP_USE_THEMES' ) && WP_USE_THEMES );

注意事项

  • 相关函数 wp_using_themes() 位于 wp-includes/load.php 中,用于确定主题使用情况。
  • 开发者可以通过添加过滤器回调来覆盖默认行为,例如在特定条件下禁用主题。

📄 原文内容

Filters whether the current request should use themes.

Parameters

$wp_using_themesbool
Whether the current request should use themes.

Source

return apply_filters( 'wp_using_themes', defined( 'WP_USE_THEMES' ) && WP_USE_THEMES );

Changelog

Version Description
5.1.0 Introduced.