if(isset($value['raw_instance']) && $id_base && wp_use_widgets_block_editor()){ $widget_object = $wp_widget_factory->get_widget_object($id_base); if( ! empty($widget_object->widget_options['show_instance_in_rest'])){ if( 'block' === $id_base && ! current_user_can( 'unfiltered_html' )){ /*
* The content of the 'block' widget is not filtered on the fly while editing.
* Filter the content here to prevent vulnerabilities.
*/ $value['raw_instance']['content'] = wp_kses_post($value['raw_instance']['content']); }
// Allow sidebar to be unset or missing when widget is not a WP_Widget.
$parsed_id = wp_parse_widget_id($widget_id); $widget_object = $wp_widget_factory->get_widget_object($parsed_id['id_base']); if(is_null($sidebar_id) && $widget_object){ returnnewWP_Error( 'rest_widget_not_found', __( 'No widget was found with that id.' ), array( 'status' => 404 ) ); }