dynamic_sidebar_before
Fires before widgets are rendered in a dynamic sidebar.
Note: The action also fires for empty sidebars, and on both the front end and back end, including the Inactive Widgets sidebar on the Widgets screen.
Usage
add_action( 'dynamic_sidebar_before', 'wp_kama_dynamic_sidebar_before_action', 10, 2 );
/**
* Function for `dynamic_sidebar_before` action-hook.
*
* @param int|string $index Index, name, or ID of the dynamic sidebar.
* @param bool $has_widgets Whether the sidebar is populated with widgets.
*
* @return void
*/
function wp_kama_dynamic_sidebar_before_action( $index, $has_widgets ){
// action...
}
- $index(int|string)
- Index, name, or ID of the dynamic sidebar.
- $has_widgets(true|false)
- Whether the sidebar is populated with widgets.
Default: true
Changelog
| Since 3.9.0 | Introduced. |
Where the hook is called
dynamic_sidebar_before
wp-includes/widgets.php 738
do_action( 'dynamic_sidebar_before', $index, true );
wp-includes/widgets.php 715
do_action( 'dynamic_sidebar_before', $index, false );
Where the hook is used in WordPress
wp-includes/blocks/widget-group.php 79
add_action( 'dynamic_sidebar_before', 'note_sidebar_being_rendered' );
wp-includes/class-wp-customize-widgets.php 1802
add_action( 'dynamic_sidebar_before', array( $this, 'start_dynamic_sidebar' ) );