Title: WP_Widget_Block::update
Published: July 20, 2021
Last modified: February 24, 2026

---

# WP_Widget_Block::update( array $new_instance, array $old_instance ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#wp--skip-link--target)

Handles updating settings for the current Block widget instance.

## 󠀁[Parameters](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#parameters)󠁿

 `$new_instance`arrayrequired

New settings for this instance as input by the user via [WP_Widget::form()](https://developer.wordpress.org/reference/classes/wp_widget/form/).

`$old_instance`arrayrequired

Old settings for this instance.

## 󠀁[Return](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#return)󠁿

 array Settings to save or bool false to cancel saving.

## 󠀁[Source](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#source)󠁿

    ```php
    public function update( $new_instance, $old_instance ) {
    	$instance = array_merge( $this->default_instance, $old_instance );

    	if ( current_user_can( 'unfiltered_html' ) ) {
    		$instance['content'] = $new_instance['content'];
    	} else {
    		$instance['content'] = wp_kses_post( $new_instance['content'] );
    	}

    	return $instance;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-includes/widgets/class-wp-widget-block.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-includes/widgets/class-wp-widget-block.php#L180)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-includes/widgets/class-wp-widget-block.php#L180-L190)

## 󠀁[Related](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#related)󠁿

| Uses | Description | 
| [wp_kses_post()](https://developer.wordpress.org/reference/functions/wp_kses_post/)`wp-includes/kses.php` |

Sanitizes content for allowed HTML tags for post content.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  |

## 󠀁[Changelog](https://developer.wordpress.org/reference/classes/wp_widget_block/update/?output_format=md#changelog)󠁿

| Version | Description | 
| [5.8.0](https://developer.wordpress.org/reference/since/5.8.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Fclasses%2Fwp_widget_block%2Fupdate%2F)
before being able to contribute a note or feedback.