wppaste
WordPress

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.

Properties · 1

$policy_contentprivate static

Methods · 10

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.

  1. 6.7.7
  2. 6.8.8
  3. 6.9.7
  4. 7.0.4
  5. 7.1.0

Signature, return type and hooks compared across 5 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 6.7.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.