WP_Widget_Custom_HTML::update()publicWP 4.8.1

Handles updating settings for the current Custom HTML widget instance.

Метод класса: WP_Widget_Custom_HTML{}

Хуков нет.

Возвращает

Массив. Settings to save or bool false to cancel saving.

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

$WP_Widget_Custom_HTML = new WP_Widget_Custom_HTML();
$WP_Widget_Custom_HTML->update( $new_instance, $old_instance );
$new_instance(массив) (обязательный)
New settings for this instance as input by the user via WP_Widget::form().
$old_instance(массив) (обязательный)
Old settings for this instance.

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

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

Код WP_Widget_Custom_HTML::update() WP 6.5.2

public function update( $new_instance, $old_instance ) {
	$instance          = array_merge( $this->default_instance, $old_instance );
	$instance['title'] = sanitize_text_field( $new_instance['title'] );
	if ( current_user_can( 'unfiltered_html' ) ) {
		$instance['content'] = $new_instance['content'];
	} else {
		$instance['content'] = wp_kses_post( $new_instance['content'] );
	}
	return $instance;
}