dynamic_sidebar_has_widgets
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.
Использование
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.
По умолчанию: false - $index(int|строка)
- Index, name, or ID of the dynamic sidebar.
Список изменений
С версии 3.9.0 | Введена. |
Где вызывается хук
dynamic_sidebar_has_widgets
wp-includes/widgets.php 872
return apply_filters( 'dynamic_sidebar_has_widgets', $did_one, $index );
wp-includes/widgets.php 711
return apply_filters( 'dynamic_sidebar_has_widgets', false, $index );
Где используется хук в WordPress
wp-includes/class-wp-customize-widgets.php 126
add_filter( 'dynamic_sidebar_has_widgets', array( $this, 'tally_sidebars_via_dynamic_sidebar_calls' ), 10, 2 );