Skip to content

REST API: Expose the privacy policy page in the settings endpoint - #13399

Open
oandregal wants to merge 3 commits into
WordPress:trunkfrom
oandregal:add/privacy-policy-page-rest-setting
Open

REST API: Expose the privacy policy page in the settings endpoint#13399
oandregal wants to merge 3 commits into
WordPress:trunkfrom
oandregal:add/privacy-policy-page-rest-setting

Conversation

@oandregal

@oandregal oandregal commented Sep 4, 2026

Copy link
Copy Markdown
Member

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_policy option, but the option is not registered with show_in_rest, so the /wp/v2/settings endpoint cannot report it. This registers it as page_for_privacy_policy, alongside page_on_front and page_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(): register wp_page_for_privacy_policy with the REST name page_for_privacy_policy.
  • rest_restrict_privacy_policy_page_setting_update(): ignore updates from users without manage_privacy_options. The settings endpoint only checks manage_options, and on multisite manage_privacy_options maps to manage_network, so a site administrator could otherwise change the page over REST but not in Settings > Privacy.
  • Settings controller tests: expect the new key, and cover updating the setting with and without the capability.
  • REST fixture: add the new setting to the schema and the settings response.

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.

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>
Copilot AI lite review requested due to automatic review settings September 4, 2026 08:44
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

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 props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props oandregal, ntsekouras.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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_policy in register_initial_settings() with show_in_rest name page_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.

Comment thread src/wp-includes/option.php Outdated
*
* @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.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded in ad178e6 to say the option was registered and exposed as page_for_privacy_policy.

@oandregal oandregal self-assigned this Sep 4, 2026
@github-actions

github-actions Bot commented Sep 4, 2026

Copy link
Copy Markdown

Test using WordPress Playground

The 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

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

oandregal and others added 2 commits September 4, 2026 11:02
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>
@ntsekouras

Copy link
Copy Markdown
Contributor

Let's also include (if needed) this change in tests for multisite.

@oandregal
oandregal requested a review from Mamaduka September 4, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants