WP_REST_Widget_Types_Controller::get_widget_preview()privateWP 5.8.0

instance. Used by encode_form_data() to preview a widget.

{} It's a method of the class: WP_REST_Widget_Types_Controller{}

No Hooks.

Return

String.

Usage

// private - for code of main (parent) class only
$result = $this->get_widget_preview( $widget, $instance );
$widget(string) (required)
The widget's PHP class name (see class-wp-widget.php).
$instance(array) (required)
Widget instance settings.

Changelog

Since 5.8.0 Introduced.

Code of WP_REST_Widget_Types_Controller::get_widget_preview() WP 6.0

private function get_widget_preview( $widget, $instance ) {
	ob_start();
	the_widget( $widget, $instance );
	return ob_get_clean();
}