WordPress at a glance

is_active_sidebar() WP 1.0

Whether a sidebar is in use.

Hooks from function:
Return

true/false. true if the sidebar is in use, false otherwise.

Usage

is_active_sidebar( $index );
$index(string/int) (required)
Sidebar name, id or number to check.

Code of is_active_sidebar: wp-includes/widgets.php VER 4.9.8

<?php
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 );
}

Related Functions

From tag: Sidebar (widgets)

More from tag: Conditional tags (all)

More from Template Tags: Main Functions

No comments
    Hello, !     Log In . Register