New Privacy Policy page helpers coming in 5.2

In the WordPress 5.2 update new helpers have been added to make designing the Privacy Policy page easier.

In total 4 new items were added which are available to use in themes or plugins. There are 2 new CSSCSS CSS is an acronym for cascading style sheets. This is what controls the design or look and feel of a site. classes to help target the Privacy Policy page and menu items on the frontend, a new function that can be used in conditionals and a brand new template available to allow themes to design or style the Privacy Policy page anyway they choose.

  • is_privacy_policy() conditional query function
  • privacy-policy.php template
  • .privacy-policy body class
  • .menu-item-privacy-policy menu item class

You can start to take advantage of these items immediately upon the release of WordPress 5.2.

Backwards Compatibility

If the new additions are used on older versions of WordPress prior to 5.2 the template will not be used and the new CSS classes will not be output. The only backwards compatibility concern with using these new helpers is with the is_privacy_policy() function.

To support the is_privacy_policy() function pre-5.2 the following shim can be added to the theme or pluginPlugin A plugin is a piece of software containing a group of functions that can be added to a WordPress website. They can extend functionality or add new features to your WordPress websites. WordPress plugins are written in the PHP programming language and integrate seamlessly with WordPress. These can be free in the WordPress.org Plugin Directory https://wordpress.org/plugins/ or can be cost-based plugin from a third-party;

<?php
if ( ! function_exists( 'is_privacy_policy' ) ) {
        function is_privacy_policy() {
                return get_option( 'wp_page_for_privacy_policy' ) && is_page( get_option( 'wp_page_for_privacy_policy' ) );
        }
}