Filter hook 'dynamic_sidebar_has_widgets'

in WP Core File wp-includes/widgets.php at line 880

View Source

dynamic_sidebar_has_widgets

Filter Hook
Description
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.

Hook Information

File Location wp-includes/widgets.php View on GitHub
Hook Type Filter
Line Number 880

Hook Parameters

Type Name Description
bool $did_one Whether at least one widget was rendered in the sidebar. Default false.
int|string $index Index, name, or ID of the dynamic sidebar.

Usage Examples

Basic Usage
<?php
// Hook into dynamic_sidebar_has_widgets
add_filter('dynamic_sidebar_has_widgets', 'my_custom_filter', 10, 2);

function my_custom_filter($did_one, $index) {
    // Your custom filtering logic here
    return $did_one;
}

Source Code Context

wp-includes/widgets.php:880 - How this hook is used in WordPress core
<?php
 875  	 *
 876  	 * @param bool       $did_one Whether at least one widget was rendered in the sidebar.
 877  	 *                            Default false.
 878  	 * @param int|string $index   Index, name, or ID of the dynamic sidebar.
 879  	 */
 880  	return apply_filters( 'dynamic_sidebar_has_widgets', $did_one, $index );
 881  }
 882  
 883  /**
 884   * Determines whether a given widget is displayed on the front end.
 885   *

PHP Documentation

<?php
/**
	 * 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.
	 *
	 * @since 3.9.0
	 *
	 * @param bool       $did_one Whether at least one widget was rendered in the sidebar.
	 *                            Default false.
	 * @param int|string $index   Index, name, or ID of the dynamic sidebar.
	 */
Quick Info
  • Hook Type: Filter
  • Parameters: 2
  • File: wp-includes/widgets.php
Related Hooks

Related hooks will be displayed here in future updates.