Make WordPress Core

Changeset 62844


Ignore:
Timestamp:
07/24/2026 03:47:25 PM (44 hours ago)
Author:
joedolson
Message:

Privacy: More accurate admin notices when saving.

When saving Privacy Policy page settings, show a notice that indicates there is no Privacy Policy page set instead of "Privacy Policy page updated successfully" if no page is selected. Differentiate between removing the current page and saving settings with no changes.

Developed in https://github.com/WordPress/wordpress-develop/pull/12247

Props anveshika, audrasjb, masteradhoc, micahele, adrianduffell, pedrofigueroa1989, joedolson.
Fixes #59276.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-admin/options-privacy.php

    r61456 r62844  
    5252
    5353        if ( 'set-privacy-page' === $action ) {
    54                 $privacy_policy_page_id = isset( $_POST['page_for_privacy_policy'] ) ? (int) $_POST['page_for_privacy_policy'] : 0;
     54                $previous_privacy_policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );
     55                $privacy_policy_page_id          = isset( $_POST['page_for_privacy_policy'] ) ? (int) $_POST['page_for_privacy_policy'] : 0;
    5556                update_option( 'wp_page_for_privacy_policy', $privacy_policy_page_id );
    5657
    57                 $privacy_page_updated_message = __( 'Privacy Policy page updated successfully.' );
     58                $privacy_page_message_type = 'success';
    5859
    5960                if ( $privacy_policy_page_id ) {
     61                        $privacy_page_updated_message = __( 'Privacy Policy page updated successfully.' );
     62
    6063                        /*
    6164                         * Don't always link to the menu customizer:
     
    7679                                );
    7780                        }
    78                 }
    79 
    80                 add_settings_error( 'page_for_privacy_policy', 'page_for_privacy_policy', $privacy_page_updated_message, 'success' );
     81                } elseif ( $previous_privacy_policy_page_id ) {
     82                        // A previously set Privacy Policy page was cleared.
     83                        $privacy_page_updated_message = __( 'Privacy Policy page removed.' );
     84                } else {
     85                        // No Privacy Policy page was set before, and none is set now.
     86                        $privacy_page_updated_message = __( 'No Privacy Policy page is currently set.' );
     87                        $privacy_page_message_type    = 'info';
     88                }
     89
     90                add_settings_error( 'page_for_privacy_policy', 'page_for_privacy_policy', $privacy_page_updated_message, $privacy_page_message_type );
    8191        } elseif ( 'create-privacy-page' === $action ) {
    8292
Note: See TracChangeset for help on using the changeset viewer.