Change how often Link Health checks and emails, or switch the digest off, from code
GET / PATCH /benecaster-outlinks/v1/link-health/settings is the route behind Link Health’s Schedule form. It is install-wide: it needs manage_options (an X-WP-Nonce for wp_rest) and Outlinks on for at least one show, else 403 benecaster_outlinks_not_active.
Both methods answer { check_frequency, digest_frequency }.
check_frequencyisweekly(the default) ordaily: how often the scheduled check runs. A change reschedules it at once.digest_frequencyisweekly(the default),dailyoroff. The email to the site’s admin address goes at the end of a check when that long has passed since the last one and something has broken since. A daily digest still only goes as often as the check runs.
PATCH changes only the keys sent. An unknown value is 400 benecaster_outlinks_settings_invalid with data.field, and nothing is saved.
Code
<?php
wp_set_current_user( 1 );
$request = new WP_REST_Request( 'PATCH', '/benecaster-outlinks/v1/link-health/settings' );
$request->set_header( 'X-WP-Nonce', wp_create_nonce( 'wp_rest' ) );
$request->set_body_params( [ 'check_frequency' => 'daily', 'digest_frequency' => 'daily' ] );
$settings = rest_do_request( $request )->get_data(); // [ 'check_frequency' => 'daily', 'digest_frequency' => 'daily' ]
Need this built rather than just documented? See our services →