WP_REST_Widget_Types_Controller::get_widget_preview()
Returns the output of WP_Widget::widget() when called with the provided instance. Used by encode_form_data() to preview a widget.
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. |
WP_REST_Widget_Types_Controller::get_widget_preview() WP REST Widget Types Controller::get widget preview code WP 6.6.2
private function get_widget_preview( $widget, $instance ) { ob_start(); the_widget( $widget, $instance ); return ob_get_clean(); }