dynamic_sidebar хук-событиеWP 3.0.0

Fires before a widget's display callback is called.

Note: The action fires on both the front end and back end, including for widgets in the Inactive Widgets sidebar on the Widgets screen.

The action is not fired for empty sidebars.

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

add_action( 'dynamic_sidebar', 'wp_kama_dynamic_sidebar_action' );

/**
 * Function for `dynamic_sidebar` action-hook.
 * 
 * @param array $widget An associative array of widget arguments.
 *
 * @return void
 */
function wp_kama_dynamic_sidebar_action( $widget ){

	// action...
}
$widget(массив)

An associative array of widget arguments.

  • name(строка)
    Name of the widget.

  • id(строка)
    Widget ID.

  • callback(callable)
    When the hook is fired on the front end, $callback is an array containing the widget object. Fired on the back end, $callback is 'wp_widget_control', see $_callback.

  • params(массив)
    An associative array of multi-widget arguments.

  • classname(строка)
    CSS class applied to the widget container.

  • description(строка)
    The widget description.

  • _callback(массив)
    When the hook is fired on the back end, $_callback is populated with an array containing the widget object, see $callback.

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

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

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

dynamic_sidebar()
dynamic_sidebar
wp_render_widget()
dynamic_sidebar
wp-includes/widgets.php 834
do_action( 'dynamic_sidebar', $wp_registered_widgets[ $id ] );
wp-includes/widgets.php 2030
do_action( 'dynamic_sidebar', $wp_registered_widgets[ $widget_id ] );

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

wp-includes/class-wp-customize-widgets.php 124
add_action( 'dynamic_sidebar', array( $this, 'tally_rendered_widgets' ) );