dynamic_sidebar_has_widgets filter-hookWP 3.9.0

Filters whether a sidebar has widgets.

Note: The filter is also evaluated for empty sidebars, and on both the front end and back end, including the Inactive Widgets sidebar on the Widgets screen.

Usage

add_filter( 'dynamic_sidebar_has_widgets', 'wp_kama_dynamic_sidebar_has_widgets_filter', 10, 2 );

/**
 * Function for `dynamic_sidebar_has_widgets` filter-hook.
 * 
 * @param bool       $did_one Whether at least one widget was rendered in the sidebar.
 * @param int|string $index   Index, name, or ID of the dynamic sidebar.
 *
 * @return bool
 */
function wp_kama_dynamic_sidebar_has_widgets_filter( $did_one, $index ){

	// filter...
	return $did_one;
}
$did_one(true|false)
Whether at least one widget was rendered in the sidebar.
Default: false
$index(int|string)
Index, name, or ID of the dynamic sidebar.

Changelog

Since 3.9.0 Introduced.

Where the hook is called

dynamic_sidebar()
dynamic_sidebar_has_widgets
wp-includes/widgets.php 870
return apply_filters( 'dynamic_sidebar_has_widgets', $did_one, $index );
wp-includes/widgets.php 709
return apply_filters( 'dynamic_sidebar_has_widgets', false, $index );

Where the hook is used in WordPress

wp-includes/class-wp-customize-widgets.php 125
add_filter( 'dynamic_sidebar_has_widgets', array( $this, 'tally_sidebars_via_dynamic_sidebar_calls' ), 10, 2 );