[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/ -> entity-utils.php (summary)

Utilities shared by the Entity Actions and Entity Fields APIs.

File Size: 156 lines (6 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 2 functions

  _wp_add_entity_preload_paths()
  _wp_add_entity_modules_to_editor_script()

Functions
Functions that are not part of a class:

_wp_add_entity_preload_paths( $paths, $context, $route )   X-Ref
Adds the paths of an entity route for the post types the editors list.

The post editor lists the post type of the edited post. The site editor
lists that of the edited post, if any, and those of the screen it opens on.
Post types that are not registered are skipped, and each post type is added
once.

param: mixed  $paths   REST API paths to preload.
param: mixed  $context Block editor context.
param: string $route   The entity route, such as `/wp/v2/entity-fields`.
return: mixed The paths with one path per post type added. An empty value

_wp_add_entity_modules_to_editor_script( $scripts, $get_modules )   X-Ref
Declares the script modules of an entity API 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.

The modules are read with `$get_modules`, which reads the registry of the
API and so fires its init action, registering the entities and their script
modules on demand. It is only called on the pages that load the editor
script, not on every admin request (heartbeat, Ajax, other screens). The
callers run 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 post types and supports the registrations derive from are
final. The registries only accept registrations while their action fires,
so the modules declared here are those of everything the page can show.

param: WP_Scripts|null $scripts     The scripts registry. Null for the global one.
param: callable        $get_modules Returns the module ids of the API, keyed



Generated : Sat Oct 24 08:20:34 2026 Cross-referenced by PHPXref