run(); } /** * Schedule the weekly cron event if not already scheduled. * * Safe to call on re-activation — no-op when already scheduled. * * Side effects: Adds a WP-Cron event. * * @return void */ public static function schedule_weekly(): void { if ( ! wp_next_scheduled( PGM_CRON_HOOK ) ) { wp_schedule_event( time(), 'weekly', PGM_CRON_HOOK ); } } /** * Remove the weekly cron schedule. * * Called on deactivation. Does not purge data. * * Side effects: Removes the WP-Cron event. * * @return void */ public static function clear_schedule(): void { $timestamp = wp_next_scheduled( PGM_CRON_HOOK ); if ( false !== $timestamp ) { wp_unschedule_event( $timestamp, PGM_CRON_HOOK ); } } /** * Check whether the weekly event is currently scheduled. * * @return bool */ public static function is_scheduled(): bool { return false !== wp_next_scheduled( PGM_CRON_HOOK ); } }