widget_update_callback хук-фильтрWP 2.8.0

Filters a widget's settings before saving.

Returning false will effectively short-circuit the widget's ability to update settings.

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

add_filter( 'widget_update_callback', 'wp_kama_widget_update_callback_filter', 10, 4 );

/**
 * Function for `widget_update_callback` filter-hook.
 * 
 * @param array     $instance     The current widget instance's settings.
 * @param array     $new_instance Array of new widget settings.
 * @param array     $old_instance Array of old widget settings.
 * @param WP_Widget $widget       The current widget instance.
 *
 * @return array
 */
function wp_kama_widget_update_callback_filter( $instance, $new_instance, $old_instance, $widget ){

	// filter...
	return $instance;
}
$instance(массив)
The current widget instance's settings.
$new_instance(массив)
Array of new widget settings.
$old_instance(массив)
Array of old widget settings.
$widget(WP_Widget)
The current widget instance.

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

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

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

WP_Widget::update_callback()
widget_update_callback
WP_REST_Widget_Types_Controller::encode_form_data()
widget_update_callback
wp-includes/class-wp-widget.php 475
$instance = apply_filters( 'widget_update_callback', $instance, $new_instance, $old_instance, $this );
wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php 497-503
$instance = apply_filters(
	'widget_update_callback',
	$instance,
	$new_instance,
	$old_instance,
	$widget_object
);

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

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