benecaster_outlinks_health_notice_message
Filters the message of the Link Health warning in Benecaster’s Notifications. It runs at the end of each finished Link Health check, only when the notice is about to be shown because something is broken. A check that finds nothing broken removes the notice and does not run the filter.
$message is the default in the site’s language, such as “Link Health found 3 broken links or images on your site.” $broken_items is the same list benecaster_outlinks_health_check_completed receives: each item has key, kind (redirect for a tracked link, site_link for a link or image in site content) and its details.
The notice’s title, its Open Link Health button, and when it is shown or brought back after a dismissal are not changed by the filter.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$message |
string |
— | The default message |
$count |
int |
— | How many items Link Health counts as broken |
$broken_items |
array |
— | Everything Link Health counts as broken |
Returns:
string
Example
add_filter( 'benecaster_outlinks_health_notice_message', function ( string $message, int $count, array $broken_items ): string {
$tracked = count( array_filter( $broken_items, fn( array $item ): bool => 'redirect' === $item['kind'] ) );
return $tracked > 0 ? sprintf( '%d broken, %d of them tracked links. Fix the tracked ones first.', $count, $tracked ) : $message;
}, 10, 3 );
Notes
The return is trimmed. A return that is not a string, or is empty once trimmed, keeps the default. Walkthrough: Change the wording of the Link Health warning under Notifications.
Need this built rather than just documented? See our services →