diff --git a/flywp.php b/flywp.php index 6833a66..7ad0224 100644 --- a/flywp.php +++ b/flywp.php @@ -86,12 +86,15 @@ public function activate() { } /** - * Plugin activation hook. + * Plugin deactivation hook. * * @return void */ public function deactivate() { - ( new FlyWP\Api\UpdatesData() )->deactivate(); + $timestamp = wp_next_scheduled( FlyWP\Api\UpdatesData::CRON_HOOK ); + if ( $timestamp ) { + wp_unschedule_event( $timestamp, FlyWP\Api\UpdatesData::CRON_HOOK ); + } } /** diff --git a/includes/Api/UpdatesData.php b/includes/Api/UpdatesData.php index 26b33e8..fa3dbc5 100644 --- a/includes/Api/UpdatesData.php +++ b/includes/Api/UpdatesData.php @@ -2,11 +2,9 @@ namespace FlyWP\Api; -use WP_Error; - class UpdatesData { - private const CRON_HOOK = 'flywp_send_updates_data'; - private const CRON_INTERVAL = 'twicedaily'; + public const CRON_HOOK = 'flywp_send_updates_data'; + public const CRON_INTERVAL = 'twicedaily'; /** * UpdatesData constructor. @@ -236,14 +234,4 @@ private function load_required_files(): void { require_once ABSPATH . 'wp-admin/includes/update.php'; } } - - /** - * Deactivate the scheduler when the plugin is deactivated. - */ - public function deactivate(): void { - $timestamp = wp_next_scheduled( self::CRON_HOOK ); - if ( $timestamp ) { - wp_unschedule_event( $timestamp, self::CRON_HOOK ); - } - } }