Repository navigation
Actions API: Register the homepage and posts page actions using REST links - #84932
Merged
Merged
Conversation
🤖 PR meta 🤖🎉 PropsIf you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message. To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. Updated as activity occurs, without notifying anyone named here. Add the 📦 Bundle sizeSize Change: +779 B (+0.01%) Total Size: 8.85 MB 📦 View Changed
⚡ PerformanceShow the resultsClient side metrics exclude the server response time. front-end-block-theme
front-end-classic-theme
media-processing
media-upload
post-editor
site-editor
|
WordPress 7.2 adds the links in `get_available_actions()` once the backport lands, and Gutenberg's PHP tests run against WordPress trunk, so the filter now skips the links a response already has.
jorgefilipecosta
force-pushed
the
try/homepage-actions-rest-links
branch
from
October 16, 2026 12:49
cadc1f7 to
436eb12
Compare
#84829 added a `gutenberg/use-typescript` suppression for `packages/editor/src/utils/get-item-title.js`, which this branch deletes, so `npm run lint:js -- --prune-suppressions` removes it.
jorgefilipecosta
marked this pull request as ready for review
October 16, 2026 14:46
wporg-sync
pushed a commit
to WordPress/wordpress-develop
that referenced
this pull request
Oct 16, 2026
Adds the `action-set-homepage` and `action-set-posts-page` links to the published pages the current user can set as the homepage or as the posts page, in the `edit` context, and their link description objects to the pages schema. Both change the site settings, so they require `manage_options`, and the current homepage and posts page get neither. The editor uses them for its "Set as homepage" and "Set as posts page" actions. Developed in #14347 and WordPress/gutenberg#84932. Follow-up to [64343]. Props jorgefilipecosta, oandregal, chihsuan. Fixes #66327. git-svn-id: https://develop.svn.wordpress.org/trunk@64433 602fd350-edb4-49c9-b593-d223f7449a82
wporg-sync
pushed a commit
to WordPress/WordPress
that referenced
this pull request
Oct 16, 2026
Adds the `action-set-homepage` and `action-set-posts-page` links to the published pages the current user can set as the homepage or as the posts page, in the `edit` context, and their link description objects to the pages schema. Both change the site settings, so they require `manage_options`, and the current homepage and posts page get neither. The editor uses them for its "Set as homepage" and "Set as posts page" actions. Developed in WordPress/wordpress-develop#14347 and WordPress/gutenberg#84932. Follow-up to [64343]. Props jorgefilipecosta, oandregal, chihsuan. Fixes #66327. Built from https://develop.svn.wordpress.org/trunk@64433 git-svn-id: http://core.svn.wordpress.org/trunk@63583 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This was referenced Oct 21, 2026
arshidkv12
pushed a commit
to arshidkv12/wordpress-develop
that referenced
this pull request
Nov 21, 2026
Adds the `action-set-homepage` and `action-set-posts-page` links to the published pages the current user can set as the homepage or as the posts page, in the `edit` context, and their link description objects to the pages schema. Both change the site settings, so they require `manage_options`, and the current homepage and posts page get neither. The editor uses them for its "Set as homepage" and "Set as posts page" actions. Developed in WordPress#14347 and WordPress/gutenberg#84932. Follow-up to [64343]. Props jorgefilipecosta, oandregal, chihsuan. Fixes #66327. git-svn-id: https://develop.svn.wordpress.org/trunk@64433 602fd350-edb4-49c9-b593-d223f7449a82
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.
Part of #83537.
Fixes #76668.
Alternative to #84646.
Right now "Set as homepage" and "Set as posts page" are not entity actions.
usePostActions()creates them with hooks that read the site settings and the templates, and adds them to the actions the server returns, so a plugin can't remove them withwp_unregister_entity_actions(). They are hooks because whether a page can be set as the homepage depends on data outside the page: the current homepage and posts page, whether the user can change the site settings, and whether the theme has afront-pagetemplate.#84646 solves this by passing the registry to
isEligible. This PR keepsisEligible( item )as it is, and lets the server say which pages the actions apply to with REST links, as the core fields already do withwp:action-publishandwp:action-sticky, and the trash actions withwp:action-trash(#84045):wp:action-set-homepageandwp:action-set-posts-pagelinks to the published pages the current user can set as the homepage or as the posts page, in theeditcontext. The user needsmanage_options, like the settings route, and the current homepage and posts page don't get them.@wordpress/core-actions/pagescript module, and registers them on the server for pages when the user can manage the options and the theme has nofront-pagetemplate.isEligiblecheck the link of the action and that the page is published, without reading any store.usePostActions().Some notes:
GET /wp/v2/pages?include=…request per change.front-pagetemplate check to the links too, but it's the same for every page, so I opted for checking it once when the actions are registered.isEligibledon't change, the eligibility doesn't add work when the stores change, and the pages list no longer makes theOPTIONS /wp/v2/settings(v1) andGET /wp/v2/templates/lookup?slug=front-page(v2) requests. The menus are the same as on trunk in both site editors and in the inspector.@wordpress/core-actions.WP_REST_Posts_Controller::get_available_actions(), likeaction-trash. I'll open it if we go with this approach.Testing Instructions
front-pagetemplate (e.g. Twenty Twenty-Four), and create three published pages, "Page A", "Page B" and "Page C".( await wp.apiFetch( { path: '/wp/v2/pages?context=edit' } ) ).map( ( page ) => [ page.title.raw, Object.keys( page._links ).filter( ( rel ) => rel.startsWith( 'wp:action-set' ) ) ] )in the browser console, and verify every published page has both links except "Page B".AI usage disclosure: fix and description drafted with AI assistance and reviewed by me.