Repository navigation
REST API: Add missing _links relations to endpoint responses - #14122
Draft
johnbillion wants to merge 3 commits into
Draft
johnbillion wants to merge 3 commits into
johnbillion wants to merge 3 commits into
Conversation
Audits every REST controller for the standard link relations and adds the ones that were missing: * Revisions: `self`, `collection`, and `author`; autosaves point these at the autosaves routes. Template revisions and autosaves gain `collection`. Global styles revisions gain `self`, `collection`, `parent`, and `author`. * Post types and taxonomies: `self`. Post statuses: `self` and `collection`. Plugins: `collection`. * Application passwords: `collection` and `up` to the owning user. * Icons: `self`, `collection`, and `up` to the icon collection. Icon collections: `self`, `collection`, and `wp:items`. * Global styles: `predecessor-version` and `wp:theme`. Templates: `author`. Font faces and font families: `about`. * Menu items: `up` to the parent menu item, which lives in meta rather than `post_parent`. * Terms in hierarchical taxonomies and posts in hierarchical post types: `children`. * Users: `wp:application-passwords` and `wp:post_type`. * Abilities: `up` to the category, and `wp:action-run` now uses the full `https://api.w.org/` URI so it compacts and emits `curies` like every other custom relation. * Widgets: remove the trailing slash from the `wp:sidebar` href. The `$parent_base` property on the revisions controllers is now protected so the inherited link builder sees the subclass value.
johnbillion
force-pushed
the
rest-api-missing-links
branch
from
October 8, 2026 20:48
1be0216 to
c2590f5
Compare
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Several REST API responses expose related resource identifiers without links to those resources, or omit basic
selfandcollectionlinks. This adds the missing relationships so clients can discover the corresponding endpoints without constructing URLs themselves.Changes
self,collection,parent, andauthorlinks as appropriate. Autosaves use their own routes. Make$parent_baseprotected where inherited link builders need it, with PHPStan baseline entries for template controllers that prepare links fromWP_Block_Templateobjects.selfand links between the descriptions of related REST-visible objects. Post types usewp:taxonomywith ataxonomyattribute; taxonomies use the newwp:post-typerelation with apost_typeattribute. The existingwp:post_typerelation continues to identify filtered post collections on terms and users.selfand/orcollectionlinks.collectionandupto the owning user. User responses advertisewp:application-passwordsonly when application passwords are available for that user and the viewer canlist_app_passwordsfor them.wp:post_typelinks to author-filtered collections for REST-visible post types served by the posts controller and supporting authors.wp:autosaveswhen a supported autosave controller exists and the viewer can edit the parent. Template links require a database-backed template. Posts build autosave URLs from the registered namespace, REST base, and ID, independently of filters on the post'sselfroute.upfor installed parent themes. Active themes advertisewp:theme-global-stylesandwp:theme-style-variations; inactive themes do not advertise these active-theme-only endpoints.predecessor-versionandwp:theme; templates gainauthorand links to installed themes. Theme-global-styles responses also link to their theme and style variations.self,collection,up, andwp:itemslinks.about.upto the parent menu item stored in meta.children.upto the category. Use the fullhttps://api.w.org/action-runrelation URI so it compacts and emitscuriesconsistently.wp:sidebarURL.The new WordPress-specific relations are URI extension relations under
https://api.w.org/, compacted towp:in responses. Their names and meanings are proposed API vocabulary for review.For backward compatibility, retain the bare
abilitiesrelation on ability categories and the existingup/parentsplit between controllers.Validation
wp-api-generated.js. Pin application-password availability and normalize autosave URLs to keep fixtures stable between runs.git diff --checkalso pass.Trac ticket: none yet.