WP_Privacy_Policy_Content::get_suggested_policy_text() WordPress Method
The WP_Privacy_Policy_Content::get_suggested_policy_text() method is used to get suggested policy text for a site. This text is designed to help site administrators create a privacy policy that meets the requirements of the EU General Data Protection Regulation (GDPR).
WP_Privacy_Policy_Content::get_suggested_policy_text() #
Check 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.
Source
File: wp-admin/includes/class-wp-privacy-policy-content.php
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 | 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' ); // Update the cache. foreach ( $checked as $data ) { add_post_meta( $policy_page_id , '_wp_suggested_privacy_policy_content' , $data ); } } return $checked ; } |
Expand full source codeCollapse full source codeView on TracView on GitHub
Changelog
Version | Description |
---|---|
4.9.6 | Introduced. |