Skip to content

Commit

Permalink
Merge pull request #669 from humanmade/cron-schedule-on-admin
Browse files Browse the repository at this point in the history
Move healthcheck schedule to altis migrate command
  • Loading branch information
roborourke authored Aug 26, 2022
2 parents 2c060b1 + d34333b commit 9c1bb94
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion inc/healthcheck/cavalcade/namespace.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Altis\Cloud\Healthcheck\Cavalcade;

use WP_CLI;
use WP_Error;

const JOB_HOOK = 'hm-platform.healthcheck.cavalcade';
Expand All @@ -23,8 +24,20 @@ function bootstrap() {
// phpcs:ignore WordPress.WP.CronInterval.ChangeDetected
add_filter( 'cron_schedules', __NAMESPACE__ . '\\add_cron_schedule' );

// Schedule if not already scheduled.
// Schedule on migrate command.
add_action( 'altis.migrate', __NAMESPACE__ . '\\schedule_job' );
}

/**
* Schedule the Cavalcade healthcheck.
*
* @return void
*/
function schedule_job() {
if ( ! wp_next_scheduled( JOB_HOOK ) && ( ! is_multisite() || is_main_site() ) ) {
if ( defined( 'WP_CLI' ) && WP_CLI ) {
WP_CLI::log( 'Scheduling Cavalcade healthcheck...' );
}
wp_schedule_event( time(), JOB_SCHEDULE, JOB_HOOK );
}
}
Expand Down

0 comments on commit 9c1bb94

Please sign in to comment.