Skip to main content

benecaster_outlinks_health_digest_body

Filter Premium outlinks

Filters the HTML body of the Link Health email digest, or cancels one. It runs only when a digest is about to be sent, straight after benecaster_outlinks_health_digest_subject. The default body lists at most 50 of $new_items, then a count.

The body is raw HTML and is sent as you return it, so escape every value you add with esc_html() or esc_url(). A return that is not a string keeps the default.

An empty body, once trimmed, cancels that email: nothing is sent, the last-sent time does not move, and the items are not marked as reported, so the next check lists them again when it sends a digest.

Parameters

Name Type Default Description
$html string — The default body HTML
$new_items array — The items broken since the last digest, in the shape [benecaster_outlinks_health_check_completed](/hooks/benecaster_outlinks_health_check_completed/) describes
$total_broken int — How many items are broken in all

Returns: string

Example

add_filter( 'benecaster_outlinks_health_digest_body', function ( string $html, array $new_items, int $total_broken ): string {
    // Only email about tracked links; image and page-link breakages wait for the Link Health page.
    $redirects = array_filter( $new_items, fn( array $item ): bool => 'redirect' === $item['kind'] );
    if ( [] === $redirects ) {
        return '';
    }
    return $html . '<p>' . esc_html__( 'Fix tracked links first: they are in your show notes.', 'my-plugin' ) . '</p>';
}, 10, 3 );

Notes

To stop the digest altogether, set its schedule to off on Settings → Link Health rather than cancelling every email here. Walkthrough: Change the subject or body of the Link Health email digest, or skip one.

Need this built rather than just documented? See our services →