Add text to the “Privacy Policy Guide” for your plugin or theme

With WordPress 4.9.6, we got some new privacy tools. This includes the new “Privacy Policy Guide”. Have you ever heard of it or even used it? If not, you should take a look at it on your site. You will find it at “Settings | Privacy” and then in the “Policy Guide” tab.

Overview of text snippets for your privacy policy

When you run WordPress and have a couple of plugins installed, some of them might store user data. Even the theme might do that. In those cases, the GDPR and similar laws enforce you to inform the users about that data in your privacy policy. Yet, it can be hard to know what data is stored and for what purpose. Themes and plugins can provide you with a text snippet you can copy to your privacy policy page.

Adding a text snippet to the Privacy Policy Guide for your plugin or theme

When you develop themes or plugins and store user data, make sure to add a custom text to this special page, so anyone using your plugin or theme can copy it. To add text to this page, you have to call the wp_add_privacy_policy_content() function and pass it a title and policy text. This could look something like this:

function privacy_policy_demo_plugin_content() {
    $content = sprintf(
        '<p class="privacy-policy-tutorial">%1$s</p><strong class="privacy-policy-tutorial">%2$s</strong> %3$s',
        __( 'Privacy Policy Demo Plugin is using local Storage ...', 'privacy-policy-demo-plugin' ),
        __( 'Suggested text:', 'privacy-policy-demo-plugin' ),
        __( 'This website uses LocalStorage to save ...', 'privacy-policy-demo-plugin' )
    );
    wp_add_privacy_policy_content(
        __( 'Privacy Policy Demo Plugin', 'privacy-policy-demo-plugin' ),
        wp_kses_post( wpautop( $content, false ) )
    );
}
add_action( 'admin_init', 'privacy_policy_demo_plugin_content' );

With this snippet in your plugin or theme, you should be able to see the text on the Privacy Policy Guide like this:

The "Privacy Policy Guide" with our custom text as well as one for "Twenty-Twenty-One" with the notice "Removed December 17, 2023".

As you can see in this screenshot, you will find different text snippets here. A click on the button “Copy suggested policy text to clipboard” will only copy the text after the “Suggested text:” headline, so your text might need also to include the plugin or theme name, to make sense.

Update notices

You can also see a text snippet for “Twenty Twenty-One” here with the notice “Removed December 12, 2023”. Any text that is added using this functionality will be “versioned”. WordPress will automatically detect, if the text was updated, or in this case, if the theme or plugin has been removed or deactivate. This indicates, to the site’s owner, that they might want to update their privacy policy page or remove some old text from it.

Conclusion

Even though this feature is around since May 2018, many have never recognized it’s there and/or have used the text snippets presented here. If you, like me, haven’t checked this page for your sites for some time, maybe now is a good time to take another or first look at it.

Posted by

Bernhard is a full time web developer who likes to write WordPress plugins in his free time and is an active member of the WP Meetups in Berlin and Potsdam.

Leave a Reply

Your email address will not be published. Required fields are marked *