Repository navigation
Editor: Register the core entity fields on the server - #14512
jorgefilipecosta wants to merge 4 commits into
Conversation
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
|
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the Core Committers: Use this line as a base for the props when committing in SVN: To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
I've tested this as part of #14514 |
969443b to
e8cee79
Compare
Copies the PHP of the `core-fields` package from the Gutenberg build and loads it, so WordPress registers its own fields through the entity fields API: the default fields every post type derives from its supports, and the field collections of pages, templates, template parts, patterns, attachments, navigation menus, and the site. Synced from WordPress/gutenberg#84696. See #66229.
Ports the REST controller tests of WordPress/gutenberg#84696: the fields route exposes the default fields of pages and the fields of patterns, with the script modules of their collections and the `core` origin. See #66229.
…udes them. The core fields are copied from the Gutenberg build, so their tests are skipped while the pinned build does not include them. See #66229.
Skipping in `set_up()` still ran `tear_down()`, which restored the theme features before they were captured and set the global to null, dropping the `title-tag` support of the test theme for the rest of the run. A class-level `@requires function` skips before either runs. The REST tests use the same annotation in place of the skip helper.
e8cee79 to
203f045
Compare
Gutenberg registers the core fields (title, author, status, the media fields, …) on the server through the entity fields API, and the editors read them from the `wp/v2/entity-fields` route. Core has the API but registered no fields, so the title column of the Site Editor's pages list was blank. Register them in Core the same way. Copy the PHP files of `@wordpress/core-fields` from the Gutenberg build in the `gutenberg-php` Grunt copy task, next to the core actions, and load their `index.php` from `wp-settings.php`. They register the default fields every post type gets from its supports, plus the field collections of pages, templates, template parts, patterns, attachments, navigation menus, and the site. The entity fields tests now swap the core fields for their fixture defaults, so they still test the API on its own. The tests for the core fields are skipped until the pinned Gutenberg build includes them. Developed in #14512. Synced from WordPress/gutenberg#84696. Follow-up to [64528]. Props oandregal, jorgefilipecosta. Fixes #66229. git-svn-id: https://develop.svn.wordpress.org/trunk@64581 602fd350-edb4-49c9-b593-d223f7449a82
Gutenberg registers the core fields (title, author, status, the media fields, …) on the server through the entity fields API, and the editors read them from the `wp/v2/entity-fields` route. Core has the API but registered no fields, so the title column of the Site Editor's pages list was blank. Register them in Core the same way. Copy the PHP files of `@wordpress/core-fields` from the Gutenberg build in the `gutenberg-php` Grunt copy task, next to the core actions, and load their `index.php` from `wp-settings.php`. They register the default fields every post type gets from its supports, plus the field collections of pages, templates, template parts, patterns, attachments, navigation menus, and the site. The entity fields tests now swap the core fields for their fixture defaults, so they still test the API on its own. The tests for the core fields are skipped until the pinned Gutenberg build includes them. Developed in WordPress/wordpress-develop#14512. Synced from WordPress/gutenberg#84696. Follow-up to [64528]. Props oandregal, jorgefilipecosta. Fixes #66229. Built from https://develop.svn.wordpress.org/trunk@64581 git-svn-id: http://core.svn.wordpress.org/trunk@63731 1a063a9b-81f0-0310-95a4-ce76da25c4cd
Backports the PHP of WordPress/gutenberg#84696, a follow-up to the entity fields API that landed in r64528.
Gutenberg registers the core fields (title, author, status, the media fields…) on the server, through the entity fields API, and the editors read them from
/wp/v2/entity-fields. Core has the API but registers no fields yet, so the title column of the site editor's pages list is blank. This PR makes Core register them.This PR:
@wordpress/core-fieldsfrom the Gutenberg build towp-includes/build/scripts/core-fields/, in thegutenberg-phpcopy task that copiesroutes.phpandpages.php, and loads itsindex.phpfromwp-settings.phpthe same way.wp_register_core_field_collections()andwp_register_core_post_type_supports_fields().Some notes:
wp-includes/build/scripts/core-fields/doesn't exist, so the new tests are skipped and nothing is registered.gutenbergtext domain from the labels, so they are translated with the default one. Thetest_the_labels_are_translated_with_the_default_text_domaintest covers it.Gruntfile.jsandwp-settings.phpas Editor: Register the core entity actions on the server #14509, which does the same for the core actions; whichever lands second needs a trivial rebase.Testing Instructions
gutenberg.shainpackage.jsontotrunk, then runnpm run gutenberg:downloadandnpm run build:dev.wp-admin/site-editor.php?p=%2Fpageand verify the pages list shows the titles, authors, and statuses of the pages.await wp.apiFetch( { path: '/wp/v2/entity-fields?kind=postType&name=page' } )and verify it returns the fields of pages with the@wordpress/core-fields/post_type_supportsand@wordpress/core-fields/pagemodules.npm run test:php -- --group entity-fields.Gutenberg PR: WordPress/gutenberg#84696
Trac ticket: https://core.trac.wordpress.org/ticket/66229
Use of AI Tools
AI assistance: Yes
Used for: porting the code and the tests 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.