wppaste
WordPress

WP_Privacy_Policy_Content::get_suggested_policy_text(): array

Since
4.9.6
Source
wp-admin/includes/class-wp-privacy-policy-content.php:215
Checks for updated, added or removed privacy policy information from plugins.

Description

Caches the current info in post_meta of the policy page.

Return

array
The privacy policy text/information added by core and plugins.

Uses · 4

Used by · 1

Source

	public static function get_suggested_policy_text() {		$policy_page_id = (int) get_option( 'wp_page_for_privacy_policy' );		$checked        = array();		$time           = time();		$update_cache   = false;		$new            = self::$policy_content;		$old            = array(); 		if ( $policy_page_id ) {			$old = (array) get_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' );		} 		// Check for no-changes and updates.		foreach ( $new as $new_key => $new_data ) {			foreach ( $old as $old_key => $old_data ) {				$found = false; 				if ( $new_data['policy_text'] === $old_data['policy_text'] ) {					// Use the new plugin name in case it was changed, translated, etc.					if ( $old_data['plugin_name'] !== $new_data['plugin_name'] ) {						$old_data['plugin_name'] = $new_data['plugin_name'];						$update_cache            = true;					} 					// A plugin was re-activated.					if ( ! empty( $old_data['removed'] ) ) {						unset( $old_data['removed'] );						$old_data['added'] = $time;						$update_cache      = true;					} 					$checked[] = $old_data;					$found     = true;				} elseif ( $new_data['plugin_name'] === $old_data['plugin_name'] ) {					// The info for the policy was updated.					$checked[]    = array(						'plugin_name' => $new_data['plugin_name'],						'policy_text' => $new_data['policy_text'],						'updated'     => $time,					);					$found        = true;					$update_cache = true;				} 				if ( $found ) {					unset( $new[ $new_key ], $old[ $old_key ] );					continue 2;				}			}		} 		if ( ! empty( $new ) ) {			// A plugin was activated.			foreach ( $new as $new_data ) {				if ( ! empty( $new_data['plugin_name'] ) && ! empty( $new_data['policy_text'] ) ) {					$new_data['added'] = $time;					$checked[]         = $new_data;				}			}			$update_cache = true;		} 		if ( ! empty( $old ) ) {			// A plugin was deactivated.			foreach ( $old as $old_data ) {				if ( ! empty( $old_data['plugin_name'] ) && ! empty( $old_data['policy_text'] ) ) {					$data = array(						'plugin_name' => $old_data['plugin_name'],						'policy_text' => $old_data['policy_text'],						'removed'     => $time,					); 					$checked[] = $data;				}			}			$update_cache = true;		} 		if ( $update_cache && $policy_page_id ) {			delete_post_meta( $policy_page_id, '_wp_suggested_privacy_policy_content' );

History

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.