WP_REST_View_Config_Controller::get_items
Returns the default view configuration for the given entity type.
Method of the class: WP_REST_View_Config_Controller{}
No Hooks.
Returns
WP_REST_Response|WP_Error. Response object on success, or WP_Error object on failure.
Usage
$WP_REST_View_Config_Controller = new WP_REST_View_Config_Controller(); $WP_REST_View_Config_Controller->get_items( $request );
- $request(WP_REST_Request) (required)
- Full details about the request.
Changelog
| Since 7.1.0 | Introduced. |
WP_REST_View_Config_Controller::get_items() WP REST View Config Controller::get items code WP 7.1.2
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 );
}