Make WordPress Core

Opened 6 weeks ago

Closed 5 weeks ago

#66045 closed enhancement (fixed)

Expose privacy policy page through REST API

Reported by: oandregal Owned by: oandregal
Priority: normal Milestone: 7.2
Component: REST API Version: trunk
Severity: normal Keywords: has-patch has-unit-tests
Cc: Focuses:

Description

Change History (4)

This ticket was mentioned in ​PR #13399 on ​WordPress/wordpress-develop by ​@oandregal.


6 weeks ago
#1

  • Keywords has-unit-tests added

Backport of ​https://github.com/WordPress/gutenberg/pull/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.

​@ntsekouras commented on ​PR #13399:


6 weeks ago
#2

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

#4 @oandregal
5 weeks ago

  • Resolution → fixed
  • Status assigned → closed

In 63526:

REST API: expose privacy policy page in settings endpoint.

Props oandregal, ntsekouras, joen.
Fixes #66045.

Note: See TracTickets for help on using tickets.