is_active_widget()检查是否小工具/侧边栏已经在前端显示

目录

描述

This Conditional Tag checks whether widget is displayed on the front-end.

To be effective this function has to run after widgets have initialized, at action 'init' or later.

is_active_widget() 描述

用法

is_active_widget() 用法

参数

$callback

(string) (可选) Widget callback to check.

默认值: False

$widget_id

(int) (可选) Widget ID. Needed for checking.

默认值: None

$id_base

(string) (可选) Base ID of a widget created by extending WP_Widget.

默认值: None

$skip_inactive

(boolean) (可选) Whether to check in 'wp_inactive_widgets'.

默认值: True

is_active_widget() 参数

返回值

(mixed) 

Returns false if the specified widget is not active, or the id of the sidebar in which the widget is active. If the callback is non-unique you can optionally specify the ID of the widget.

is_active_widget() 返回值

示例

Only load a script when the widget is active

is_active_widget() 示例

历史

添加于 版本: 2.2.0

is_active_widget() 历史

源文件

is_active_widget() 函数的代码位于 wp-includes/widgets.php.

is_active_widget() 源文件

相关