Commit 503df7ff85 for wordpress.org

commit 503df7ff85c947113a0d63a56e0005833b5a655e
Author: oandregal <oandregal@git.wordpress.org>
Date:   Tue Sep 8 08:42:49 2026 +0000

    REST API: expose privacy policy page in settings endpoint.

    Props oandregal, ntsekouras, joen.
    Fixes #66045.

    Built from https://develop.svn.wordpress.org/trunk@63526


    git-svn-id: http://core.svn.wordpress.org/trunk@62702 1a063a9b-81f0-0310-95a4-ce76da25c4cd

diff --git a/wp-includes/default-filters.php b/wp-includes/default-filters.php
index 12ca0045b9..d16979c9c8 100644
--- a/wp-includes/default-filters.php
+++ b/wp-includes/default-filters.php
@@ -545,6 +545,7 @@ add_action( 'edit_user_created_user', 'wp_send_new_user_notifications', 10, 2 );
 add_action( 'init', 'rest_api_init' );
 add_action( 'rest_api_init', 'rest_api_default_filters', 10, 1 );
 add_action( 'rest_api_init', 'register_initial_settings', 10 );
+add_filter( 'rest_pre_update_setting', 'rest_restrict_privacy_policy_page_setting_update', 10, 2 );
 add_action( 'rest_api_init', 'create_initial_rest_routes', 99 );
 add_action( 'parse_request', 'rest_api_loaded' );

diff --git a/wp-includes/option.php b/wp-includes/option.php
index 5d877e7273..d5c179c645 100644
--- a/wp-includes/option.php
+++ b/wp-includes/option.php
@@ -2739,6 +2739,7 @@ function set_site_transient( $transient, $value, $expiration = 0 ) {
  *
  * @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 registered, exposed as `page_for_privacy_policy`.
  */
 function register_initial_settings() {
 	register_setting(
@@ -2931,6 +2932,18 @@ function register_initial_settings() {
 		)
 	);

+	register_setting(
+		'reading',
+		'wp_page_for_privacy_policy',
+		array(
+			'show_in_rest' => array(
+				'name' => 'page_for_privacy_policy',
+			),
+			'type'         => 'integer',
+			'description'  => __( 'The ID of the page that should be displayed as the privacy policy page' ),
+		)
+	);
+
 	register_setting(
 		'discussion',
 		'default_ping_status',
diff --git a/wp-includes/rest-api.php b/wp-includes/rest-api.php
index 0de022beac..c146289021 100644
--- a/wp-includes/rest-api.php
+++ b/wp-includes/rest-api.php
@@ -3447,6 +3447,27 @@ function rest_get_endpoint_args_for_schema( $schema, $method = WP_REST_Server::C
 	return $endpoint_args;
 }

+/**
+ * Prevents users without the `manage_privacy_options` capability from
+ * changing the privacy policy page through the REST API.
+ *
+ * The settings endpoint only checks `manage_options`. On multisite the
+ * `manage_privacy_options` capability maps to `manage_network`, so a site
+ * administrator can read the setting but must not change it, matching the
+ * Settings > Privacy screen.
+ *
+ * @since 7.2.0
+ *
+ * @param bool   $updated Whether the setting update has already been handled.
+ * @param string $name    Setting name (as shown in REST API responses).
+ * @return bool Whether to short-circuit the update.
+ */
+function rest_restrict_privacy_policy_page_setting_update( $updated, $name ) {
+	if ( 'page_for_privacy_policy' === $name && ! current_user_can( 'manage_privacy_options' ) ) {
+		return true;
+	}
+	return $updated;
+}

 /**
  * Converts an error to a response object.
diff --git a/wp-includes/version.php b/wp-includes/version.php
index d2c8d869b9..cbb6370034 100644
--- a/wp-includes/version.php
+++ b/wp-includes/version.php
@@ -16,7 +16,7 @@
  *
  * @global string $wp_version
  */
-$wp_version = '7.2-alpha-63525';
+$wp_version = '7.2-alpha-63526';

 /**
  * Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.