Run a health check on the daily license cron in addition to the once-per-admin-session sweep
A health check that only runs when someone opens the WordPress admin has a blind spot: the podcaster who does not log in for three weeks. If the condition you are watching for matters while nobody is looking — a payment integration that stopped working, a feed that stopped updating — the check needs a second place to run.
Benecaster’s daily licence check is that place. Attaching your check to it means the notice is already waiting the next time the podcaster signs in, rather than being generated by their arrival.
When to Use This
Most checks want both — the daily run for coverage, the admin-session run for freshness.
Run it on the daily cycle only when the check is genuinely expensive: it makes a slow outbound request, or queries something large. Those are the checks worth keeping off every admin page load.
Run It Through Benecaster, Not Directly
Ask Benecaster to run your check rather than calling its method yourself. Going through Benecaster applies the same containment the admin sweep uses, so a check that throws during cron fails quietly instead of breaking the rest of the daily run.
Code
<?php
add_action( 'benecaster_boot', function ( \Benecaster\Container $container ): void {
$notices = $container->make( NoticeManager::class );
$check = new StripeWebhookHealthCheck( $notices );
// Admin-pageload sweep (transient-gated, once per session).
$notices->add_health_check( $check );
// Daily cron sweep — also runs the check on a fixed cadence so the
// notice shows up even if no admin ever opens wp-admin between firings.
add_action(
'benecaster_license_cron_complete',
function () use ( $notices, $check ): void {
$notices->run_health_check( $check );
}
);
} );
Hooks Used
Need this built rather than just documented? See our services →