REST API: Expose the privacy policy page in the settings endpoint - #13399
REST API: Expose the privacy policy page in the settings endpoint#13399oandregal wants to merge 3 commits into
Conversation
The page assigned in Settings > Privacy is stored in the `wp_page_for_privacy_policy` option, but the option is not registered with `show_in_rest`, so the settings endpoint cannot report it. Register it as `page_for_privacy_policy`, alongside `page_on_front` and `page_for_posts`, so the editor can label the privacy policy page. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
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. |
There was a problem hiding this comment.
🟢 Approval recommended
The change is small and consistent with existing settings registration patterns, and it includes corresponding test and fixture updates.
Pull request overview
Exposes the site’s configured Privacy Policy page through the REST API settings endpoint (/wp/v2/settings) by registering the underlying wp_page_for_privacy_policy option with a REST-facing name, enabling clients (e.g., the editor) to reliably read it alongside other reading-related page settings.
Changes:
- Register
wp_page_for_privacy_policyinregister_initial_settings()withshow_in_restnamepage_for_privacy_policy. - Extend the REST settings controller PHPUnit test to expect the new settings key.
- Update the QUnit REST API fixture schema and mocked settings payload to include
page_for_privacy_policy.
File summaries
| File | Description |
|---|---|
| src/wp-includes/option.php | Registers wp_page_for_privacy_policy for REST exposure as page_for_privacy_policy. |
| tests/phpunit/tests/rest-api/rest-settings-controller.php | Adds page_for_privacy_policy to the expected /wp/v2/settings response keys. |
| tests/qunit/fixtures/wp-api-generated.js | Extends the fixture schema and mocked settings response with page_for_privacy_policy. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| * | ||
| * @since 4.7.0 | ||
| * @since 6.0.1 The `show_on_front`, `page_on_front`, and `page_for_posts` options were added. | ||
| * @since 7.2.0 The `wp_page_for_privacy_policy` option was added. |
There was a problem hiding this comment.
Reworded in ad178e6 to say the option was registered and exposed as page_for_privacy_policy.
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 settings endpoint only checks `manage_options`. On multisite the `manage_privacy_options` capability maps to `manage_network`, so without this a site administrator could change the privacy policy page through the REST API but not through Settings > Privacy. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
|
Let's also include (if needed) this change in tests for multisite. |
Backport of WordPress/gutenberg#82422.
Trac ticket https://core.trac.wordpress.org/ticket/66045#ticket
The page assigned in Settings > Privacy is stored in the
wp_page_for_privacy_policyoption, but the option is not registered withshow_in_rest, so the/wp/v2/settingsendpoint cannot report it. This registers it aspage_for_privacy_policy, alongsidepage_on_frontandpage_for_posts, so the editor can show a "Privacy Policy Page" badge next to that page, as the classic pages list does.Changes:
register_initial_settings(): registerwp_page_for_privacy_policywith the REST namepage_for_privacy_policy.rest_restrict_privacy_policy_page_setting_update(): ignore updates from users withoutmanage_privacy_options. The settings endpoint only checksmanage_options, and on multisitemanage_privacy_optionsmaps tomanage_network, so a site administrator could otherwise change the page over REST but not in Settings > Privacy.Trac ticket:
Use of AI Tools
AI assistance: Yes
Tool(s): Claude Code
Model(s): Claude Fable 5.1
Used for: Drafting the change and the tests; reviewed and tested 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.