| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
REST API: WP_REST_View_Config_Controller class
| File Size: | 843 lines (22 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
WP_REST_View_Config_Controller:: (16 methods):
__construct()
register_routes()
get_items_permissions_check()
get_required_capability()
get_items()
cast_empty_objects()
get_item_schema()
get_view_base_schema()
get_column_style_schema()
get_table_layout_schema()
get_list_layout_schema()
get_combined_layout_schema()
get_grid_layout_schema()
get_form_layout_schema()
get_form_field_schema()
get_form_schema()
Class: WP_REST_View_Config_Controller - X-Ref
Controller which provides a REST endpoint for retrieving the default| __construct() X-Ref |
| Constructor. |
| register_routes() X-Ref |
| Registers the routes for the controller. |
| get_items_permissions_check( $request ) X-Ref |
| Checks if a given request has access to read view config. param: WP_REST_Request $request Full details about the request. return: true|WP_Error True if the request has read access, WP_Error object otherwise. |
| get_required_capability( $kind, $name ) X-Ref |
| Resolves the capability required to read the view config for an entity. Known kinds map to the capability that gates managing that entity's list: post types use their own `edit_posts` capability (which honors custom `capability_type` registrations), taxonomies use `manage_terms`, and root-level entities use `manage_options`. A post type or taxonomy that is not registered, or not exposed to the REST API, resolves to `null` so the request is treated as referencing an unknown entity. Any other kind falls back to `edit_posts`. This keeps entities registered through the `get_entity_view_config_{$kind}_{$name}` filter readable behind a baseline capability. param: string $kind The entity kind (e.g. `postType`). param: string $name The entity name (e.g. `page`). return: string|null Capability required to read the config, or null if the |
| get_items( $request ) X-Ref |
| Returns the default view configuration for the given entity type. param: WP_REST_Request $request Full details about the request. return: WP_REST_Response|WP_Error Response object on success, or WP_Error object on failure. |
| cast_empty_objects( $value, $schema ) X-Ref |
| Recursively casts empty arrays to objects where the schema types them as objects. PHP cannot distinguish an empty associative array from an empty list, so `json_encode()` always serializes `array()` as a JSON array (`[]`). The REST schema, however, types several values as objects, which must encode as `{}`. This walks the value against its schema and casts any empty, object-typed array to an object. Non-empty associative arrays already encode as objects, so they are left as arrays and only recursed into to fix any nested empty objects. Union schemas (`oneOf`/`anyOf`) are handled only for the empty-array case: an empty value is cast to an object when any branch allows an object. Such values are not recursed into, which is sufficient for the form schema where they never contain empty nested objects. param: mixed $value The value to normalize. param: array $schema The schema node describing the value. return: mixed The normalized value, with empty object-typed arrays cast to objects. |
| get_item_schema() X-Ref |
| Retrieves the item's schema, conforming to JSON Schema. return: array Item schema data. |
| get_view_base_schema() X-Ref |
| Returns the schema properties shared by all view types (ViewBase), excluding 'type'. return: array Schema properties for the base view configuration. |
| get_column_style_schema() X-Ref |
| Returns the schema for the ColumnStyle type. return: array Schema for a column style object. |
| get_table_layout_schema() X-Ref |
| Returns the layout schema for table-type views (ViewTable, ViewPickerTable). return: array Schema for a table layout object. |
| get_list_layout_schema() X-Ref |
| Returns the layout schema for list-type views (ViewList, ViewActivity). return: array Schema for a list layout object. |
| get_combined_layout_schema() X-Ref |
| Returns a combined layout schema that accepts properties from all view types. This is useful for contexts where the view type is not known ahead of time (e.g. the `view` override in a view list item), so all possible layout properties must be accepted. return: array Schema for a combined layout object. |
| get_grid_layout_schema() X-Ref |
| Returns the layout schema for grid-type views (ViewGrid, ViewPickerGrid). return: array Schema for a grid layout object. |
| get_form_layout_schema() X-Ref |
| Returns the schema for a form layout object as a discriminated union. Each variant is discriminated by a single-value enum on its `type` property, matching the TypeScript Layout union in dataviews/src/types/dataform.ts. return: array Schema for a form layout object. |
| get_form_field_schema() X-Ref |
| Returns the schema for a form field item (string or object). return: array Schema for a form field. |
| get_form_schema() X-Ref |
| Returns the schema for the form configuration object. return: array Schema properties for the form configuration. |
| Generated : Wed Jun 24 08:20:11 2026 | Cross-referenced by PHPXref |