diff -r 7b1b88e27a20 -r 48c4eec2b7e6 wp/wp-admin/includes/class-wp-privacy-policy-content.php --- a/wp/wp-admin/includes/class-wp-privacy-policy-content.php Thu Sep 29 08:06:27 2022 +0200 +++ b/wp/wp-admin/includes/class-wp-privacy-policy-content.php Fri Sep 05 18:40:08 2025 +0200 @@ -7,6 +7,7 @@ * @since 4.9.6 */ +#[AllowDynamicProperties] final class WP_Privacy_Policy_Content { private static $policy_content = array(); @@ -19,7 +20,7 @@ private function __construct() {} /** - * Add content to the postbox shown when editing the privacy policy. + * Adds content to the postbox shown when editing the privacy policy. * * Plugins and themes should suggest text for inclusion in the site's privacy policy. * The suggested text should contain information about any functionality that affects user privacy, @@ -48,7 +49,7 @@ } /** - * Quick check if any privacy info has changed. + * Performs a quick check to determine whether any privacy info has changed. * * @since 4.9.6 */ @@ -102,11 +103,15 @@ sort( $old ); sort( $new ); - // The == operator (equal, not identical) was used intentionally. - // See http://php.net/manual/en/language.operators.array.php + /* + * The == operator (equal, not identical) was used intentionally. + * See https://www.php.net/manual/en/language.operators.array.php + */ if ( $new != $old ) { - // A plugin was activated or deactivated, or some policy text has changed. - // Show a notice on the relevant screens to inform the admin. + /* + * A plugin was activated or deactivated, or some policy text has changed. + * Show a notice on the relevant screens to inform the admin. + */ add_action( 'admin_notices', array( 'WP_Privacy_Policy_Content', 'policy_text_changed_notice' ) ); $state = 'changed'; } else { @@ -122,38 +127,35 @@ } /** - * Output a warning when some privacy info has changed. + * Outputs a warning when some privacy info has changed. * * @since 4.9.6 - * - * @global WP_Post $post Global post object. */ public static function policy_text_changed_notice() { - global $post; - $screen = get_current_screen()->id; if ( 'privacy' !== $screen ) { return; } - ?> -
-

- review the guide and update your privacy policy.' ), - esc_url( admin_url( 'privacy-policy-guide.php?tab=policyguide' ) ) - ); - ?> -

-
- review the guide and update your privacy policy.' ), + esc_url( admin_url( 'privacy-policy-guide.php?tab=policyguide' ) ) + ); + + wp_admin_notice( + $privacy_message, + array( + 'type' => 'warning', + 'additional_classes' => array( 'policy-text-updated' ), + 'dismissible' => true, + ) + ); } /** - * Update the cached policy info when the policy page is updated. + * Updates the cached policy info when the policy page is updated. * * @since 4.9.6 * @access private @@ -202,7 +204,7 @@ } /** - * Check for updated, added or removed privacy policy information from plugins. + * Checks for updated, added or removed privacy policy information from plugins. * * Caches the current info in post_meta of the policy page. * @@ -300,7 +302,7 @@ } /** - * Add a notice with a link to the guide when editing the privacy policy page. + * Adds a notice with a link to the guide when editing the privacy policy page. * * @since 4.9.6 * @since 5.0.0 The `$post` parameter was made optional. @@ -351,27 +353,25 @@ 'after' ); } else { - ?> -
-

- %s %s', - $url, - $label, - /* translators: Accessibility text. */ - __( '(opens in a new tab)' ) - ); - ?> -

-
- %s %s', + $url, + $label, + /* translators: Hidden accessibility text. */ + __( '(opens in a new tab)' ) + ); + wp_admin_notice( + $message, + array( + 'type' => 'warning', + 'additional_classes' => array( 'inline', 'wp-pp-notice' ), + ) + ); } } /** - * Output the privacy policy guide together with content from the theme and plugins. + * Outputs the privacy policy guide together with content from the theme and plugins. * * @since 4.9.6 */ @@ -393,8 +393,14 @@ $badge_title = sprintf( __( 'Removed %s.' ), $date ); /* translators: %s: Date of plugin deactivation. */ - $removed = __( 'You deactivated this plugin on %s and may no longer need this policy.' ); - $removed = '

' . sprintf( $removed, $date ) . '

'; + $removed = sprintf( __( 'You deactivated this plugin on %s and may no longer need this policy.' ), $date ); + $removed = wp_get_admin_notice( + $removed, + array( + 'type' => 'info', + 'additional_classes' => array( 'inline' ), + ) + ); } elseif ( ! empty( $section['updated'] ) ) { $badge_class = ' blue'; $date = date_i18n( $date_format, $section['updated'] ); @@ -427,7 +433,7 @@ @@ -440,7 +446,7 @@ } /** - * Return the default suggested privacy policy content. + * Returns the default suggested privacy policy content. * * @since 4.9.6 * @since 5.0.0 Added the `$blocks` parameter. @@ -460,7 +466,7 @@ } /* translators: Default privacy policy heading. */ - $strings[] = '

' . __( 'Who we are' ) . '

'; + $strings[] = '

' . __( 'Who we are' ) . '

'; if ( $description ) { /* translators: Privacy policy tutorial. */ @@ -488,7 +494,7 @@ } /* translators: Default privacy policy heading. */ - $strings[] = '

' . __( 'Comments' ) . '

'; + $strings[] = '

' . __( 'Comments' ) . '

'; if ( $description ) { /* translators: Privacy policy tutorial. */ @@ -501,7 +507,7 @@ } /* translators: Default privacy policy heading. */ - $strings[] = '

' . __( 'Media' ) . '

'; + $strings[] = '

' . __( 'Media' ) . '

'; if ( $description ) { /* translators: Privacy policy tutorial. */ @@ -519,11 +525,11 @@ } /* translators: Default privacy policy heading. */ - $strings[] = '

' . __( 'Cookies' ) . '

'; + $strings[] = '

' . __( 'Cookies' ) . '

'; if ( $description ) { /* translators: Privacy policy tutorial. */ - $strings[] = '

' . __( 'In this subsection you should list the cookies your web site uses, including those set by your plugins, social media, and analytics. We have provided the cookies which WordPress installs by default.' ) . '

'; + $strings[] = '

' . __( 'In this subsection you should list the cookies your website uses, including those set by your plugins, social media, and analytics. We have provided the cookies which WordPress installs by default.' ) . '

'; } else { /* translators: Default privacy policy text. */ $strings[] = '

' . $suggested_text . __( 'If you leave a comment on our site you may opt-in to saving your name, email address and website in cookies. These are for your convenience so that you do not have to fill in your details again when you leave another comment. These cookies will last for one year.' ) . '

'; @@ -537,7 +543,7 @@ if ( ! $description ) { /* translators: Default privacy policy heading. */ - $strings[] = '

' . __( 'Embedded content from other websites' ) . '

'; + $strings[] = '

' . __( 'Embedded content from other websites' ) . '

'; /* translators: Default privacy policy text. */ $strings[] = '

' . $suggested_text . __( 'Articles on this site may include embedded content (e.g. videos, images, articles, etc.). Embedded content from other websites behaves in the exact same way as if the visitor has visited the other website.' ) . '

'; /* translators: Default privacy policy text. */ @@ -554,7 +560,7 @@ } /* translators: Default privacy policy heading. */ - $strings[] = '

' . __( 'Who we share your data with' ) . '

'; + $strings[] = '

' . __( 'Who we share your data with' ) . '

'; if ( $description ) { /* translators: Privacy policy tutorial. */ @@ -567,11 +573,11 @@ } /* translators: Default privacy policy heading. */ - $strings[] = '

' . __( 'How long we retain your data' ) . '

'; + $strings[] = '

' . __( 'How long we retain your data' ) . '

'; if ( $description ) { /* translators: Privacy policy tutorial. */ - $strings[] = '

' . __( 'In this section you should explain how long you retain personal data collected or processed by the web site. While it is your responsibility to come up with the schedule of how long you keep each dataset for and why you keep it, that information does need to be listed here. For example, you may want to say that you keep contact form entries for six months, analytics records for a year, and customer purchase records for ten years.' ) . '

'; + $strings[] = '

' . __( 'In this section you should explain how long you retain personal data collected or processed by the website. While it is your responsibility to come up with the schedule of how long you keep each dataset for and why you keep it, that information does need to be listed here. For example, you may want to say that you keep contact form entries for six months, analytics records for a year, and customer purchase records for ten years.' ) . '

'; } else { /* translators: Default privacy policy text. */ $strings[] = '

' . $suggested_text . __( 'If you leave a comment, the comment and its metadata are retained indefinitely. This is so we can recognize and approve any follow-up comments automatically instead of holding them in a moderation queue.' ) . '

'; @@ -580,7 +586,7 @@ } /* translators: Default privacy policy heading. */ - $strings[] = '

' . __( 'What rights you have over your data' ) . '

'; + $strings[] = '

' . __( 'What rights you have over your data' ) . '

'; if ( $description ) { /* translators: Privacy policy tutorial. */ @@ -591,7 +597,7 @@ } /* translators: Default privacy policy heading. */ - $strings[] = '

' . __( 'Where your data is sent' ) . '

'; + $strings[] = '

' . __( 'Where your data is sent' ) . '

'; if ( $description ) { /* translators: Privacy policy tutorial. */ @@ -635,14 +641,14 @@ /* translators: Default privacy policy heading. */ $strings[] = '

' . __( 'What third parties we receive data from' ) . '

'; /* translators: Privacy policy tutorial. */ - $strings[] = '

' . __( 'If your web site receives data about users from third parties, including advertisers, this information must be included within the section of your privacy policy dealing with third party data.' ) . '

'; + $strings[] = '

' . __( 'If your website receives data about users from third parties, including advertisers, this information must be included within the section of your privacy policy dealing with third party data.' ) . '

'; } if ( $description ) { /* translators: Default privacy policy heading. */ $strings[] = '

' . __( 'What automated decision making and/or profiling we do with user data' ) . '

'; /* translators: Privacy policy tutorial. */ - $strings[] = '

' . __( 'If your web site provides a service which includes automated decision making - for example, allowing customers to apply for credit, or aggregating their data into an advertising profile - you must note that this is taking place, and include information about how that information is used, what decisions are made with that aggregated data, and what rights users have over decisions made without human intervention.' ) . '

'; + $strings[] = '

' . __( 'If your website provides a service which includes automated decision making - for example, allowing customers to apply for credit, or aggregating their data into an advertising profile - you must note that this is taking place, and include information about how that information is used, what decisions are made with that aggregated data, and what rights users have over decisions made without human intervention.' ) . '

'; } if ( $description ) { @@ -655,12 +661,12 @@ if ( $blocks ) { foreach ( $strings as $key => $string ) { - if ( 0 === strpos( $string, '

' ) ) { - $strings[ $key ] = '' . $string . ''; + if ( str_starts_with( $string, '

' ) ) { + $strings[ $key ] = "\n" . $string . "\n\n"; } - if ( 0 === strpos( $string, '

' ) ) { - $strings[ $key ] = '' . $string . ''; + if ( str_starts_with( $string, '

\n"; } } } @@ -689,7 +695,7 @@ } /** - * Add the suggested privacy policy text to the policy postbox. + * Adds the suggested privacy policy text to the policy postbox. * * @since 4.9.6 */