Repository navigation
REST API: Add the homepage and posts page action links to pages - #14347
jorgefilipecosta wants to merge 3 commits into
Conversation
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. Both change the site settings, so they require `manage_options`, and the current homepage and posts page get neither.
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. |
`update_option()` leaves the integer in the options cache, so these tests read an integer from `get_option()`, while a request reads a string from the database. Clearing the cache makes them fail when the `(int)` casts in `get_available_actions()` are removed.
…sts. Adds `@ticket 66327` to the new tests and a failure message to every assertion. The schema tests now count each LDO with `wp_list_filter()` and `assertCount()`, like the other LDO tests, so an LDO added twice fails them.
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
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
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
Backports the homepage and posts page action links from WordPress/gutenberg#84932, part of WordPress/gutenberg#83537.
Right now a client that wants to know whether a page can be set as the homepage or as the posts page needs the site settings on top of the page, and whether the user can read them. The editor reads them for its "Set as homepage" and "Set as posts page" actions. This PR lets the server say it with links, as
action-publish,action-stickyandaction-trashdo for other actions:https://api.w.org/action-set-homepageandhttps://api.w.org/action-set-posts-pagelinks to the published pages the current user can set as the homepage or as the posts page, in theeditcontext. Both change the site settings, so they requiremanage_options, like the settings route. The current homepage and posts page get neither.Some notes:
show_on_front, so the page stored inpage_on_frontgets neither while the homepage shows the latest posts.front-pagetemplate, which makes the homepage setting have no effect. It's the same for every page, so the Gutenberg PR checks it once, when it registers the actions.Testing Instructions
wp-admin/post-new.phpas an administrator. In the console, run( 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' ) ) ] )and verify "Page B" and "Page C" have both links and "Page A" has neither.context=viewand verify no page has them.npm run test:php -- --filter WP_Test_REST_Pages_Controller.Gutenberg PR: WordPress/gutenberg#84932
Trac ticket: https://core.trac.wordpress.org/ticket/66327
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.