WP_REST_Widget_Types_Controller::get_widget()publicWP 5.8.0

Gets the details about the requested widget.

Метод класса: WP_REST_Widget_Types_Controller{}

Хуков нет.

Возвращает

Массив|WP_Error. The array of widget data if the name is valid, WP_Error otherwise.

Использование

$WP_REST_Widget_Types_Controller = new WP_REST_Widget_Types_Controller();
$WP_REST_Widget_Types_Controller->get_widget( $id );
$id(строка) (обязательный)
The widget type id.

Список изменений

С версии 5.8.0 Введена.

Код WP_REST_Widget_Types_Controller::get_widget() WP 6.5.2

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