benecaster_outlinks_health_item_action_after
Fires after Link Health has written one of its actions to one item, and only when that item succeeded. It pairs with benecaster_outlinks_health_item_action_before, which fires for every item that passed its checks; an item whose write failed fires before with no after.
$result is the item’s row from the actions route’s answer: ok is true, update_url adds the cleaned url, and create_outlink adds redirect with the new link’s id, slug, go_url and destination_url.
$args depends on the action, as on the before hook: [] for dismiss and restore; old_url, url and post_id for update_url; url and post_id for unlink; url, post_id, show_id and slug for create_outlink.
Link Health is install-wide and needs Outlinks switched on for at least one show, so the hook never fires while Outlinks is off for every show or the licence has lapsed.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
$action |
string |
— | `dismiss`, `restore`, `update_url`, `unlink` or `create_outlink` |
$item |
array |
— | `[ 'type' => 'site_link'|'redirect', 'id' => int ]`, the pair the actions route takes |
$args |
array |
— | What the action wrote, by action as listed above |
$result |
array |
— | The item's result row from the actions route's answer |
Examples
Log every fixed URL
add_action( 'benecaster_outlinks_health_item_action_after', function ( string $action, array $item, array $args, array $result ): void {
if ( 'update_url' === $action ) {
error_log( sprintf( 'Link Health: post %d now links to %s instead of %s', $args['post_id'], $args['url'], $args['old_url'] ) );
}
}, 10, 4 );
Notes
Need this built rather than just documented? See our services →