wp_add_privacy_policy_content

The timeline below displays how wordpress function wp_add_privacy_policy_content has changed across different WordPress versions. If a version is not listed, refer to the next available version below.

WordPress Version: 6.1

/**
 * Declares a helper function for adding content to the Privacy Policy Guide.
 *
 * Plugins and themes should suggest text for inclusion in the site's privacy policy.
 * The suggested text should contain information about any functionality that affects user privacy,
 * and will be shown on the Privacy Policy Guide screen.
 *
 * A plugin or theme can use this function multiple times as long as it will help to better present
 * the suggested policy content. For example modular plugins such as WooCommerse or Jetpack
 * can add or remove suggested content depending on the modules/extensions that are enabled.
 * For more information see the Plugin Handbook:
 * https://developer.wordpress.org/plugins/privacy/suggesting-text-for-the-site-privacy-policy/.
 *
 * The HTML contents of the `$policy_text` supports use of a specialized `.privacy-policy-tutorial`
 * CSS class which can be used to provide supplemental information. Any content contained within
 * HTML elements that have the `.privacy-policy-tutorial` CSS class applied will be omitted
 * from the clipboard when the section content is copied.
 *
 * Intended for use with the `'admin_init'` action.
 *
 * @since 4.9.6
 *
 * @param string $plugin_name The name of the plugin or theme that is suggesting content
 *                            for the site's privacy policy.
 * @param string $policy_text The suggested content for inclusion in the policy.
 */
function wp_add_privacy_policy_content($plugin_name, $policy_text)
{
    if (!is_admin()) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: %s: admin_init */
            __('The suggested privacy policy content should be added only in wp-admin by using the %s (or later) action.'),
            '<code>admin_init</code>'
        ), '4.9.7');
        return;
    } elseif (!doing_action('admin_init') && !did_action('admin_init')) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: %s: admin_init */
            __('The suggested privacy policy content should be added by using the %s (or later) action. Please see the inline documentation.'),
            '<code>admin_init</code>'
        ), '4.9.7');
        return;
    }
    if (!class_exists('WP_Privacy_Policy_Content')) {
        require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
    }
    WP_Privacy_Policy_Content::add($plugin_name, $policy_text);
}

WordPress Version: 5.4

/**
 * Helper function for adding content to the Privacy Policy Guide.
 *
 * Plugins and themes should suggest text for inclusion in the site's privacy policy.
 * The suggested text should contain information about any functionality that affects user privacy,
 * and will be shown on the Privacy Policy Guide screen.
 *
 * A plugin or theme can use this function multiple times as long as it will help to better present
 * the suggested policy content. For example modular plugins such as WooCommerse or Jetpack
 * can add or remove suggested content depending on the modules/extensions that are enabled.
 * For more information see the Plugin Handbook:
 * https://developer.wordpress.org/plugins/privacy/suggesting-text-for-the-site-privacy-policy/.
 *
 * The HTML contents of the `$policy_text` supports use of a specialized `.privacy-policy-tutorial`
 * CSS class which can be used to provide supplemental information. Any content contained within
 * HTML elements that have the `.privacy-policy-tutorial` CSS class applied will be omitted
 * from the clipboard when the section content is copied.
 *
 * Intended for use with the `'admin_init'` action.
 *
 * @since 4.9.6
 *
 * @param string $plugin_name The name of the plugin or theme that is suggesting content
 *                            for the site's privacy policy.
 * @param string $policy_text The suggested content for inclusion in the policy.
 */
function wp_add_privacy_policy_content($plugin_name, $policy_text)
{
    if (!is_admin()) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: %s: admin_init */
            __('The suggested privacy policy content should be added only in wp-admin by using the %s (or later) action.'),
            '<code>admin_init</code>'
        ), '4.9.7');
        return;
    } elseif (!doing_action('admin_init') && !did_action('admin_init')) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: %s: admin_init */
            __('The suggested privacy policy content should be added by using the %s (or later) action. Please see the inline documentation.'),
            '<code>admin_init</code>'
        ), '4.9.7');
        return;
    }
    if (!class_exists('WP_Privacy_Policy_Content')) {
        require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
    }
    WP_Privacy_Policy_Content::add($plugin_name, $policy_text);
}

WordPress Version: 5.3

/**
 * Helper function for adding content to the Privacy Policy Guide.
 *
 * Plugins and themes should suggest text for inclusion in the site's privacy policy.
 * The suggested text should contain information about any functionality that affects user privacy,
 * and will be shown on the Privacy Policy Guide screen.
 *
 * A plugin or theme can use this function multiple times as long as it will help to better present
 * the suggested policy content. For example modular plugins such as WooCommerse or Jetpack
 * can add or remove suggested content depending on the modules/extensions that are enabled.
 * For more information see the Plugin Handbook:
 * https://developer.wordpress.org/plugins/privacy/suggesting-text-for-the-site-privacy-policy/.
 *
 * Intended for use with the `'admin_init'` action.
 *
 * @since 4.9.6
 *
 * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy.
 * @param string $policy_text The suggested content for inclusion in the policy.
 */
function wp_add_privacy_policy_content($plugin_name, $policy_text)
{
    if (!is_admin()) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: %s: admin_init */
            __('The suggested privacy policy content should be added only in wp-admin by using the %s (or later) action.'),
            '<code>admin_init</code>'
        ), '4.9.7');
        return;
    } elseif (!doing_action('admin_init') && !did_action('admin_init')) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: %s: admin_init */
            __('The suggested privacy policy content should be added by using the %s (or later) action. Please see the inline documentation.'),
            '<code>admin_init</code>'
        ), '4.9.7');
        return;
    }
    if (!class_exists('WP_Privacy_Policy_Content')) {
        require_once ABSPATH . 'wp-admin/includes/class-wp-privacy-policy-content.php';
    }
    WP_Privacy_Policy_Content::add($plugin_name, $policy_text);
}

WordPress Version: 9.7

/**
 * Helper function for adding content to the Privacy Policy Guide.
 *
 * Plugins and themes should suggest text for inclusion in the site's privacy policy.
 * The suggested text should contain information about any functionality that affects user privacy,
 * and will be shown on the Privacy Policy Guide screen.
 *
 * A plugin or theme can use this function multiple times as long as it will help to better present
 * the suggested policy content. For example modular plugins such as WooCommerse or Jetpack
 * can add or remove suggested content depending on the modules/extensions that are enabled.
 * For more information see the Plugin Handbook:
 * https://developer.wordpress.org/plugins/privacy/suggesting-text-for-the-site-privacy-policy/.
 *
 * Intended for use with the `'admin_init'` action.
 *
 * @since 4.9.6
 *
 * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy.
 * @param string $policy_text The suggested content for inclusion in the policy.
 */
function wp_add_privacy_policy_content($plugin_name, $policy_text)
{
    if (!is_admin()) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: %s: admin_init */
            __('The suggested privacy policy content should be added only in wp-admin by using the %s (or later) action.'),
            '<code>admin_init</code>'
        ), '4.9.7');
        return;
    } elseif (!doing_action('admin_init') && !did_action('admin_init')) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: %s: admin_init */
            __('The suggested privacy policy content should be added by using the %s (or later) action. Please see the inline documentation.'),
            '<code>admin_init</code>'
        ), '4.9.7');
        return;
    }
    if (!class_exists('WP_Privacy_Policy_Content')) {
        require_once ABSPATH . 'wp-admin/includes/misc.php';
    }
    WP_Privacy_Policy_Content::add($plugin_name, $policy_text);
}

WordPress Version: 9.6

/**
 * Helper function for adding content to the postbox shown when editing the privacy policy.
 *
 * Plugins and themes should suggest text for inclusion in the site's privacy policy.
 * The suggested text should contain information about any functionality that affects user privacy,
 * and will be shown in the Suggested Privacy Policy Content postbox.
 *
 * A plugin or theme can use this function multiple times as long as it will help to better present
 * the suggested policy content. For example modular plugins such as WooCommerse or Jetpack
 * can add or remove suggested content depending on the modules/extensions that are enabled.
 *
 * Intended for use with the `'admin_init'` action.
 *
 * @since 4.9.6
 *
 * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy.
 * @param string $policy_text The suggested content for inclusion in the policy.
 *                            For more information see the Plugins Handbook https://developer.wordpress.org/plugins/. 
 */
function wp_add_privacy_policy_content($plugin_name, $policy_text)
{
    if (!class_exists('WP_Privacy_Policy_Content')) {
        require_once ABSPATH . 'wp-admin/includes/misc.php';
    }
    WP_Privacy_Policy_Content::add($plugin_name, $policy_text);
}

WordPress Version: .10

/**
 * Helper function for adding content to the Privacy Policy Guide.
 *
 * Plugins and themes should suggest text for inclusion in the site's privacy policy.
 * The suggested text should contain information about any functionality that affects user privacy,
 * and will be shown on the Privacy Policy Guide screen.
 *
 * A plugin or theme can use this function multiple times as long as it will help to better present
 * the suggested policy content. For example modular plugins such as WooCommerse or Jetpack
 * can add or remove suggested content depending on the modules/extensions that are enabled.
 * For more information see the Plugin Handbook:
 * https://developer.wordpress.org/plugins/privacy/suggesting-text-for-the-site-privacy-policy/.
 *
 * Intended for use with the `'admin_init'` action.
 *
 * @since 4.9.6
 *
 * @param string $plugin_name The name of the plugin or theme that is suggesting content for the site's privacy policy.
 * @param string $policy_text The suggested content for inclusion in the policy.
 */
function wp_add_privacy_policy_content($plugin_name, $policy_text)
{
    if (!is_admin()) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: %s: admin_init */
            __('The suggested privacy policy content should be added only in wp-admin by using the %s (or later) action.'),
            '<code>admin_init</code>'
        ), '4.9.7');
        return;
    } elseif (!doing_action('admin_init') && !did_action('admin_init')) {
        _doing_it_wrong(__FUNCTION__, sprintf(
            /* translators: %s: admin_init */
            __('The suggested privacy policy content should be added by using the %s (or later) action. Please see the inline documentation.'),
            '<code>admin_init</code>'
        ), '4.9.7');
        return;
    }
    if (!class_exists('WP_Privacy_Policy_Content')) {
        require_once ABSPATH . 'wp-admin/includes/misc.php';
    }
    WP_Privacy_Policy_Content::add($plugin_name, $policy_text);
}