This commit is contained in:
Javier Casares 2026-07-09 06:28:55 +00:00
commit db98c4438c

View file

@ -37,6 +37,47 @@ function wpvulnerability_add_every_six_hours( $schedules ) {
return $schedules;
}
// Add weekly and daily schedules used by the notification cron.
// These must be registered in this file (always loaded pre-init) so that the
// on-load notification scheduling at the bottom of this file can resolve the
// 'weekly' schedule before notifications.php is loaded at init.
add_filter( 'cron_schedules', 'wpvulnerability_add_every_week' );
add_filter( 'cron_schedules', 'wpvulnerability_add_every_day' );
/**
* Registers a custom weekly cron schedule.
*
* @since 2.0.0
*
* @param array<string, array<string, int|string>> $schedules Existing schedules.
* @return array<string, array<string, int|string>> Schedules with the weekly interval added.
*/
function wpvulnerability_add_every_week( $schedules ) {
$schedules['weekly'] = array(
'interval' => 604800,
'display' => did_action( 'init' ) ? __( 'Every week', 'wpvulnerability' ) : 'Every week',
);
return $schedules;
}
/**
* Registers a custom daily cron schedule.
*
* @since 2.0.0
*
* @param array<string, array<string, int|string>> $schedules Existing schedules.
* @return array<string, array<string, int|string>> Schedules with the daily interval added.
*/
function wpvulnerability_add_every_day( $schedules ) {
$schedules['daily'] = array(
'interval' => 86400,
'display' => did_action( 'init' ) ? __( 'Every day', 'wpvulnerability' ) : 'Every day',
);
return $schedules;
}
// Remove legacy scheduled events on subsites in multisite installs.
if ( is_multisite() && ! is_main_site() ) {
wpvulnerability_clear_plugin_cron_hooks();