Skip to content

Editor: Preload the entity fields of the post editor - #14517

Closed
jorgefilipecosta wants to merge 1 commit into
WordPress:trunkfrom
jorgefilipecosta:fix/post-editor-entity-fields-preload
Closed

jorgefilipecosta wants to merge 1 commit into
WordPress:trunkfrom
jorgefilipecosta:fix/post-editor-entity-fields-preload

Conversation

@jorgefilipecosta

Copy link
Copy Markdown
Member

Backports the post editor part of _gutenberg_preload_entity_fields() from WordPress/gutenberg#85081, a follow-up to the entity fields API that landed in r64528.

Since that PR, the post summary of the post editor's inspector reads the fields of the edited post type from /wp/v2/entity-fields. Gutenberg preloads them, but Core only preloads them in the site editor.

This PR:

  • Makes _wp_preload_entity_fields() also preload /wp/v2/entity-fields?kind=postType&name=<post type> in the post editor.
  • Replaces test_the_post_editor_does_not_preload_the_fields with the Gutenberg test test_the_post_editor_preloads_the_fields_of_the_post_type.

The pinned Gutenberg build doesn't request the route yet, so this only takes effect with a pin that includes WordPress/gutenberg#85081. #14494 ports the other post editor preload paths of that PR, in edit-form-blocks.php.

Trac ticket: https://core.trac.wordpress.org/ticket/66339

Testing Instructions

  1. Run npm run test:php -- --group entity-fields.
  2. Set gutenberg.sha in package.json to trunk, then run npm run gutenberg:download and npm run build:dev.
  3. Open a post in the post editor and verify in the Network panel of the browser's developer tools that no /wp/v2/entity-fields request is made on load.

Use of AI Tools

AI assistance: Yes
Used for: porting the change and the test from the Gutenberg PR, and drafting this description; reviewed and edited by me.


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

The post summary of the post editor's inspector reads the fields of the edited post type from the `/wp/v2/entity-fields` route since Gutenberg stabilized the DataForm-based inspector, so the post editor now preloads them, as the site editor does.

Follow-up to [64528].

See #66339.
@github-actions

Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@jorgefilipecosta

Copy link
Copy Markdown
Member Author

Closing in favor of #14516, which includes the same change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant