WP_REST_Widget_Types_Controller::get_widget( string $id )

Gets the details about the requested widget.


Parameters Parameters

$id

(string) (Required) The widget type id.


Top ↑

Return Return

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


Top ↑

Source Source

File: wp-includes/rest-api/endpoints/class-wp-rest-widget-types-controller.php

	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 ) );
	}


Top ↑

Changelog Changelog

Changelog
Version Description
5.8.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.