Commit d79d1d800c for wordpress.org

commit d79d1d800cee0b8b7068b04cda4bfad3d1d0cebd
Author: jorgefilipecosta <jorgefilipecosta@git.wordpress.org>
Date:   Tue Oct 20 11:10:55 2026 +0000

    Editor: Preload the entity fields and actions the editors read.

    The editors read the fields and actions of the post types they show from the `wp/v2/entity-fields` and `wp/v2/entity-actions` routes. Core preloaded the fields only in the site editor and the actions only in the post editor.
    The post editor now also preloads the entity fields of the edited post type, which the post summary of its inspector reads. The site editor now also preloads the entity actions of the edited post and of the post types its screen lists (pages, templates, patterns and template parts), as it already did for the entity fields.

    Developed in https://github.com/WordPress/wordpress-develop/pull/14516.
    Synced from https://github.com/WordPress/gutenberg/pull/85081 and https://github.com/WordPress/gutenberg/pull/85155.
    Follow-up to [64528], [64566].

    Props jorgefilipecosta, oandregal.
    See #66343.
    Built from https://develop.svn.wordpress.org/trunk@64595


    git-svn-id: http://core.svn.wordpress.org/trunk@63745 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/entity-actions.php b/wp-includes/entity-actions.php
index 13ec78bc03..426fd1d309 100644
--- a/wp-includes/entity-actions.php
+++ b/wp-includes/entity-actions.php
@@ -189,13 +189,16 @@ function _wp_add_entity_action_modules_to_editor_script( $scripts = null ) {
 }

 /**
- * Preloads the actions of the post type the post editor edits.
+ * Preloads the actions of the post types the editors list.
  *
- * The actions menu of the post editor reads them from the `wp/v2/entity-actions`
- * route as it loads, see `useEntityActions()` in
- * packages/editor/src/dataviews/entity-actions-loader.ts. The path must match the
- * request of the `getEntityActionsConfig` core data resolver, see
- * packages/core-data/src/resolvers.js.
+ * The editors read them from the `/wp/v2/entity-actions` route as they load,
+ * see `useEntityActions()` in
+ * packages/editor/src/dataviews/entity-actions-loader.ts in Gutenberg. The
+ * post editor reads those of the edited post in its actions menu. The site
+ * editor reads those of the edited post, if any, and of the post types of the
+ * screen it opens on, whose lists show the actions of their items. A path must
+ * match the request of the `getEntityActionsConfig` core data resolver, see
+ * packages/core-data/src/resolvers.js in Gutenberg.
  *
  * @since 7.2.0
  *
@@ -204,11 +207,24 @@ function _wp_add_entity_action_modules_to_editor_script( $scripts = null ) {
  * @return array Filtered preload paths.
  */
 function _wp_preload_entity_actions( $paths, $context ) {
+	$post_types = array();
 	if ( 'core/edit-post' === $context->name && isset( $context->post ) ) {
+		$post_types[] = $context->post->post_type;
+	} elseif ( 'core/edit-site' === $context->name ) {
+		if ( isset( $context->post ) ) {
+			$post_types[] = $context->post->post_type;
+		}
+		$post_types = array_merge( $post_types, _wp_get_site_editor_screen_post_types() );
+	}
+
+	foreach ( array_unique( $post_types ) as $post_type ) {
+		if ( ! post_type_exists( $post_type ) ) {
+			continue;
+		}
 		$paths[] = add_query_arg(
 			array(
 				'kind' => 'postType',
-				'name' => $context->post->post_type,
+				'name' => $post_type,
 			),
 			'/wp/v2/entity-actions'
 		);
diff --git a/wp-includes/entity-fields.php b/wp-includes/entity-fields.php
index 91a0547557..779a32f7fe 100644
--- a/wp-includes/entity-fields.php
+++ b/wp-includes/entity-fields.php
@@ -288,8 +288,8 @@ function _wp_get_post_type_fields_preload_paths( $post_types ) {
 }

 /**
- * Returns the post types whose fields the screen of the site editor being
- * loaded lists, from its `p` query arg.
+ * Returns the post types whose items the screen of the site editor being
+ * loaded lists or edits, from its `p` query arg.
  *
  * The screens are the routes in
  * packages/edit-site/src/components/site-editor-routes in Gutenberg: the
@@ -323,16 +323,13 @@ function _wp_get_site_editor_screen_post_types() {
 }

 /**
- * Preloads the fields of the post types the site editor lists.
+ * Preloads the fields of the post types the editors list.
  *
- * 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.
+ * The editors read them from the `/wp/v2/entity-fields` route, see `useFields`
+ * in packages/editor/src/dataviews/fields-loader/index.ts in Gutenberg. The
+ * post editor reads those of the edited post in the post summary of its
+ * inspector. The site editor reads those of the edited post, if any, and of
+ * the post types of the screen it opens on.
  *
  * @since 7.2.0
  * @access private
@@ -342,15 +339,15 @@ function _wp_get_site_editor_screen_post_types() {
  * @return array Filtered preload paths.
  */
 function _wp_preload_entity_fields( $paths, $context ) {
-	if ( 'core/edit-site' !== $context->name ) {
-		return $paths;
-	}
-
 	$post_types = array();
-	if ( isset( $context->post ) ) {
+	if ( 'core/edit-post' === $context->name && isset( $context->post ) ) {
 		$post_types[] = $context->post->post_type;
+	} elseif ( 'core/edit-site' === $context->name ) {
+		if ( isset( $context->post ) ) {
+			$post_types[] = $context->post->post_type;
+		}
+		$post_types = array_merge( $post_types, _wp_get_site_editor_screen_post_types() );
 	}
-	$post_types = array_merge( $post_types, _wp_get_site_editor_screen_post_types() );

 	return array_merge(
 		$paths,
diff --git a/wp-includes/version.php b/wp-includes/version.php
index 5d977dbe38..48120ace06 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-alpha-64594';
+$wp_version = '7.2-alpha-64595';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.