WordPress at Your Fingertips
function is not described

WP_REST_Widget_Types_Controller::get_widget() public WP 5.8.0

Gets the details about the requested widget.

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

No Hooks.

Return

Array|WP_Error. The array of widget data if the name is valid, WP_Error otherwise.

Usage

$WP_REST_Widget_Types_Controller = new WP_REST_Widget_Types_Controller();
$WP_REST_Widget_Types_Controller->get_widget( $id );
$id(string) (required)
The widget type id.

Changelog

Since 5.8.0 Introduced.

Code of WP_REST_Widget_Types_Controller::get_widget() WP 5.8.1

public function get_widget( $id ) {
	foreach ( $this->get_widgets() as $widget ) {
		if ( $id === $widget['id'] ) {
			return $widget;
		}
	}

	return new WP_Error( 'rest_widget_type_invalid', __( 'Invalid widget type.' ), array( 'status' => 404 ) );
}