WP_REST_View_Config_Controller::get_items( WP_REST_Request $request ): WP_REST_Response|WP_Error

In this article

Returns the default view configuration for the given entity type.

Parameters

$requestWP_REST_Requestrequired
Full details about the request.

Return

WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure.

Source

public function get_items( $request ) {
	$kind = $request->get_param( 'kind' );
	$name = $request->get_param( 'name' );

	$config = wp_get_entity_view_config( $kind, $name );
	$schema = $this->get_item_schema();

	$response = array(
		'kind'            => $kind,
		'name'            => $name,
		'version'         => WP_View_Config_Data::LATEST_VERSION,
		'default_view'    => $this->cast_empty_objects( $config['default_view'], $schema['properties']['default_view'] ),
		'default_layouts' => $this->cast_empty_objects( $config['default_layouts'], $schema['properties']['default_layouts'] ),
		'view_list'       => $this->cast_empty_objects( $config['view_list'], $schema['properties']['view_list'] ),
		'form'            => $this->cast_empty_objects( $config['form'], $schema['properties']['form'] ),
	);

	return rest_ensure_response( $response );
}

Changelog

VersionDescription
7.1.0Introduced.

User Contributed Notes

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