Run your own code when Link Health’s schedule or exclusions are saved
Two before/after pairs fire when the Schedule and Exclusions forms on Settings → Link Health are saved, or when their routes are called (schedule, exclusions). Each pair fires only for a request that sends at least one of its route’s fields and passes validation: before immediately before the save, after once the save is done. A refused request (400, where nothing is saved) fires nothing, and so does a request with none of the fields. A field sent with the value already saved still fires.
benecaster_outlinks_health_settings_save_before( array $changes, array $previous ):$changesholds only the keys sent,check_frequency(weeklyordaily) and/ordigest_frequency(weekly,dailyoroff).$previousis{ check_frequency, digest_frequency }before the save.benecaster_outlinks_health_settings_save_after( array $settings, array $previous ):$settingsis{ check_frequency, digest_frequency }as saved, after a changed check frequency has rescheduled the check.benecaster_outlinks_health_exclusions_save_before( array $exclusions, array $previous ): both are{ domains, post_types, categories }.$exclusionsholds the cleaned lists about to be saved (domains lower case withoutwww., a pasted URL reduced to its host; post types fromepisode,pageandpost; categories as term ids),$previousthe lists saved until now. A list the request did not send is the same in both.benecaster_outlinks_health_exclusions_save_after( array $exclusions, array $previous, int $removed ): after the save, once the items the new exclusions cover have left Link Health;$removedis how many.
Code
<?php
add_action( 'benecaster_outlinks_health_exclusions_save_after', function ( array $exclusions, array $previous, int $removed ): void {
$added = array_diff( $exclusions['domains'], $previous['domains'] );
if ( [] !== $added ) {
error_log( sprintf( 'Link Health now skips %s (%d items removed)', implode( ', ', $added ), $removed ) );
}
}, 10, 3 );
Hooks Used
Need this built rather than just documented? See our services →