diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php index 5fb9b8f6e1..9b97da4199 100644 --- a/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php +++ b/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php @@ -289,13 +289,14 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller { * * @since 5.8.0 * - * @global array $wp_registered_widget_updates The registered widget update functions. + * @global array $wp_registered_widget_updates The registered widget update functions. + * @global WP_Widget_Factory $wp_widget_factory * * @param WP_REST_Request $request Full details about the request. * @return WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. */ public function delete_item( $request ) { - global $wp_registered_widget_updates; + global $wp_registered_widget_updates, $wp_widget_factory; retrieve_widgets(); @@ -344,6 +345,17 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller { $_POST = $original_post; $_REQUEST = $original_request; + $widget_object = $wp_widget_factory->get_widget_object( $id_base ); + + if ( $widget_object ) { + /* + * WP_Widget sets `updated = true` after an update to prevent more than one widget + * from being saved per request. This isn't what we want in the REST API, though, + * as we support batch requests. + */ + $widget_object->updated = false; + } + wp_assign_widget_to_sidebar( $widget_id, '' ); $response->set_data( @@ -520,9 +532,11 @@ class WP_REST_Widgets_Controller extends WP_REST_Controller { $widget_object->_set( $number ); $widget_object->_register_one( $number ); - // WP_Widget sets updated = true after an update to prevent more - // than one widget from being saved per request. This isn't what we - // want in the REST API, though, as we support batch requests. + /* + * WP_Widget sets `updated = true` after an update to prevent more than one widget + * from being saved per request. This isn't what we want in the REST API, though, + * as we support batch requests. + */ $widget_object->updated = false; } diff --git a/wp-includes/version.php b/wp-includes/version.php index b35cbf9883..cfd1538a12 100644 --- a/wp-includes/version.php +++ b/wp-includes/version.php @@ -13,7 +13,7 @@ * * @global string $wp_version */ -$wp_version = '5.8-RC1-51275'; +$wp_version = '5.8-RC1-51290'; /** * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.