钩子文档

is_active_sidebar

💡 云策文档标注

概述

is_active_sidebar 是一个 WordPress 过滤器,用于动态判断侧边栏是否“活跃”,即是否包含任何小部件。它允许开发者自定义侧边栏活跃状态的逻辑。

关键要点

  • 过滤器名称:is_active_sidebar
  • 参数:$is_active_sidebar(布尔值,表示侧边栏是否应被视为活跃)和 $index(整数或字符串,动态侧边栏的索引、名称或ID)
  • 用途:修改 is_active_sidebar() 函数的返回值,控制侧边栏活跃状态
  • 相关函数:is_active_sidebar() 用于确定侧边栏是否包含小部件
  • 引入版本:WordPress 3.9.0

📄 原文内容

Filters whether a dynamic sidebar is considered “active”.

Parameters

$is_active_sidebarbool
Whether or not the sidebar should be considered “active”.
In other words, whether the sidebar contains any widgets.
$indexint|string
Index, name, or ID of the dynamic sidebar.

Source

return apply_filters( 'is_active_sidebar', $is_active_sidebar, $index );

Changelog

Version Description
3.9.0 Introduced.