Skip to main content

benecaster_outlinks_health_check_completed

Action Premium outlinks

Fires once at the end of each finished Link Health check, after the Link Health notice and the email digest have been handled. A check that runs out of time carries on in a later request; the hook fires only at the end of the request that finishes it.

$broken_items is everything Link Health counts as broken now, the same list the notice counts: [] when nothing is. Tracked links come first, then links and images in site content, each in id order. Every item has key (redirect:{id} or site_link:{id}, stable from run to run) and kind (redirect or site_link).

  • A tracked link (broken and not dismissed) also has id, slug and destination_url.
  • A site link (last check broken, not dismissed, not on an excluded domain) also has id, url, item_type (link or image), source_type (episode, page or post), source_id (the post) and http_status (null when there was no response).

The check is install-wide and scheduled only while Outlinks is switched on for at least one show, so the hook never fires while Outlinks is off for every show or the licence has lapsed. It runs under WP-Cron, with no user logged in.

Parameters

Name Type Default Description
$broken_items array — Everything Link Health counts as broken now, in the shape above
$finished_at int — Unix time the check finished

Examples

Report the run to a status service

add_action( 'benecaster_outlinks_health_check_completed', function ( array $broken_items, int $finished_at ): void {
    $redirects = array_filter( $broken_items, fn( array $item ): bool => 'redirect' === $item['kind'] );
    wp_remote_post( 'https://status.example.com/hooks/link-health', [
        'body' => wp_json_encode( [ 'at' => gmdate( 'c', $finished_at ), 'broken' => count( $broken_items ), 'tracked_links' => array_column( $redirects, 'slug' ) ] ),
    ] );
}, 10, 2 );

Notes

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