WP_Widget_Custom_HTML::update( array $new_instance, array $old_instance ): array
- Since
- 4.8.1
- Source
wp-includes/widgets/class-wp-widget-custom-html.php:190
Handles updating settings for the current Custom HTML widget instance.
Parameters
$new_instancearray- New settings for this instance as input by the user via WP_Widget::form().
$old_instancearray- Old settings for this instance.
Return
array- Settings to save or bool false to cancel saving.
Uses · 3
- sanitize_text_field()Sanitizes a string from user input or from the database.
- current_user_can()Returns whether the current user has the specified capability.
- wp_kses_post()Sanitizes content for allowed HTML tags for post content.
Source
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; }History
Introduced in 4.8.1. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-includes/widgets/class-wp-widget-custom-html.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.