dynamic_sidebar_before хук-событиеWP 3.9.0

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.

Использование

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|строка)
Index, name, or ID of the dynamic sidebar.
$has_widgets(true|false)
Whether the sidebar is populated with widgets.
По умолчанию: true

Список изменений

С версии 3.9.0 Введена.

Где вызывается хук

dynamic_sidebar()
dynamic_sidebar_before
wp-includes/widgets.php 730
do_action( 'dynamic_sidebar_before', $index, true );
wp-includes/widgets.php 707
do_action( 'dynamic_sidebar_before', $index, false );

Где используется хук в WordPress

wp-includes/blocks/widget-group.php 68
add_action( 'dynamic_sidebar_before', 'note_sidebar_being_rendered' );
wp-includes/class-wp-customize-widgets.php 1778
add_action( 'dynamic_sidebar_before', array( $this, 'start_dynamic_sidebar' ) );