# Site Health Checks for Privacy Settings

> Adds Site Health tests that check whether a privacy policy page is published, whether full commenter IP addresses are being stored, and whether the comment cookie consent checkbox is turned on.

- Type: PHP
- Runs: Admin only
- Category: [Privacy & Cookies](https://wpide.com/library/category/privacy/)
- Tags: site-health, gdpr, audit
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/privacy-site-health-checks/

## Code

```php
add_filter( 'site_status_tests', function ( $tests ) {
    $result = function ( $id, $ok, $good, $bad, $fix ) {
        return array(
            'label'       => $ok ? $good : $bad,
            'status'      => $ok ? 'good' : 'recommended',
            'badge'       => array( 'label' => 'Privacy', 'color' => $ok ? 'blue' : 'orange' ),
            'description' => '<p>' . esc_html( $ok ? $good . '.' : $fix ) . '</p>',
            'test'        => $id,
        );
    };

    $tests['direct']['wpide_privacy_page'] = array(
        'label' => 'Privacy policy page',
        'test'  => function () use ( $result ) {
            $id = (int) get_option( 'wp_page_for_privacy_policy' );
            return $result( 'wpide_privacy_page', $id && 'publish' === get_post_status( $id ), 'A privacy policy page is published', 'No privacy policy page is published', 'Create and publish a privacy policy page, then select it under Settings > Privacy.' );
        },
    );

    $tests['direct']['wpide_comment_ips'] = array(
        'label' => 'Commenter IP addresses',
        'test'  => function () use ( $result ) {
            global $wpdb;
            $ip = (string) $wpdb->get_var( "SELECT comment_author_IP FROM {$wpdb->comments} WHERE comment_author_IP <> '' ORDER BY comment_ID DESC LIMIT 1" );
            $ok = '' === $ip || wp_privacy_anonymize_ip( $ip ) === $ip;
            return $result( 'wpide_comment_ips', $ok, 'New comments do not store full IP addresses', 'Full IP addresses are stored with comments', 'Store shortened IP addresses for comments, or none at all, unless your spam protection needs them.' );
        },
    );

    $tests['direct']['wpide_comment_cookies'] = array(
        'label' => 'Comment cookie consent',
        'test'  => function () use ( $result ) {
            $ok = ! get_option( 'default_comment_status' ) || 'closed' === get_option( 'default_comment_status' ) || get_option( 'show_comments_cookies_opt_in' );
            return $result( 'wpide_comment_cookies', (bool) $ok, 'Commenters are asked before their details are saved in a cookie', 'Comment cookies are set without asking', 'Turn on "Show comments cookies opt-in checkbox" under Settings > Discussion.' );
        },
    );

    return $tests;
} );
```

## Notes

Each result explains how to fix the setting; pair it with the IP shortening and consent snippets.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Site Health Checks for Privacy Settings" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
