is_active_sidebar

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

WordPress Version: 5.5

/**
 * Determines whether a sidebar contains widgets.
 *
 * 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.8.0
 *
 * @param string|int $index Sidebar name, id or number to check.
 * @return bool True if the sidebar has widgets, false otherwise.
 */
function is_active_sidebar($index)
{
    $index = is_int($index) ? "sidebar-{$index}" : sanitize_title($index);
    $sidebars_widgets = wp_get_sidebars_widgets();
    $is_active_sidebar = !empty($sidebars_widgets[$index]);
    /**
     * Filters whether a dynamic sidebar is considered "active".
     *
     * @since 3.9.0
     *
     * @param bool       $is_active_sidebar Whether or not the sidebar should be considered "active".
     *                                      In other words, whether the sidebar contains any widgets.
     * @param int|string $index             Index, name, or ID of the dynamic sidebar.
     */
    return apply_filters('is_active_sidebar', $is_active_sidebar, $index);
}

WordPress Version: 5.1

/**
 * Determines whether a sidebar is in use.
 *
 * 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.8.0
 *
 * @param string|int $index Sidebar name, id or number to check.
 * @return bool true if the sidebar is in use, false otherwise.
 */
function is_active_sidebar($index)
{
    $index = is_int($index) ? "sidebar-{$index}" : sanitize_title($index);
    $sidebars_widgets = wp_get_sidebars_widgets();
    $is_active_sidebar = !empty($sidebars_widgets[$index]);
    /**
     * Filters whether a dynamic sidebar is considered "active".
     *
     * @since 3.9.0
     *
     * @param bool       $is_active_sidebar Whether or not the sidebar should be considered "active".
     *                                      In other words, whether the sidebar contains any widgets.
     * @param int|string $index             Index, name, or ID of the dynamic sidebar.
     */
    return apply_filters('is_active_sidebar', $is_active_sidebar, $index);
}

WordPress Version: 5.0

/**
 * Determines whether a sidebar is in use.
 * 
 * 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.8.0
 *
 * @param string|int $index Sidebar name, id or number to check.
 * @return bool true if the sidebar is in use, false otherwise.
 */
function is_active_sidebar($index)
{
    $index = is_int($index) ? "sidebar-{$index}" : sanitize_title($index);
    $sidebars_widgets = wp_get_sidebars_widgets();
    $is_active_sidebar = !empty($sidebars_widgets[$index]);
    /**
     * Filters whether a dynamic sidebar is considered "active".
     *
     * @since 3.9.0
     *
     * @param bool       $is_active_sidebar Whether or not the sidebar should be considered "active".
     *                                      In other words, whether the sidebar contains any widgets.
     * @param int|string $index             Index, name, or ID of the dynamic sidebar.
     */
    return apply_filters('is_active_sidebar', $is_active_sidebar, $index);
}

WordPress Version: 4.6

/**
 * Whether a sidebar is in use.
 *
 * @since 2.8.0
 *
 * @param string|int $index Sidebar name, id or number to check.
 * @return bool true if the sidebar is in use, false otherwise.
 */
function is_active_sidebar($index)
{
    $index = is_int($index) ? "sidebar-{$index}" : sanitize_title($index);
    $sidebars_widgets = wp_get_sidebars_widgets();
    $is_active_sidebar = !empty($sidebars_widgets[$index]);
    /**
     * Filters whether a dynamic sidebar is considered "active".
     *
     * @since 3.9.0
     *
     * @param bool       $is_active_sidebar Whether or not the sidebar should be considered "active".
     *                                      In other words, whether the sidebar contains any widgets.
     * @param int|string $index             Index, name, or ID of the dynamic sidebar.
     */
    return apply_filters('is_active_sidebar', $is_active_sidebar, $index);
}

WordPress Version: 4.1

/**
 * Whether a sidebar is in use.
 *
 * @since 2.8.0
 *
 * @param string|int $index Sidebar name, id or number to check.
 * @return bool true if the sidebar is in use, false otherwise.
 */
function is_active_sidebar($index)
{
    $index = is_int($index) ? "sidebar-{$index}" : sanitize_title($index);
    $sidebars_widgets = wp_get_sidebars_widgets();
    $is_active_sidebar = !empty($sidebars_widgets[$index]);
    /**
     * Filter whether a dynamic sidebar is considered "active".
     *
     * @since 3.9.0
     *
     * @param bool       $is_active_sidebar Whether or not the sidebar should be considered "active".
     *                                      In other words, whether the sidebar contains any widgets.
     * @param int|string $index             Index, name, or ID of the dynamic sidebar.
     */
    return apply_filters('is_active_sidebar', $is_active_sidebar, $index);
}

WordPress Version: 3.9

/**
 * Whether a sidebar is in use.
 *
 * @since 2.8.0
 *
 * @param mixed $index Sidebar name, id or number to check.
 * @return bool true if the sidebar is in use, false otherwise.
 */
function is_active_sidebar($index)
{
    $index = is_int($index) ? "sidebar-{$index}" : sanitize_title($index);
    $sidebars_widgets = wp_get_sidebars_widgets();
    $is_active_sidebar = !empty($sidebars_widgets[$index]);
    /**
     * Filter whether a dynamic sidebar is considered "active".
     *
     * @since 3.9.0
     *
     * @param bool       $is_active_sidebar Whether or not the sidebar should be considered "active".
     *                                      In other words, whether the sidebar contains any widgets.
     * @param int|string $index             Index, name, or ID of the dynamic sidebar.
     */
    return apply_filters('is_active_sidebar', $is_active_sidebar, $index);
}

WordPress Version: 3.7

/**
 * Whether a sidebar is in use.
 *
 * @since 2.8
 *
 * @param mixed $index Sidebar name, id or number to check.
 * @return bool true if the sidebar is in use, false otherwise.
 */
function is_active_sidebar($index)
{
    $index = is_int($index) ? "sidebar-{$index}" : sanitize_title($index);
    $sidebars_widgets = wp_get_sidebars_widgets();
    $is_active_sidebar = !empty($sidebars_widgets[$index]);
    return $is_active_sidebar;
}