diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php index dced990fcdd0f..44b3db0dac6ce 100644 --- a/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php +++ b/src/wp-includes/rest-api/endpoints/class-wp-rest-widgets-controller.php @@ -236,6 +236,10 @@ public function update_item_permissions_check( $request ) { public function update_item( $request ) { global $wp_widget_factory; + // Calling wp_get_sidebars_widgets() here is a safe fix for https://github.com/WordPress/gutenberg/issues/33335 + // @TODO: Remove this after WP 5.8 RC1 in favor of updating retrieve_widgets and wp_set_sidebars_widgets + wp_get_sidebars_widgets(); + retrieve_widgets(); $widget_id = $request['id']; @@ -300,6 +304,10 @@ public function delete_item_permissions_check( $request ) { public function delete_item( $request ) { global $wp_widget_factory, $wp_registered_widget_updates; + // Calling wp_get_sidebars_widgets() here is a safe fix for https://github.com/WordPress/gutenberg/issues/33335 + // @TODO: Remove this after WP 5.8 RC1 in favor of updating retrieve_widgets and wp_set_sidebars_widgets + wp_get_sidebars_widgets(); + retrieve_widgets(); $widget_id = $request['id'];