WP_Privacy_Policy_Content
- Since
- 4.9.6
- Source
wp-admin/includes/class-wp-privacy-policy-content.php:10
WP_Privacy_Policy_Content class.
Compatibility
- WordPress
- since 4.9.6
- 6.7.7
- 6.8.8
- 6.9.7
- 7.0.4
- 7.1.0
Present in every tracked release (6.7.7 to 7.1.0).
Hooks and filters fired · 1
Every hook that fires from inside WP_Privacy_Policy_Content, in the order it appears in the class, grouped by the method that fires it.
WP_Privacy_Policy_Content::get_default_content()
- do_action( wp_get_default_privacy_policy_content )filter_deprecated line 687
Properties · 1
$policy_contentprivate static
Methods · 10
- __construct()Constructor
- add()Adds content to the postbox shown when editing the privacy policy.
- text_change_check()Performs a quick check to determine whether any privacy info has changed.
- policy_text_changed_notice()Outputs a warning when some privacy info has changed.
- _policy_page_updated()Updates the cached policy info when the policy page is updated.
- get_suggested_policy_text()Checks for updated, added or removed privacy policy information from plugins.
- notice()Adds a notice with a link to the guide when editing the privacy policy page.
- privacy_policy_guide()Outputs the privacy policy guide together with content from the theme and plugins.
- get_default_content()Returns the default suggested privacy policy content.
- add_suggested_content()Adds the suggested privacy policy text to the policy postbox.
Source code
#[AllowDynamicProperties]final class WP_Privacy_Policy_Content { private static $policy_content = array(); /** * Constructor * * @since 4.9.6 */ private function __construct() {} /** * 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, * and will be shown in the Suggested Privacy Policy Content postbox. * * Intended for use from `wp_add_privacy_policy_content()`. * * @since 4.9.6 * * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy. * @param string $policy_text The suggested content for inclusion in the policy. */ public static function add( $plugin_name, $policy_text ) { if ( empty( $plugin_name ) || empty( $policy_text ) ) { return; } $data = array( 'plugin_name' => $plugin_name, 'policy_text' => $policy_text, ); if ( ! in_array( $data, self::$policy_content, true ) ) { self::$policy_content[] = $data; } } /** * Performs a quick check to determine whether any privacy info has changed. * * @since 4.9.6 */ public static function text_change_check() { $policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' ); // The site doesn't have a privacy policy. if ( empty( $policy_page_id ) ) { return false; } if ( ! current_user_can( 'edit_post', $policy_page_id ) ) { return false; } $old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' ); // Updates are not relevant if the user has not reviewed any suggestions yet. if ( empty( $old ) ) { return false; } $cached = get_option( '_wp_suggested_policy_text_has_changed' ); /* * When this function is called before `admin_init`, `self::$policy_content` * has not been populated yet, so use the cached result from the last * execution instead. */ if ( ! did_action( 'admin_init' ) ) { return 'changed' === $cached; } $new = self::$policy_content; // Remove the extra values added to the meta.Changelog
Introduced in 4.9.6. Unchanged from 6.7.7 through 7.1.0.
Signature, return type and hooks compared across 5 parsed releases.
About this page
- Parsed data
- Generated from the wordpress-develop 6.9.7 tag, from
src/wp-admin/includes/class-wp-privacy-policy-content.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. - Corrections
- Something wrong on this page? Report it and it gets fixed in the next regeneration.