is_active_widget

The timeline below displays how wordpress function is_active_widget has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.5

/**
 * Determines whether a given widget is displayed on the front end.
 *
 * 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 {@see 'init'} or later.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_widgets The registered widgets.
 *
 * @param callable|false $callback      Optional. Widget callback to check. Default false.
 * @param string|false   $widget_id     Optional. Widget ID. Optional, but needed for checking.
 *                                      Default false.
 * @param string|false   $id_base       Optional. The base ID of a widget created by extending WP_Widget.
 *                                      Default false.
 * @param bool           $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'.
 *                                      Default true.
 * @return string|false ID of the sidebar in which the widget is active,
 *                      false if the widget is not active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || str_starts_with($sidebar, 'orphaned_widgets'))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] === $callback || $id_base && _get_widget_id_base($widget) === $id_base) {
                        if (!$widget_id || $widget_id === $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 6.3

/**
 * Determines whether a given widget is displayed on the front end.
 *
 * 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 {@see 'init'} or later.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_widgets
 *
 * @param callable|false $callback      Optional. Widget callback to check. Default false.
 * @param string|false   $widget_id     Optional. Widget ID. Optional, but needed for checking.
 *                                      Default false.
 * @param string|false   $id_base       Optional. The base ID of a widget created by extending WP_Widget.
 *                                      Default false.
 * @param bool           $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'.
 *                                      Default true.
 * @return string|false ID of the sidebar in which the widget is active,
 *                      false if the widget is not active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || str_starts_with($sidebar, 'orphaned_widgets'))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] === $callback || $id_base && _get_widget_id_base($widget) === $id_base) {
                        if (!$widget_id || $widget_id === $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 5.7

/**
 * Determines whether a given widget is displayed on the front end.
 *
 * 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 {@see 'init'} or later.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_widgets
 *
 * @param callable|false $callback      Optional. Widget callback to check. Default false.
 * @param string|false   $widget_id     Optional. Widget ID. Optional, but needed for checking.
 *                                      Default false.
 * @param string|false   $id_base       Optional. The base ID of a widget created by extending WP_Widget.
 *                                      Default false.
 * @param bool           $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'.
 *                                      Default true.
 * @return string|false ID of the sidebar in which the widget is active,
 *                      false if the widget is not active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] === $callback || $id_base && _get_widget_id_base($widget) === $id_base) {
                        if (!$widget_id || $widget_id === $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 5.5

/**
 * Determines whether a given widget is displayed on the front end.
 *
 * 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 {@see 'init'} or later.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_widgets
 *
 * @param callable|false $callback      Optional, Widget callback to check. Default false.
 * @param int|false      $widget_id     Optional. Widget ID. Optional, but needed for checking. Default false.
 * @param string|false   $id_base       Optional. The base ID of a widget created by extending WP_Widget. Default false.
 * @param bool           $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'. Default true.
 * @return string|false False if widget is not active or id of sidebar in which the widget is active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] === $callback || $id_base && _get_widget_id_base($widget) === $id_base) {
                        if (!$widget_id || $widget_id === $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 5.4

/**
 * Determines whether a given widget is displayed on the front end.
 *
 * 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 {@see 'init'} or later.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_widgets
 *
 * @param string|false $callback      Optional, Widget callback to check. Default false.
 * @param int|false    $widget_id     Optional. Widget ID. Optional, but needed for checking. Default false.
 * @param string|false $id_base       Optional. The base ID of a widget created by extending WP_Widget. Default false.
 * @param bool         $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'. Default true.
 * @return string|false False if widget is not active or id of sidebar in which the widget is active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] === $callback || $id_base && _get_widget_id_base($widget) === $id_base) {
                        if (!$widget_id || $widget_id === $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 5.1

/**
 * Determines whether a given widget is displayed on the front end.
 *
 * 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 {@see 'init'} or later.
 *
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/
 * Conditional Tags} article in the Theme Developer Handbook.
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_widgets
 *
 * @param string|false $callback      Optional, Widget callback to check. Default false.
 * @param int|false    $widget_id     Optional. Widget ID. Optional, but needed for checking. Default false.
 * @param string|false $id_base       Optional. The base ID of a widget created by extending WP_Widget. Default false.
 * @param bool         $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'. Default true.
 * @return string|false False if widget is not active or id of sidebar in which the widget is active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback || $id_base && _get_widget_id_base($widget) == $id_base) {
                        if (!$widget_id || $widget_id == $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 5.0

/**
 * Determines whether a given widget is displayed on the front end.
 *
 * 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 {@see 'init'} or later.
 * 
 * For more information on this and similar theme functions, check out
 * the {@link https://developer.wordpress.org/themes/basics/conditional-tags/ 
 * Conditional Tags} article in the Theme Developer Handbook.
 * 
 * @since 2.2.0
 *
 * @global array $wp_registered_widgets
 *
 * @param string|false $callback      Optional, Widget callback to check. Default false.
 * @param int|false    $widget_id     Optional. Widget ID. Optional, but needed for checking. Default false.
 * @param string|false $id_base       Optional. The base ID of a widget created by extending WP_Widget. Default false.
 * @param bool         $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'. Default true.
 * @return string|false False if widget is not active or id of sidebar in which the widget is active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback || $id_base && _get_widget_id_base($widget) == $id_base) {
                        if (!$widget_id || $widget_id == $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 4.6

/**
 * Whether widget is displayed on the front end.
 *
 * 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 {@see 'init'} or later.
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_widgets
 *
 * @param string|false $callback      Optional, Widget callback to check. Default false.
 * @param int|false    $widget_id     Optional. Widget ID. Optional, but needed for checking. Default false.
 * @param string|false $id_base       Optional. The base ID of a widget created by extending WP_Widget. Default false.
 * @param bool         $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'. Default true.
 * @return string|false False if widget is not active or id of sidebar in which the widget is active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback || $id_base && _get_widget_id_base($widget) == $id_base) {
                        if (!$widget_id || $widget_id == $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 4.5

/**
 * Whether widget is displayed on the front end.
 *
 * 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.
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_widgets
 *
 * @param string|false $callback      Optional, Widget callback to check. Default false.
 * @param int|false    $widget_id     Optional. Widget ID. Optional, but needed for checking. Default false.
 * @param string|false $id_base       Optional. The base ID of a widget created by extending WP_Widget. Default false.
 * @param bool         $skip_inactive Optional. Whether to check in 'wp_inactive_widgets'. Default true.
 * @return string|false False if widget is not active or id of sidebar in which the widget is active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback || $id_base && _get_widget_id_base($widget) == $id_base) {
                        if (!$widget_id || $widget_id == $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 4.3

/**
 * Whether widget is displayed on the front-end.
 *
 * 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.
 *
 * @since 2.2.0
 *
 * @global array $wp_registered_widgets
 *
 * @param string $callback      Optional, Widget callback to check.
 * @param int    $widget_id     Optional, but needed for checking. Widget ID.
 * @param string $id_base       Optional, the base ID of a widget created by extending WP_Widget.
 * @param bool   $skip_inactive Optional, whether to check in 'wp_inactive_widgets'.
 * @return string|false False if widget is not active or id of sidebar in which the widget is active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback || $id_base && _get_widget_id_base($widget) == $id_base) {
                        if (!$widget_id || $widget_id == $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 4.0

/**
 * Whether widget is displayed on the front-end.
 *
 * 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.
 *
 * @since 2.2.0
 *
 * @param string $callback Optional, Widget callback to check.
 * @param int $widget_id Optional, but needed for checking. Widget ID.
 * @param string $id_base Optional, the base ID of a widget created by extending WP_Widget.
 * @param bool $skip_inactive Optional, whether to check in 'wp_inactive_widgets'.
 * @return mixed false if widget is not active or id of sidebar in which the widget is active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && ('wp_inactive_widgets' === $sidebar || 'orphaned_widgets' === substr($sidebar, 0, 16))) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback || $id_base && _get_widget_id_base($widget) == $id_base) {
                        if (!$widget_id || $widget_id == $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}

WordPress Version: 3.7

/**
 * Whether widget is displayed on the front-end.
 *
 * 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.
 *
 * @since 2.2.0
 *
 * @param string $callback Optional, Widget callback to check.
 * @param int $widget_id Optional, but needed for checking. Widget ID.
 * @param string $id_base Optional, the base ID of a widget created by extending WP_Widget.
 * @param bool $skip_inactive Optional, whether to check in 'wp_inactive_widgets'.
 * @return mixed false if widget is not active or id of sidebar in which the widget is active.
 */
function is_active_widget($callback = false, $widget_id = false, $id_base = false, $skip_inactive = true)
{
    global $wp_registered_widgets;
    $sidebars_widgets = wp_get_sidebars_widgets();
    if (is_array($sidebars_widgets)) {
        foreach ($sidebars_widgets as $sidebar => $widgets) {
            if ($skip_inactive && 'wp_inactive_widgets' == $sidebar) {
                continue;
            }
            if (is_array($widgets)) {
                foreach ($widgets as $widget) {
                    if ($callback && isset($wp_registered_widgets[$widget]['callback']) && $wp_registered_widgets[$widget]['callback'] == $callback || $id_base && _get_widget_id_base($widget) == $id_base) {
                        if (!$widget_id || $widget_id == $wp_registered_widgets[$widget]['id']) {
                            return $sidebar;
                        }
                    }
                }
            }
        }
    }
    return false;
}