Make WordPress Core


Ignore:
Timestamp:
09/08/2026 08:41:22 AM (15 hours ago)
Author:
oandregal
Message:

REST API: expose privacy policy page in settings endpoint.

Props oandregal, ntsekouras, joen.
Fixes #66045.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api.php

    r63509 r63526  
    34483448}
    34493449
     3450/**
     3451 * Prevents users without the `manage_privacy_options` capability from
     3452 * changing the privacy policy page through the REST API.
     3453 *
     3454 * The settings endpoint only checks `manage_options`. On multisite the
     3455 * `manage_privacy_options` capability maps to `manage_network`, so a site
     3456 * administrator can read the setting but must not change it, matching the
     3457 * Settings > Privacy screen.
     3458 *
     3459 * @since 7.2.0
     3460 *
     3461 * @param bool   $updated Whether the setting update has already been handled.
     3462 * @param string $name    Setting name (as shown in REST API responses).
     3463 * @return bool Whether to short-circuit the update.
     3464 */
     3465function rest_restrict_privacy_policy_page_setting_update( $updated, $name ) {
     3466        if ( 'page_for_privacy_policy' === $name && ! current_user_can( 'manage_privacy_options' ) ) {
     3467                return true;
     3468        }
     3469        return $updated;
     3470}
    34503471
    34513472/**
Note: See TracChangeset for help on using the changeset viewer.