| [ Index ] |
PHP Cross Reference of WordPress Trunk (Updated Daily) |
[Source view] [Print] [Project Stats]
Entity Fields API. A field definition is the serializable subset of the DataViews Field API: every property that is plain data (`id`, `type`, `label`, `elements`, `filterBy`, `isValid`, …). Properties that are JavaScript callbacks or components (`render`, `Edit` as a component, `getValue`, `setValue`, `sort`, `isVisible`, `getElements`, …) cannot be declared here. They are provided by a script module registered for the entity along with its fields: its default export maps field ids to the properties of each field that are JavaScript. An entity can have several modules. Each module applies to the fields it was registered with, see {@see wp_get_registered_entity_field_modules()}.
| File Size: | 359 lines (14 kb) |
| Included or required: | 0 times |
| Referenced: | 0 times |
| Includes or requires: | 0 files |
| wp_register_entity_fields( $origin, $kind, $name, $fields, $script_module = null ) X-Ref |
| Registers fields for an entity, see {@see WP_Entity_Fields_Registry::register()}. It only runs on the `wp_entity_fields_api_init` action. param: string $origin Who registers the fields: `core`, or param: string $kind The entity kind (e.g. `postType`). param: string $name The entity name (e.g. `page`). param: array[] $fields The list of field definitions, each with an `id`. param: string|null $script_module The id of the script module providing return: string[] The ids of the fields registered, in the order of the |
| wp_update_entity_fields( $origin, $kind, $name, $fields, $script_module = null ) X-Ref |
| Updates registered fields of an entity, see {@see WP_Entity_Fields_Registry::update()}. It only runs on the `wp_entity_fields_api_init` action. param: string $origin Who updates the fields: `core`, or param: string $kind The entity kind (e.g. `postType`). param: string $name The entity name (e.g. `page`). param: array[] $fields The list of partial field definitions, param: string|null $script_module The id of the script module providing return: string[] The ids of the fields updated, in the order of the |
| wp_unregister_entity_fields( $kind, $name, $ids = null ) X-Ref |
| Unregisters fields of an entity, see {@see WP_Entity_Fields_Registry::unregister()}. It only runs on the `wp_entity_fields_api_init` action. param: string $kind The entity kind (e.g. `postType`). param: string $name The entity name (e.g. `page`). param: string[]|null $ids The ids of the fields to unregister. Default return: array[] The list of the definitions unregistered, in |
| wp_get_registered_entity_fields( $kind, $name ) X-Ref |
| Returns the fields registered for the given entity. param: string $kind The entity kind (e.g. `postType`). param: string $name The entity name (e.g. `page`). return: array[] The list of registered field definitions, in registration |
| wp_get_registered_entity_field_modules( $kind, $name ) X-Ref |
| Returns the ids of the script modules registered for the given entity. param: string $kind The entity kind (e.g. `postType`). param: string $name The entity name (e.g. `page`). return: array<string, string[]> The ids of the fields each module applies |
| wp_get_all_registered_entity_field_modules() X-Ref |
| Returns the ids of all script modules registered for any entity. return: array<string, array<string, string[]>> The lists of module ids, |
| _wp_add_entity_field_modules_to_editor_script( $scripts = null ) X-Ref |
| Declares the script modules of the entity fields as dependencies of the editor script. The editor imports the script modules of an entity on demand, with a dynamic `import()` the browser resolves through the import map of the page. Listing the modules as dynamic `module_dependencies` of the `wp-editor` script adds them to the import map of every page that loads the editor script: the post editor, the site editor, and the pages booted by `@wordpress/boot`, whose prerequisites depend on it. A dynamic dependency is only listed in the import map; the module is fetched when it is imported. Reading the registry fires `wp_entity_fields_api_init`, so the fields and their script modules are registered on demand. It only reads the registry on the pages that load the editor script, not on every admin request (heartbeat, Ajax, other screens). It runs on `admin_footer`, the last action before the import map is printed that fires both in the admin template and in the pages rendered outside it, which print the import map themselves. By then `init` has completed, so the supports the default fields derive from are final. The registry only accepts registrations while the action fires, so the modules declared here are the modules of every field the page can show. It is hooked to `admin_footer` without arguments, so the global scripts registry is used. In other scenarios (tests), the scripts are given directly. param: WP_Scripts|null $scripts Optional. The scripts registry. Default null, |
| wp_get_entity_field_collection_fields( $directory ) X-Ref |
| Returns the fields of a field collection, see {@see WP_Entity_Fields_Registry::get_collection_fields()}. param: string $directory The directory of the collection. return: array<string, array> The fields of the collection, keyed by id, in |
| wp_register_entity_field_collection( $directory ) X-Ref |
| Registers the fields of a field collection, see {@see WP_Entity_Fields_Registry::register_collection()} for the format of a collection. Like wp_register_entity_fields(), it only runs on the `wp_entity_fields_api_init` action. param: string $directory The directory of the collection. return: bool Whether the collection is valid and all of its fields are |
| _wp_get_post_type_fields_preload_paths( $post_types ) X-Ref |
| Returns the paths that serve the fields of the given post types, skipping the post types that are not registered. A path must match the request of the `getFieldsConfig` core data resolver, see packages/core-data/src/resolvers.js in Gutenberg. param: string[] $post_types The post types. return: string[] One path of the `/wp/v2/entity-fields` route per post type, |
| _wp_get_site_editor_screen_post_types() X-Ref |
| Returns the post types whose fields the screen of the site editor being loaded lists, from its `p` query arg. The screens are the routes in packages/edit-site/src/components/site-editor-routes in Gutenberg: the lists and the editors of pages, templates, patterns, and template parts. The patterns screen lists both patterns and template parts. return: string[] The post types, empty for any other screen. |
| _wp_preload_entity_fields( $paths, $context ) X-Ref |
| Preloads the fields of the post types the site editor lists. The site editor reads them from the `/wp/v2/entity-fields` route before it can list the post fields, see `useFields` in packages/editor/src/dataviews/fields-loader/index.ts in Gutenberg: those of the edited post, if any, and of the post types of the screen it opens on. The post editor is left untouched: it only reads the fields in the DataForm-based inspector, an experiment of the Gutenberg plugin which preloads them on its own. param: array $paths REST API paths to preload. param: WP_Block_Editor_Context $context Block editor context. return: array Filtered preload paths. |
| Generated : Tue Oct 20 08:20:34 2026 | Cross-referenced by PHPXref |