Skip to main content

benecaster_outlinks_health_guest_links

Filter Premium outlinks

Filters the list of guests’ publication links Link Health checks. Outlinks runs it once per Link Health check, in the background scan, starting from an empty list; Guest Manager adds its guests’ publication links. An add-on that keeps links on guests can add its own the same way.

Return a list of [ 'guest_id' => int, 'url' => string ], where guest_id is the published guest the link is on. Entries that are not arrays, have no positive guest_id, or whose URL is not http or https are skipped. One URL on one guest is one item however often it is listed. Link Health’s excluded domains apply.

Return untracked links only. A publication tracked with Outlinks as a site-wide link is already checked as that link’s destination, so listing its address here too would report one broken link twice.

The items appear on Settings → Link Health with the source Guest, the guest’s name and a link to edit the guest. They belong to no show, so filtering the page by show lists none of them. They can be dismissed and restored; Update URL, Unlink and Create outlink are refused, because the link lives in the guest’s profile and is corrected there. An item the filter stops returning is removed at the end of that check.

Parameters

Name Type Default Description
$links array — The guest links collected so far; empty to start

Returns: array

Example

add_filter( 'benecaster_outlinks_health_guest_links', function ( array $links ): array {
    foreach ( my_addon_guests_with_publications() as $guest_id => $publications ) {
        foreach ( $publications as $publication ) {
            if ( empty( $publication['outlinks_id'] ) ) {
                $links[] = [ 'guest_id' => $guest_id, 'url' => $publication['url'] ];
            }
        }
    }
    return $links;
} );

Notes

In benecaster_outlinks_health_check_completed, the notice and digest filters, and the Link Health items route (source=guest), these items are site links with source_type guest and source_id the guest's ID. Walkthrough: Have Link Health check the links your add-on keeps.

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