首页 WordPress函数大全 is_active_widget()

is_active_widget()

2020-05-02 / 3315阅 / 悠然

如何你看完本文还不知道如何使用该函数,可以联系我定制视频教程,50元/个函数,学不会全额退款

is_active_widget( string|false $callback = false, int|false $widget_id = false, string|false $id_base = false, bool $skip_inactive = true )

Determines whether a given widget is displayed>

Contents

  • Description
    • Parameters
    • Return
    • Source
    • Changelog
  • Related
    • Uses
    • Used By
  • User Contributed Notes

描述

Either $callback or $id_base can be used $id_base is the first argument when extending WP_Widget class Without the optional $widget_id parameter, returns the ID of the first sidebar in which the first instance of the widget with the given callback or $id_base is found. With the $widget_id parameter, returns the ID of the sidebar where the widget with that callback/$id_base AND that ID is found.

NOTE: $widget_id and $id_base are the same for single widgets. To be effective this function has to run after widgets have initialized, at action ‘init’ or later.

For more information> Conditional Tags article in the Theme Developer Handbook.

参数

$callback

(string|false)
(Optional)
Widget callback to check.

Default value: false

$widget_id

(int|false)
(Optional)
Widget ID. Optional, but needed for checking.

Default value: false

$id_base

(string|false)
(Optional)
The base ID of a widget created by extending WP_Widget.

Default value: false

$skip_inactive

(bool)
(Optional)
Whether to check in 'wp_inactive_widgets'.

Default value: true

返回

(string|false) False if widget is not active or id of sidebar in which the widget is active.

大家谈论
    我的见解