Create a gist now

Instantly share code, notes, and snippets.

Embed
Add support to your plugin or theme for WordPress Privacy Policy Generator (GDPR Compliance).
<?php
/**
* Return the default suggested privacy policy content.
*
* @return string The default policy content.
*/
function plugin_get_default_privacy_content() {
return
'<h2>' . __( 'What personal data we collect and why we collect it' ) . '</h2>' .
'<p>' . __( 'This text describes what type of information the admin should include here or what they should do with this info you provide in your template.' ) . '</p>';
}
/**
* Add the suggested privacy policy text to the policy postbox.
*/
function plugin_add_suggested_privacy_content() {
$content = plugin_get_default_privacy_content();
wp_add_privacy_policy_content( __( 'Plugin Name' ), $content );
}
// Not sure why but core registers their default text at priority 15, so to be after them (which I think would be the idea, you need to be 20+.
add_action( 'admin_init', 'plugin_add_suggested_privacy_content', 20 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment